Skip to content
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

offer more configuration for textDocument/hover #772

Open
stamblerre opened this issue Jun 12, 2019 · 6 comments
Open

offer more configuration for textDocument/hover #772

stamblerre opened this issue Jun 12, 2019 · 6 comments
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities hover
Milestone

Comments

@stamblerre
Copy link

Because the hover result is either a string or a markdown string, it's hard to offer users more configuration over their hover results.

A good example of this is this issue raised against gopls: golang/go#32561. Some users want to see full documentation on hover, while others prefer to see one sentence of the documentation, while others may prefer to see none at all.

Personally, my preferred solution would be to offer users a "see more" option, something like holding down Command and hovering over an identifier. Right now, that just previews the declaration of the identifier, but perhaps it could be something like a detailed hover?

Is there any chance that the textDocument/hover could have a detailed configuration, or maybe there could be an additional textDocument/detailedHover? I would suspect that most languages return some combination of documentation and signatures/type declarations, so maybe hover could even be more structured than just a string?

Otherwise, I will likely add additional configurations to gopls to control the level of hover. I figured it was worth raising this issue because I suspect other languages would encounter these questions as well.

@dbaeumer
Copy link
Member

To stay in line with other request we should improve this in the following way:

  • have a HoverItem result type
  • have a content property that is MarkupContent
  • have an optional details property that is MarkupContent
  • have a hover/resolve request to resolvethe details value is needed.

I am open to such a improvement. However it needs to be speced and we need to have a reference implementation for it.

@dbaeumer dbaeumer added feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities labels Jun 14, 2019
@dbaeumer dbaeumer added this to the Backlog milestone Jun 14, 2019
@alanz
Copy link

alanz commented Jun 14, 2019

This feature would also help for emacs-lsp, where the hover request is used both to provide the documentation for the current focal point, but also to get summary information for variables in the local context. So have either a two-level request, or a two-level reply would help.

See emacs-lsp/lsp-ui#292

@stamblerre
Copy link
Author

To add a bit more to this issue - golang/go#33352 was just raised in gopls. To me, it seems like the best solution for this issue would be to have a more structured return type from textDocument/hover. I would expect that most languages return some combination of documentation and a signature--would it be possible to separate the two in the hover result?

@stamblerre
Copy link
Author

@dbaeumer: Just to clarify, would I be able to contribute the solution for this issue, or would it have to be someone who works on the LSP?

@dbaeumer
Copy link
Member

@stamblerre sorry for the late reply. Yes, I would accept a PR for this. However as state we need a reference implementation for it in one of the editors / tools. It can't only be a spec update.

jsravn added a commit to jsravn/lsp-mode that referenced this issue Apr 23, 2020
Many LSP servers, like gopls, return `document/onHover` as
MarkupContent. This modifies the eldoc behavior to support MarkupContent
by displaying the first rendered line. As the majority of LSP servers
return the signature, this will display the signature as most people expect.

In the future,
microsoft/language-server-protocol#772
should make this more reliable.
yyoncho pushed a commit to emacs-lsp/lsp-mode that referenced this issue Apr 23, 2020
* Display the first line of MarkupContent in eldoc

Many LSP servers, like gopls, return `document/onHover` as
MarkupContent. This modifies the eldoc behavior to support MarkupContent
by displaying the first rendered line. As the majority of LSP servers
return the signature, this will display the signature as most people expect.

In the future,
microsoft/language-server-protocol#772
should make this more reliable.

* nit: use s-lines
@dbaeumer dbaeumer added the hover label Nov 11, 2020
@ejgallego
Copy link

My use case for a hover extension is that often for a particular position I have different infos corresponding to different ranges under the position.

I understand this would cover my case of returning multiple pairs of hover info + range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities hover
Projects
None yet
Development

No branches or pull requests

4 participants