ShadowMitia · 2022-12-30 20:37
I've been playing around eglot to compare with lsp-mode. I've been liking it so far, using corfu as well to show completion. The only I wish I could have right now is show code lenses in the code.
I don't think eglot has the ability to show code lenses (unless I'm missing something obvious). So another package would have to take over, but I can't find one other than the ones integrated for lsp-mode.
Has anyone been able to have some kind of code lens with eglot? I'm open to suggestions!
TheFrenchPoulp · 2022-12-30 21:09
For the less fluent ones in LSP-speak, what are code lenses exactly?
ShadowMitia · 2022-12-30 21:17
It's extra information and actions that can be shown inside the editor.
Here is an example of buttons to compile and run in normal and debug mode for rust, directly show about the main function in rust:
[https://emacs-lsp.github.io/lsp-mode/page/main-features/#code-lens](https://emacs-lsp.github.io/lsp-mode/page/main-features/#code-lens)
It can show data given by the server such as references in the code.
[https://www.reddit.com/r/emacs/comments/9k3rf6/put\_a\_codelens\_overlay\_sticking\_in\_the\_end\_of\_the/](https://www.reddit.com/r/emacs/comments/9k3rf6/put_a_codelens_overlay_sticking_in_the_end_of_the/)
In my case what I really enjoy is showing the deduced types in Rust directly in the code, helps a lot in visualizing what's going on.
cradlemann · 2022-12-30 21:47
lsp-ui and code lenses are very useful features for me. Especially file preview while switching between options. Eglot is not an option for me unfortunately.
TheFrenchPoulp · 2022-12-30 21:55
Actions Eglot already support afaict, but for instance seeing the definition of a type (TypeScript) in an overlay would be useful for me I think. Would let me see a complete type without having to go to definition and mess with current buffers and window geometry
Thanks for the examples
fuzzbomb23 · 2022-12-31 00:12
"Code lenses" cover quite a broad range of features.
They are a mixture of statistics, metadata, links, and action, which relate to your code. The thing they have in common is that the information is gleaned from elsewhere; static code analysis, bug trackers, version control, and so on.
The GUI aspect is that the information is presented in the editor window. The Microsoft editors put little summaries inline, which have bunch of pop-up windows. (If you like that sort of thing; personally I'd prefer the information to be in a separate side pane, where they won't obscure the actual code in the editing pane.)
For an overview, including fancy UI screenshots, see [Find code changes and other history with CodeLens](https://learn.microsoft.com/en-us/visualstudio/ide/find-code-changes-and-other-history-with-codelens?view=vs-2022).
Some features are directly related to the program code and language:
* Find references, or find definition. (Eglot makes this information available via an xref backend, but it leaves the UI to other packages).
* Information about base methods overridden, or interface methods implemented.
Meanwhile some features are less directly related to the language used:
* VC history of the current function. (You can get this in Emacs from vc-annotate, or some other "blame" packages.)
* Open issues related to the current function.
* Open pull requests which touch the current function.
* Code review annotations about the current function.
* Tests for the current function (e.g. actions to run locally, or statistics from a CI server).
The thing I don't grok is what these later ones have to do with LSP. Version control, bug trackers, and CI are often orthogonal to the programming *language*. I suppose some tools and concepts have been conflated by marketing efforts for one-stop services like Azure DevOps.
In Emacs, you can get some of the issue/pull information from the Magit Forge package.
The quick-peek Emacs package might be of interest here.
slinchisl · 2022-12-31 06:22
There's a [stale pr](https://github.com/joaotavora/eglot/pull/71) from 2018 in the eglot repo. I suppose someone would have to pick that back up.
ShadowMitia · 2022-12-31 09:48
Oh I missed that, thanks!