Skip to content

x/tools/gopls: hover: doc link markup ignores import mapping of current file, omits links #61677

Open
@nikos-atwise

Description

@nikos-atwise

Is your feature request related to a problem? Please describe.
When hovering over a symbol in the editor, currently some go doc links do not render as links in the tooltip.

If the link is to some URL, then it will appear correctly. If the link is to a fully-qualified symbol eg [encoding/json.Marshal] then it will also appear correctly. However links to symbols imported in the current package but not fully-qualified will not appear as links.

Describe the solution you'd like
For builtins or standard library symbols that are accessible, they should link to their pkg.go.dev pages.

For symbols imported in the current package that are not rooted in the same module as the symbol being hovered on, they should also link to their pkg.go.dev pages. (Of course, they may not actually exist on pkg.go.dev, but I think this is good enough, and I believe GoLand does the same thing - it's been a while since I've used it however.)

For symbols imported in the current package that are rooted in the same module as the symbol being hovered on, I think the tooltip should change to showing the documentation for that symbol, since the full comment text should be available in the current workspace.

Describe alternatives you've considered
None

Additional context

https://tip.golang.org/doc/comment#doclinks describes the rules for links.

Given the code sample:

package sample

import "encoding/json"

// This is a sample go doc comment.
//   - [A regular link] works fine.
//   - So does a fully-qualified link to a builtin like [encoding/json.Marshal].
//   - And even non-builtins like [github.com/vmihailenco/msgpack/v5.Marshal].
//
// However...
//   - A link to a symbol accessible through an alias does not: [json.Marshal]
//   - Neither does a link to a symbol in the current package: [Bar]
//
// [A regular link]: http://example.com
type Foo struct{}
type Bar struct{}

func (Foo) F() {
	json.Marshal(nil)
}

This tooltip is shown when I hover over Foo in the editor:

Screenshot 2023-07-28 at 11 15 39 PM

Metadata

Metadata

Assignees

Labels

FeatureRequestIssues asking for a new feature that does not need a proposal.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions