emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.76k stars 879 forks source link

rust-analyzer client: extract signature in hover content #4465

Closed blahgeek closed 4 months ago

blahgeek commented 4 months ago

The full hover content from rust-analyzer usually looks like this:

Screenshot_20240529_232050 Screenshot_20240529_232031

By default, when lsp-eldoc-render-all is nil, only the first line (the comment) is show.

This PR implements the extraction method (like clangd) to return the first non-comment line.

jcs090218 commented 4 months ago

Thank you!

scturtle commented 3 months ago

Another solution is in https://github.com/emacs-lsp/lsp-mode/pull/1740 and it's included in doom emacs now.

blahgeek commented 3 months ago

Thanks for the link. I did not know that exists.

Based on my reading, these two PRs are not exactly the same though. https://github.com/emacs-lsp/lsp-mode/pull/1740 aims to extract a meaningful section for a type (for hovering on a type definition), the solution is rather heuristic and more format-specific, and arguably more opinionated. This PR merely strip comments from the result (usually for hovering on a variable).

So personally I can see why this PR is more suitable and accepted, or at least as a first step (I'm surely biased :) ) But of course I'm happy to see more improvement on this function by anyone