Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Godoc not appearing in code-completion #194

Closed
luca-moser opened this issue Feb 7, 2016 · 7 comments
Closed

Godoc not appearing in code-completion #194

luca-moser opened this issue Feb 7, 2016 · 7 comments

Comments

@luca-moser
Copy link

Hi Luke.

System:

  • vscode-go 0.6.26
  • Visual Studio Code 0.10.6.
  • Windows 10 (64-bit)

Godoc does not appear when using code-completion.

In this animation we have some code written on the right pane which calls a function from the code on the left pane. You see that the func GetGroupIDsOfUser has a comment, however, it does not appear in the code-completion:
animation

Godoc should appear when:

  • the cursor is inside the parentheses of a function call
  • the auto-completion list is open with suggestions of functions

The godocs do not show up on my own code, however, when using the fmt package as an example, it only shows itself sometimes:
animation2

@lukehoban
Copy link
Contributor

Yes - ideally we'll show the GoDoc information in QuickInfo and Completion as well. Currently we only show it in SignatureHelp. Should be fairly straightforward to integrate with these other features as well.

@ramya-rao-a
Copy link
Contributor

We are blocked on nsf/gocode#415 to get the docs during completion.

As of now we have docs in Signature Help and Quick Info.

@ramya-rao-a
Copy link
Contributor

One way we could achieve this is

Will not work for pkg with alias
Need to be smart to not call godoc for the same pkg multiple times. Example: fmt.P will give multiple functions, but godoc needs to be called just once.

@antifuchs
Copy link

Just a heads-up that there's now a PR to nsf/gocode that adds a package import path field to each autocomplete symbol. It might be possible to get all the information you need from that. Please test this out and let me know if it breaks things!

@segevfiner
Copy link
Contributor

Note that there is even a VS Code API meant for this case: CompletionItemProvider.resolveCompletionItem.

@ramya-rao-a
Copy link
Contributor

That is a good idea @segevfiner

Using resolveCompletionItem is better as we will then be fetching docs for just the suggestion item in focus instead of doing it for all items which would happen if we were to fetch docs in the provideCompletionItems call.

If anyone is interested in picking up this item, here are a few code pointers:

  • Build and Debug Extension to get a local set up of the extension up and running
  • All changes would be in the goSuggest.ts file
  • Extend the CompletionItem object to include a new property called package. Store the package info @antifuchs mentioned in Godoc not appearing in code-completion #194 (comment) in this object and ensure this is returned by provideCompeltionItems function
  • Implement the resolveCompletionItem function in the Completion provider. You now have both the package import path and the symbol name which you can then use to call godoc to get the documentation on the symbol.

segevfiner added a commit to segevfiner/vscode-go that referenced this issue Oct 26, 2018
Using `go doc` instead of `godoc` due to
golang/go#25443

`go doc` doesn't support giving the code of an unsaved file via stdin
like `gocode`, so it won't display documentation for unsaved changes.

TODO: Make sure this works for all cases, the current file, main package,
etc...

Fixes microsoft#194
segevfiner added a commit to segevfiner/vscode-go that referenced this issue Oct 26, 2018
Using `go doc` instead of `godoc` due to
golang/go#25443

`go doc` doesn't seem to support giving the code of an unsaved file via
stdin like `gocode`, so it won't display documentation for unsaved
changes.

Fixes microsoft#194
segevfiner added a commit to segevfiner/vscode-go that referenced this issue Oct 26, 2018
Using `go doc` instead of `godoc` due to
golang/go#25443

`go doc` doesn't seem to support giving the code of an unsaved file via
stdin like `gocode`, so it won't display documentation for unsaved
changes.

Fixes microsoft#194
ramya-rao-a pushed a commit that referenced this issue Nov 1, 2018
* Add item documentation to completions

Using `go doc` instead of `godoc` due to
golang/go#25443

`go doc` doesn't seem to support giving the code of an unsaved file via
stdin like `gocode`, so it won't display documentation for unsaved
changes.

Fixes #194

* Code review fixes for #2054

* Refactoring and comments

* Always resolve the item

* Prompt for updating gocode if the package property is missing
@ramya-rao-a
Copy link
Contributor

This long pending feature is now out in the latest update of this extension (0.7.0)
Thanks to @segevfiner!

@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants