internal/lsp: add LocalPrefix configuration

Updates golang/go#32049

Change-Id: I64e5201170b5be8b470c436264e18e12ec8d12f2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/204820
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
Rebecca Stambler 2019-11-01 16:19:19 -04:00
parent 6b7b8b79ae
commit 3c3d1ad199
2 changed files with 14 additions and 2 deletions

View File

@ -185,6 +185,7 @@ func (v *view) buildProcessEnv(ctx context.Context) (*imports.ProcessEnv, error)
Logf: func(format string, args ...interface{}) {
log.Print(ctx, fmt.Sprintf(format, args...))
},
LocalPrefix: v.options.LocalPrefix,
Debug: true,
}
for _, kv := range cfg.Env {

View File

@ -105,6 +105,9 @@ type Options struct {
ComputeEdits diff.ComputeEdits
Analyzers []*analysis.Analyzer
// LocalPrefix is used to specify goimports's -local behavior.
LocalPrefix string
}
type CompletionOptions struct {
@ -243,7 +246,7 @@ func (o *Options) set(name string, value interface{}) OptionResult {
case "hoverKind":
hoverKind, ok := value.(string)
if !ok {
result.errorf("Invalid type %T for string option %q", value, name)
result.errorf("invalid type %T for string option %q", value, name)
break
}
switch hoverKind {
@ -278,6 +281,14 @@ func (o *Options) set(name string, value interface{}) OptionResult {
case "go-diff":
result.setBool(&o.GoDiff)
case "local":
localPrefix, ok := value.(string)
if !ok {
result.errorf("invalid type %T for string option %q", value, name)
break
}
o.LocalPrefix = localPrefix
// Deprecated settings.
case "wantSuggestedFixes":
result.State = OptionDeprecated