-
Notifications
You must be signed in to change notification settings - Fork 98
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
feat: definitions and references lsp hint #1016
base: main
Are you sure you want to change the base?
Conversation
Also this would enable semantic highlighting I think? |
Consider using
I think we should do it for this new code and retroactively do it for the inactive code hints too. Probably good to compartmentalize the bulk of the new stuff into a new module. We could make the functions always be called, and then the function body can be conditionally compiled (with an empty body by default); and rely on dead code elimination to do the right thing. Or add conditional compilation at the call-site to guarantee the optimization. |
c2099f9
to
7b0ff8d
Compare
f97183a
to
df047ee
Compare
.push_from_atom(atom); | ||
vkey_expr | ||
.atom(s.vars()) | ||
.expect("must be atom since we're matching atom") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fly-by comment
The way this new code works isn't right because match
ing an expr and finding an Atom
might find you a $var
that is actually a list.
You might want to add span_atom
equivalent of span_list
, which I haven't yet added because I didn't have the need for it.
Describe your changes. Use imperative present tense.
Add goto definition support for LSP consumers. Adding support for it directly in LSP server could maybe be doable, but unreliable (e.g. templates are complicating things) and so a lot of parser logic would need to be reimplemented for all edge cases, so I think this is better added directly to kanata-parser.
For now I've added definition and references for aliases. I'd like to wait for recieve some feeback (i.e. if this is a direction we want to take) before adding the rest (variables, layers, etc.).
Currently the code is working for aliases when paired with rszyma/vscode-kanata#32
Implementation notes:
I couldn't add
lsp_hints
toParserState
, because it would require changing&
to&mut
ons
param in many places which would be really ugly, and even then, when trying to switch to&mut
at some point I got an error regarding multiple borrows of&mut s
at the same time. So instead I've added additionallsp_hints
param to many functions.Other done things:
lsp_hint_inactive_code
fromParserState
toIntermediateConfig
Other thoughts:
Perhaps for performance purposes LSP features could be behind a feature flag, but it doesn't seem like it causes any major performance degradation + parser code runs only once, so for simplicity I didn't introduce the flag.
Checklist 1
Go-to definition and references implemented for:
Checklist 2