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: attach documentation to completion items #29151
Comments
I would love to help If possible, can you please guide me @stamblerre |
@Tolsee: absolutely! The main feature here involves generating documentation from a Feel free to send me a change for review if you'd like to work on this. |
Note: If in case getting the docs takes a little more time, then it need not be sent for each of the completion item in the result. There is a resolve completion item request for just the completion item in focus. You can send the docs as part of this request. |
Also happy to assist @Tolsee, let me know if I can be of any help. |
Saw in the tools update that this would be a good issue to get started. Is anybody actively working on this? If not I'm game to give it a go, probably starting in trying to get any docs included in Hover as that seems like a fairly clear start. |
Don't believe so - just assign yourself when you start working so others will be aware. Feel free to reach out to me here or on Slack with any questions! We should be able to add a documentation function that can be used by both Hover and Completion. |
Great, let me see if I can get a dev environment rolling against VSCode and if that works then I'll volunteer for this. I've done some documentation extraction for our own go stuff so have some experience on this so in theory should be able to knock this out. |
Ok, I'm going to give this a go, got this working with a vscode-ception of gopls which is fun. I can't assign myself this but I'll look at this over the next few days and hopefully have something in a day or two to show. |
Looks like I can't assign it to you either - I guess you have to have some ownership in the repository or something. Self-assigned to make it obvious that this is taken. |
Realize this is a slightly different issue but on the call you mentioned not liking the tag treatment when looking at a struct. Started looking at that since that seemed an even simpler entry point and that looks like explicit behavior in |
good idea! yeah i think eliminating them makes the most sense. |
Ah, I see now, the format is part of the core library in |
I looked at this when writing the guru compatibility, I think a complete implementation inside lsp/source is the only viable approach. |
I'm not convinced it's the tags that makes the tooltip hard to look at, but rather the lack of formatting. We've been displaying the tags in Atom's hover implementation for a while and haven't received any feedback that the tags are a problem. Here's a screenshot of a tooltip that includes tags but properly formats the struct type definition: |
Ya, I kinda agree. Maybe we should start with formatting first and see how people feel about it before reimplementing all the |
I'd like to jump on this one if it is back to available. |
I actually have a CL in progress to fix this, sorry I didn't write here earlier. It's actually a fairly big change, so I may be able to file several more issues once my first one is in. |
Change https://golang.org/cl/172661 mentions this issue: |
This change associates an ast.Node for some object declarations. In this case, we only handle type declarations, but future changes will support other objects as well. This is the first step in adding documentation on hover. Updates golang/go#29151 Change-Id: I39ddccf4130ee3b106725286375cd74bc51bcd38 Reviewed-on: https://go-review.googlesource.com/c/tools/+/172661 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
Change https://golang.org/cl/172958 mentions this issue: |
This change adds support for showing documentation when hovering over any named type or function. For now, we show the entire comment associated with the type; in future CLs, we should refine our approach and perhaps only show the first line or sentence. Updates golang/go#29151 Change-Id: Ib33284747b19acba67d79fb55c916574c3dd8073 Reviewed-on: https://go-review.googlesource.com/c/tools/+/172958 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
As I'm sure you are aware, note that Go doc strings are not Markdown but rather have their own minimalistic formatting. For them to display with formatting correctly they will need to be converted to Markdown before returning them if we want them to show up formatted in the editor correctly. See microsoft/vscode-go#2245 where I implemented this transformation albeit in JS and here it is needed in Go. |
Thanks for bringing this to my attention, @segevfiner! Right now in |
Change https://golang.org/cl/180657 mentions this issue: |
This change refactors hover to generate documentation for just the declaration portion of an identifier. Updates golang/go#29151 Change-Id: I16d48a99b56c36132e49cc87e2736f85c88ed14a Reviewed-on: https://go-review.googlesource.com/c/tools/+/180657 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
The last case that needs documentation is completion items. This should probably be done on |
To do that on So what should that key for looking up the object in resolve be? |
I do think we should cache identifier information to avoid recomputing hover information, but I think to start, we may be able to avoid caching. If we know the position of the completion item, we can get the identifier at the position and get the documentation that way. It might not be technically correct, as the code could change before the item is resolved, but in practice, I'd be surprised if that were a common occurrence. |
I think gopls has type info cached so it sounds reasonable to me it will already have a mechanism for this. Maybe |
Change https://golang.org/cl/184721 mentions this issue: |
This change adds documentation to the completion items. This normally should be done in completionItem/resolve, since it takes more time to compute documentation. However, I am not sure if that latency incurred by pre-computing documentation is actually significantly more than the latency incurred by an extra call to 'completionItem/resolve'. This needs to be investigated, so we begin by just precomputing all of the documentation for each item. Updates golang/go#29151 Change-Id: I148664d271cf3f1d089c1a871901e3ee404ffbe8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/184721 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
This change adds documentation to the completion items. This normally should be done in completionItem/resolve, since it takes more time to compute documentation. However, I am not sure if that latency incurred by pre-computing documentation is actually significantly more than the latency incurred by an extra call to 'completionItem/resolve'. This needs to be investigated, so we begin by just precomputing all of the documentation for each item. Updates golang/go#29151 Change-Id: I148664d271cf3f1d089c1a871901e3ee404ffbe8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/184721 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
The above change experimentally added the documentation to the completion items, but we still have a few things to determine before turning this feature on by default. In particular - should we move to the approach of using |
Completion documentation was turned on by default at master, so closing this issue. |
LSP has a field for documentation in completion items, as well as space for markdown in the "hover" request. We should attach useful documentation here.
The text was updated successfully, but these errors were encountered: