diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go index ae3c9a5e29..1488a368bb 100644 --- a/internal/lsp/cache/view.go +++ b/internal/lsp/cache/view.go @@ -128,7 +128,9 @@ func (v *view) Config(ctx context.Context) *packages.Config { panic("go/packages must not be used to parse files") }, Logf: func(format string, args ...interface{}) { - log.Print(ctx, fmt.Sprintf(format, args...)) + if v.options.VerboseOutput { + log.Print(ctx, fmt.Sprintf(format, args...)) + } }, Tests: true, } @@ -186,7 +188,7 @@ func (v *view) buildProcessEnv(ctx context.Context) (*imports.ProcessEnv, error) log.Print(ctx, fmt.Sprintf(format, args...)) }, LocalPrefix: v.options.LocalPrefix, - Debug: true, + Debug: v.options.VerboseOutput, } for _, kv := range cfg.Env { split := strings.Split(kv, "=") diff --git a/internal/lsp/source/options.go b/internal/lsp/source/options.go index b69d9faf68..c45d034b79 100644 --- a/internal/lsp/source/options.go +++ b/internal/lsp/source/options.go @@ -108,6 +108,8 @@ type Options struct { // LocalPrefix is used to specify goimports's -local behavior. LocalPrefix string + + VerboseOutput bool } type CompletionOptions struct { @@ -289,6 +291,9 @@ func (o *Options) set(name string, value interface{}) OptionResult { } o.LocalPrefix = localPrefix + case "verboseOutput": + result.setBool(&o.VerboseOutput) + // Deprecated settings. case "wantSuggestedFixes": result.State = OptionDeprecated