-
-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: autocomplete (and validate) known map keys #2241
Comments
Thanks for the extensive info. @ericdallo, any thoughts here about clojure-lsp's side of supporting this? |
Very cool! Iiuc, we wouldn't need to do anything on the Calva side of things if clojure-lsp is made to support this. Is that how you understand it too, @bpringe? |
Yes, that seems to be the case to me as well. |
Thanks for the detailed issue description, I do think clojure-lsp with clj-kondo's help should make that work. |
Autocomplete (and validate) known map keys
Related to the Slack discussion on #calva and in #clj-kondo: Clojure is a dynamically typed language, but we could leverage the runtime schema/spec data in IDE to provide better type linting and auto-complete of known map keys. This would radically improve developer experience, help people come from ecosystem like TypeScript and lessen the map fatigue.
The below examples are based on malli, but the same approach could work with schema and spec too.
Use Case
i. function argument or return value
ii. var value
iii. edn file (e.g. config file)
i. errors without evaluating the code
ii. autocomplete on known map keys
Current Status
Suggestion
Add IDE-support for autocompleting map keys in case we know the data form via malli schemas for the data. Integrate this to when creating literal data maps (2ii & 2iii) and when accessing schematized function arguments within the function body.
This might require work on all of malli, clj-kondo, lsp-clojure and calva.
Happy to help from malli side.
Screenshots
Malli + clj-kondo ✅
Malli Vars 🚧 👍
Imaginary Autocomplete of known keys 👍
JSON + JSON Schema + VSCode ✅
Typescript + VSCode ✅
Bonus
As Malli supports lite-syntax, the syntax is not far from typescript (in the simple cases):
The text was updated successfully, but these errors were encountered: