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

x/tools/gopls: add configuration for single-line hover #32561

Closed
inliquid opened this issue Jun 12, 2019 · 14 comments
Closed

x/tools/gopls: add configuration for single-line hover #32561

inliquid opened this issue Jun 12, 2019 · 14 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. Suggested Issues that may be good for new contributors looking for work to do.
Milestone

Comments

@inliquid
Copy link

Right now gopls returns only first sentence from the symbol documentation, please make it return full docs.
изображение

@gopherbot gopherbot added this to the Unreleased milestone Jun 12, 2019
@gopherbot gopherbot added Documentation gopls Issues related to the Go language server, gopls. labels Jun 12, 2019
@stamblerre stamblerre changed the title x/tools/cmd/gopls: make quick documentation return full docs, not just first sentence x/tools/cmd/gopls: show full docs, not just first sentence, on hover Jun 12, 2019
@stamblerre
Copy link
Contributor

This is intentional. Often, documentation can be lengthy and overwhelming (token.Pos is a good example), so we try to avoid showing it all on hover. My assumption was that, if the user wanted to see more detail, they could jump to the definition of the identifier.

However, if this is not the case, and other people are also interested in this behavior, I'd be willing to make this change.

If you want to see full documentation on hover, please upvote this issue or comment with your reasoning.

@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jun 12, 2019
@inliquid
Copy link
Author

Actually full docs on hover was available with all editors/tools that I was using so far:

  • VS Code + default command line tools
  • VS Code + go-langserver
  • VS Code + bingo
  • Goland

From my experience it's one of the most useful and demanded features. I wouldn't mind that gopls will have a config option to disable documentation on hover. Right now cutting it to first sentence is confusing and wrong because it creates wrong understanding by putting first phrase out of context and creating wrong impression for a developer that this first sentence IS the description, while it's not. It must either be full docs or no doc at all.

@marwan-at-work
Copy link
Contributor

marwan-at-work commented Jun 12, 2019

I like the small doc to not clutter everything. Before Gopls, when you hover over a signature you get a mini version of the doc (or none), but if you cmd+hover you get the full doc/definition. That was quite useful, because sometimes I just want to see the signature without having to recognize it from the docs...and sometimes I want to read the docs so I just cmd+hover

@stamblerre
Copy link
Contributor

Filed microsoft/language-server-protocol#772 to get more clarity on textDocument/hover.

@stm9443
Copy link

stm9443 commented Jun 27, 2019

I personally would prefer to have full comments over the single line version, but I can understand the desire to only see the signature at times. Is it possible to add a configuration that will change the length of comments that you see on hover?

Something like: showFullComments: true (default: false)

A setting like this would allow each developer to decide the style of comments they see when hovering.

@stamblerre
Copy link
Contributor

That does seem like a reasonable solution while we wait on modifications to the LSP specification. I think the options should be 1) full, 2) shortened, 3) single line (to support clients like vim-go, which currently trims to a single line).

@stamblerre stamblerre changed the title x/tools/cmd/gopls: show full docs, not just first sentence, on hover x/tools/cmd/gopls: add configurations for level of documentation on hover Jun 28, 2019
@stamblerre stamblerre changed the title x/tools/cmd/gopls: add configurations for level of documentation on hover x/tools/gopls: add configurations for level of documentation on hover Jul 2, 2019
@gopherbot
Copy link

Change https://golang.org/cl/184797 mentions this issue: internal/lsp: add configuration for hover levels

gopherbot pushed a commit to golang/tools that referenced this issue Jul 3, 2019
Instead of defaulting to a one sentence synopsis for documentation on
hover, allow the user to configure the amount of documentation they want
to see. Right now, the options are none, some (using go/doc.Synopsis),
or all. We should add a 4th, single-line, mode, which will allow clients
like vim-go to stop stripping off documentation on hover.

Updates golang/go#32561

Change-Id: I529242da84b794636984d5ef2918b7252886f0ef
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184797
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
@stamblerre stamblerre changed the title x/tools/gopls: add configurations for level of documentation on hover x/tools/gopls: add configuration for single-line hover Jul 8, 2019
@stamblerre stamblerre added NeedsFix The path to resolution is known, but the work has not been done. Suggested Issues that may be good for new contributors looking for work to do. and removed Documentation WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jul 8, 2019
movie-travel-code pushed a commit to movie-travel-code/tools that referenced this issue Jul 11, 2019
Instead of defaulting to a one sentence synopsis for documentation on
hover, allow the user to configure the amount of documentation they want
to see. Right now, the options are none, some (using go/doc.Synopsis),
or all. We should add a 4th, single-line, mode, which will allow clients
like vim-go to stop stripping off documentation on hover.

Updates golang/go#32561

Change-Id: I529242da84b794636984d5ef2918b7252886f0ef
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184797
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
@inliquid
Copy link
Author

I think gopls must either not show doc at all or show full docs. Cutting first sentence out of the context is simply wrong. There a lot of cases where first sentence is smth like You can use that method for anything you like. and second But do it at own risk. It's not supported. It's DEPRECATED. (exaggerating)
Adding additional click to this flow is also wrong. It's degraded user experience. Documentation on hover vs documentation on hover + CLICK is HUGE difference. In the last case you'll put VS Code with vscode-go down the bottom of rank of good Go editors.

@gopherbot
Copy link

Change https://golang.org/cl/188981 mentions this issue: internal/lsp: support single-line hover for LSP clients like Vim

@mattn
Copy link
Member

mattn commented Aug 6, 2019

Latest Vim have popup window. it can indicate multiple-lines. vim-lsp have already option to switch hover to popup.

@stamblerre
Copy link
Contributor

@mattn: Right, I have heard that the latest versions of Vim have popups, but I think a large number of people are still using older versions. vim-go also strips hover information to turn it back into a single line, so I think it would be simpler for gopls to provide the single line, at least for now.

@inliquid
Copy link
Author

inliquid commented Aug 8, 2019

@stamblerre how do I use this new option?

@stamblerre
Copy link
Contributor

Add this to your VSCode settings:

"gopls": {
        "hoverKind": "SingleLine", // hoverKind can be NoDocumentation, SingleLine, Synopsis, FullDocumentation
}

I will add more documentation to the gopls wiki once we solidify the supported set of configurations.

@inliquid
Copy link
Author

inliquid commented Aug 8, 2019

@stamblerre thanks, that works, I will use "FullDocumentation". Now with that option available, may I ask to move signature above the documentation, as it was done previously in sourcegraph's language server, bingo, and as in default vscode-go config with godoc or gogetdoc? Because now I have to scroll down to the bottom to just see the signature.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. Suggested Issues that may be good for new contributors looking for work to do.
Projects
None yet
Development

No branches or pull requests

6 participants