From 3c3d1ad199b3f6d47d86987a0a547e7cc762f637 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Fri, 1 Nov 2019 16:19:19 -0400 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Ian Cottrell --- internal/lsp/cache/view.go | 3 ++- internal/lsp/source/options.go | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go index 118a21d95f..ae3c9a5e29 100644 --- a/internal/lsp/cache/view.go +++ b/internal/lsp/cache/view.go @@ -185,7 +185,8 @@ func (v *view) buildProcessEnv(ctx context.Context) (*imports.ProcessEnv, error) Logf: func(format string, args ...interface{}) { log.Print(ctx, fmt.Sprintf(format, args...)) }, - Debug: true, + LocalPrefix: v.options.LocalPrefix, + Debug: true, } for _, kv := range cfg.Env { split := strings.Split(kv, "=") diff --git a/internal/lsp/source/options.go b/internal/lsp/source/options.go index 8a0093037f..b69d9faf68 100644 --- a/internal/lsp/source/options.go +++ b/internal/lsp/source/options.go @@ -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