-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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(lsp): code lenses #5063
base: master
Are you sure you want to change the base?
feat(lsp): code lenses #5063
Conversation
This is not specific to rust-analyzer, I think that other lsps work the same way (especially for test codelens), for example I know its the case with deno lsp. I think this would require plugins to handle, because executing the commands is lsp dependent |
@sigmaSd yes, indeed, you are right. Rust for example returns |
How many servers actually support server side execution? If rust-analyzer is the odd-one out with client-only commands then this might be worth merging but if almost all LSPs only allow client-side command execution then I think this should probably wait for plugins. |
eb99696
to
867e027
Compare
I can confirm that at least Metals also expects the client to run some code lens commands and they are implemented in the plugin for sublime for example. |
Hi, I'm new to git and I have question. I already have helix 23.03 and in release notes there is information about Initial support for snippets, but #3005 bug is still there. This is how it is supposed to be? Automatic type annotation is one of best things in haskell. |
Closing this until Helix has support for plugins that are prerequisit for this being useful. |
I have a question about this: It is my impression that there are code lenses which don’t need a plugin to work. I think haskell-language-server has some of those. Is that wrong? Or could we maybe implement this, but only show code lenses in the case where they don’t require a plugin? |
Similar to the above comment, in For example, when in |
👋 let me take a look if I could revive this. Indeed, the support might vary language to language but for some languages this might be worthwhile even in limited capacity. |
cc7cdc8
to
4d7203d
Compare
Also: Even if Code lenses can’t be triggered it might still be useful to show them, right? And that part should always work without plugin support, right? |
Initial implementation of LSP code lense.
I am test driving this and it works just fine with haskell-language-server. Of course it would be nice if the code lenses would auto-update, but this is good enough for me. Thank you! |
This PR provides initial (limited) implementation of LSP code lens1. The purpose is to provide ground for future improvements and experimentation.
Code Lens
From the VS Code features docs:
Implementation
This PR strafes a little bit from the standard approach to code lens to limit the scope of the initial PR. Instead of showing the code lens close the location that they apply to (via for example virtual text) this PR provides only a code lens picker that provides overview of all code lenses for specific file. The code lenses can be scrolled through, showing preview of the part of the file that they apply to, and executed.
Support
The support for code lens seems limited among certain LSPs but there are already nice features that can be achieved via code lenses (some of them listed below). The biggest limitation is that a lot of language servers rely on client-side command execution which is usually solved via plugins.
generate
,vendor
,update dependency
, and more.run
for tests and main - requires client side execuityreferences
/implementations
(show number of references/implementations and can be opened to view them, disabled by default) - requires client side executionrun test
support - requires client side execution(didn't check other languages so far).
Future work
As mentioned above this implementation is limited and doesn't provide Code Lens as they should be provided - contextually - close to the code that they apply for. Here's non-exhaustive list of improvements I would like to implement in follow-up PRs or in follow-up commits here (not yet decided on the full scope):
▶
in the diagnostic gutter)space + l
?) menu (e.g. same look as code completion)codeLens/resolve
workspace/codeLens/refresh
server requestShowcase
Here's showcase of what's missing:
Screen.Recording.2022-12-08.at.11.43.53.mov
You can see that the information about implementation/references needs to be resolved via the
codeLens/resolve
and thatrust-analyzer
doesn't support executing commands (on the server side) so the commands need to be executed client side.Related/fixes: #3005
Related: #3272
Footnotes
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_codeLens ↩
https://github.com/golang/go/issues/36787 ↩