mirror of https://github.com/golang/go.git
internal/lsp: link to the new pkg.go.dev instead of godoc.org
Updates golang/go#35563 Change-Id: I88ae3f742daf5043d4784fe8827454fb1ce1f9db Reviewed-on: https://go-review.googlesource.com/c/tools/+/209337 Reviewed-by: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
ecd32218bd
commit
6e064ea0cf
|
|
@ -46,6 +46,16 @@ If true, then completion responses may contain placeholders for function paramet
|
|||
|
||||
Default: `false`.
|
||||
|
||||
### **linkTarget** *string*
|
||||
|
||||
This controls where points documentation for given package in `textDocument/documentLink`.
|
||||
It might be one of:
|
||||
* `"godoc.org"`
|
||||
* `"pkg.go.dev"`
|
||||
If company chooses to use its own `godoc.org`, it's address can be used as well.
|
||||
|
||||
Default: `"pkg.go.dev"`.
|
||||
|
||||
## Experimental
|
||||
|
||||
The below settings are considered experimental. They may be deprecated or changed in the future. They are typically used to test experimental opt-in features or to disable features.
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package lsp
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/token"
|
||||
"regexp"
|
||||
|
|
@ -47,7 +48,7 @@ func (s *Server) documentLink(ctx context.Context, params *protocol.DocumentLink
|
|||
if target == "" {
|
||||
return false
|
||||
}
|
||||
target = "https://godoc.org/" + target
|
||||
target = fmt.Sprintf("https://%s/%s", view.Options().LinkTarget, target)
|
||||
l, err := toProtocolLink(view, m, target, n.Path.Pos()+1, n.Path.End()-1)
|
||||
if err != nil {
|
||||
log.Error(ctx, "cannot initialize DocumentLink", err, tag.Of("Path", n.Path.Value))
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ var (
|
|||
ComputeEdits: myers.ComputeEdits,
|
||||
Analyzers: defaultAnalyzers,
|
||||
GoDiff: true,
|
||||
LinkTarget: "pkg.go.dev",
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -110,6 +111,8 @@ type Options struct {
|
|||
LocalPrefix string
|
||||
|
||||
VerboseOutput bool
|
||||
|
||||
LinkTarget string
|
||||
}
|
||||
|
||||
type CompletionOptions struct {
|
||||
|
|
@ -164,6 +167,8 @@ const (
|
|||
OptionUnexpected
|
||||
)
|
||||
|
||||
type LinkTarget string
|
||||
|
||||
func SetOptions(options *Options, opts interface{}) OptionResults {
|
||||
var results OptionResults
|
||||
switch opts := opts.(type) {
|
||||
|
|
@ -265,6 +270,14 @@ func (o *Options) set(name string, value interface{}) OptionResult {
|
|||
result.errorf("Unsupported hover kind", tag.Of("HoverKind", hoverKind))
|
||||
}
|
||||
|
||||
case "linkTarget":
|
||||
linkTarget, ok := value.(string)
|
||||
if !ok {
|
||||
result.errorf("invalid type %T for string option %q", value, name)
|
||||
break
|
||||
}
|
||||
o.LinkTarget = linkTarget
|
||||
|
||||
case "experimentalDisabledAnalyses":
|
||||
disabledAnalyses, ok := value.([]interface{})
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
package links
|
||||
|
||||
import (
|
||||
"fmt" //@link(`fmt`,"https://godoc.org/fmt")
|
||||
"fmt" //@link(`fmt`,"https://pkg.go.dev/fmt")
|
||||
|
||||
"golang.org/x/tools/internal/lsp/foo" //@link(`golang.org/x/tools/internal/lsp/foo`,`https://godoc.org/golang.org/x/tools/internal/lsp/foo`)
|
||||
"golang.org/x/tools/internal/lsp/foo" //@link(`golang.org/x/tools/internal/lsp/foo`,`https://pkg.go.dev/golang.org/x/tools/internal/lsp/foo`)
|
||||
|
||||
_ "database/sql" //@link(`database/sql`, `https://godoc.org/database/sql`)
|
||||
_ "database/sql" //@link(`database/sql`, `https://pkg.go.dev/database/sql`)
|
||||
|
||||
errors "golang.org/x/xerrors" //@link(`golang.org/x/xerrors`, `https://godoc.org/golang.org/x/xerrors`)
|
||||
errors "golang.org/x/xerrors" //@link(`golang.org/x/xerrors`, `https://pkg.go.dev/golang.org/x/xerrors`)
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
|||
Loading…
Reference in New Issue