diff --git a/internal/lsp/source/hover.go b/internal/lsp/source/hover.go index 2423010935cf1..a3ddc89ef37c2 100644 --- a/internal/lsp/source/hover.go +++ b/internal/lsp/source/hover.go @@ -390,7 +390,7 @@ func FormatHover(h *HoverInformation, options Options) (string, error) { } func formatLink(h *HoverInformation, options Options) string { - if options.LinkTarget == "" || h.Link == "" { + if !options.LinksInHover || options.LinkTarget == "" || h.Link == "" { return "" } plainLink := fmt.Sprintf("https://%s/%s", options.LinkTarget, h.Link) @@ -403,6 +403,7 @@ func formatLink(h *HoverInformation, options Options) string { return plainLink } } + func formatDoc(doc string, options Options) string { if options.PreferredContentFormat == protocol.Markdown { return CommentToMarkdown(doc) diff --git a/internal/lsp/source/options.go b/internal/lsp/source/options.go index 5d378cf3874fd..c59d4d3c655c6 100644 --- a/internal/lsp/source/options.go +++ b/internal/lsp/source/options.go @@ -115,6 +115,7 @@ func DefaultOptions() Options { Env: os.Environ(), HoverKind: FullDocumentation, LinkTarget: "pkg.go.dev", + LinksInHover: true, Matcher: Fuzzy, SymbolMatcher: SymbolFuzzy, DeepCompletion: true, @@ -210,6 +211,9 @@ type UserOptions struct { // provided. LinkTarget string + // LinksInHover toggles the presence of links to documentation in hover. + LinksInHover bool + // ImportShortcut specifies whether import statements should link to // documentation or go to definitions. The default is both. ImportShortcut ImportShortcut @@ -526,6 +530,9 @@ func (o *Options) set(name string, value interface{}) OptionResult { case "linkTarget": result.setString(&o.LinkTarget) + case "linksInHover": + result.setBool(&o.LinksInHover) + case "importShortcut": var s string result.setString(&s)