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? |
|
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! |
3e838ff to
0096f95
Compare
|
Heya 👋 I picked this up again after a loooong time, there seems to be way more of the ground work done to get this working properly. Rebase was too hard, so I started from scratch, sorry for the nuked history of this PR. It should now work properly by auto-requesting code lenses for documents.
Done parts which weren't part of the outdated PR:
Feel free to test-drive (I will try to keep the branch up to date) and report any issues (just keep in mind what's unimplemented and expected vs. what should be working and isn't). |
|
Displaying code lenses as a virtual text would ideally be done by implementing |
55acb30 to
314f869
Compare
2d8efc8 to
a7e7749
Compare
a7e7749 to
af6eaad
Compare
856e245 to
097f7f5
Compare
Allows requesting code lenses and renders them in the gutter with the lowest priority.
Request code lenses on newly opened documents, when a language server is started, etc.
Initial (limited) implementation of LSP code lenses1. This is purposefully as small of a change as possible, it displays code lenses in the gutter and adds a single new command
show_code_lenses_under_cursorthat displays a picker for code lenses on the current line. Notably, displaying code lenses as annotations for the current line is not implemented and this implementation doesn't support resolving code lenses from multiple language servers. I am happy to address both but would prefer to do so separately to make this PR reviewable amidst the low bandwith and large backlog for maintainers.Code Lens
From the VS Code features docs2:
And from the official LSP docs3:
Support
The support for code lens varies among LSPs but there are already nice features that can be achieved via code lenses (some of them listed below). The biggest limitation is that some language servers rely on client-side command execution which is usually solved via plugins. For other LSPs code lenses are opt-in only and without plugins can for example only display inline hints about number of references or number of implementations4.
Still, LSP is part of Helix and given Code Lenses are part of the specs, I think it's fair to implement them. Even if - without a plugin system - with limited capabilities.
generate,vendor,update dependency, and more.runfor 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 testsupport - requires client side execution(didn't check more languages).
Future work
As mentioned above this implementation is limited and doesn't provide Code Lens as they should be provided - displayed contextually as a text - close to the code that they apply for. There should be a follow up PRs for:
Showcase
Screen.Recording.2025-11-21.at.14.16.32.mov
Related/fixes: #3005
Related: #3272
Footnotes
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_codeLens ↩
https://code.visualstudio.com/blogs/2017/02/12/code-lens-roundup ↩
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_codeLens ↩
https://github.com/typescript-language-server/typescript-language-server?tab=readme-ov-file#code-lenses-textdocumentcodelens ↩
https://github.com/golang/go/issues/36787 ↩