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: support markdown in completion items #57300

Closed
rodrigocfd opened this issue Dec 11, 2022 · 4 comments
Closed

x/tools/gopls: support markdown in completion items #57300

rodrigocfd opened this issue Dec 11, 2022 · 4 comments
Assignees
Labels
FeatureRequest FrozenDueToAge gopls/completion Issues related to auto-completion in gopls. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@rodrigocfd
Copy link

rodrigocfd commented Dec 11, 2022

What version of Go, VS Code & VS Code Go extension are you using?

  • Go 1.19.4
  • VSCode 1.74.0
  • Go extension 0.36.0

Describe the bug

Go 1.19 introduced a lot of new additions to doc comments, in particular, a syntax to add hyperlinks to the text. The hyperlinks render correctly when hovering the entity with the cursor, but not in autocomplete.

package foo

// Just says [hello].
//
// [hello]: https://en.wikipedia.org/wiki/Hello
func Hello() string {
    return "hello"
}

Screenshots or recordings

The VSCode extension correctly renders the hyperlinks when hovering the function declaration:

1 hover func

And it also correctly renders the hyperlinks when hovering the function calls:

2 hover func

However, in autocompletion, the new hyperlink syntax disappears, and we read instead the raw syntax formatting:

3 autocomp

The autocomplete box should also render the hyperlinks.

@findleyr
Copy link
Contributor

Thanks for the report.

This is a new problem for us to solve due to go 1.19 doc comment support. Our completion results just return string documentation, but the LSP spec for CompletionItem supports returning MarkupContent.

Transferring to the gopls issue tracker.

CC @pjweinb, who coincidentally worked on both the new doc comment support AND support for unions in the protocol package.

@findleyr findleyr changed the title Autocomplete doesn't render hyperlinks in doc comments x/tools/gopls: support markdown in completion items Dec 14, 2022
@findleyr findleyr transferred this issue from golang/vscode-go Dec 14, 2022
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Dec 14, 2022
@gopherbot gopherbot added this to the Unreleased milestone Dec 14, 2022
@findleyr findleyr modified the milestones: Unreleased, gopls/later Dec 14, 2022
@findleyr findleyr added the gopls/completion Issues related to auto-completion in gopls. label Dec 14, 2022
@pjweinb pjweinb self-assigned this Dec 14, 2022
@pjweinb
Copy link

pjweinb commented Dec 14, 2022

It is possible to change gopls to provide this new behavior:

  1. CompletionItem.Documentation is presently a string, but should be a MarkupItem (or at least accept MarkupItem)
  2. Gopls has to look at the client's optional SignatureHelpClientCapabilities.SignatureInformation.DocumentationFormat list to see if the client prefers markdown to plaintext. (as vscode does)
  3. And if so, convert the documentation to markdown (as is already done for Hover).
  4. (it's probably not quite this simple...)

Getting this done is dependent on some existing CLs getting approved first. (and prioritization, of course, but it looks worth doing)

@gopherbot
Copy link

Change https://go.dev/cl/463135 mentions this issue: gopls/completions: use markdown for completions

@gopherbot
Copy link

Change https://go.dev/cl/463377 mentions this issue: tools/gopls: provide markdown for completion and signature help

@golang golang locked and limited conversation to collaborators Jan 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest FrozenDueToAge gopls/completion Issues related to auto-completion in gopls. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants