gopls/internal/lsp/source: add the "symbolScope" option
Add a new "symbolScope" option that controls whether matches are
restricted to workspace packages only. This is the new default behavior,
though the old behavior can be enabled by setting "symbolScope": "all".
Fixes golang/go#37236
Change-Id: Ic614b57005488e61ea0c018a68076785e667db16
Reviewed-on: https://go-review.googlesource.com/c/tools/+/490935
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
diff --git a/gopls/internal/lsp/source/api_json.go b/gopls/internal/lsp/source/api_json.go
index b564be1..2eb26d2 100644
--- a/gopls/internal/lsp/source/api_json.go
+++ b/gopls/internal/lsp/source/api_json.go
@@ -195,6 +195,23 @@
Hierarchy: "ui.navigation",
},
{
+ Name: "symbolScope",
+ Type: "enum",
+ Doc: "symbolScope controls which packages are searched for workspace/symbol\nrequests. The default value, \"workspace\", searches only workspace\npackages. The legacy behavior, \"all\", causes all loaded packages to be\nsearched, including dependencies; this is more expensive and may return\nunwanted results.\n",
+ EnumValues: []EnumValue{
+ {
+ Value: "\"all\"",
+ Doc: "`\"all\"` matches symbols in any loaded package, including\ndependencies.\n",
+ },
+ {
+ Value: "\"workspace\"",
+ Doc: "`\"workspace\"` matches symbols in workspace packages only.\n",
+ },
+ },
+ Default: "\"workspace\"",
+ Hierarchy: "ui.navigation",
+ },
+ {
Name: "analyses",
Type: "map[string]bool",
Doc: "analyses specify analyses that the user would like to enable or disable.\nA map of the names of analysis passes that should be enabled/disabled.\nA full list of analyzers that gopls uses can be found in\n[analyzers.md](https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md).\n\nExample Usage:\n\n```json5\n...\n\"analyses\": {\n \"unreachable\": false, // Disable the unreachable analyzer.\n \"unusedparams\": true // Enable the unusedparams analyzer.\n}\n...\n```\n",