3 <!--TODO: Generate this file from the documentation in golang/org/x/tools/internal/lsp/source/options.go.-->
5 This document describes the global settings for `gopls` inside the editor. The settings block will be called `"gopls"` and contains a collection of controls for `gopls` that the editor is not expected to understand or control. These settings can also be configured differently per workspace folder.
7 In VSCode, this would be a section in your `settings.json` file that might look like this:
11 "usePlaceholders": true,
12 "completeUnimported": true
16 ## Officially supported
18 Below is the list of settings that are officially supported for `gopls`.
20 To enable all experimental features, use **allExperiments: `true`**. You will
21 still be able to independently override specific experimental features.
23 <!-- BEGIN User: DO NOT MANUALLY EDIT THIS SECTION -->
24 ### **buildFlags** *[]string*
25 buildFlags is the set of flags passed on to the build system when invoked.
26 It is applied to queries like `go list`, which is used when discovering files.
27 The most common use is to set `-tags`.
31 ### **env** *map[string]string*
32 env adds environment variables to external commands run by `gopls`, most notably `go list`.
36 ### **hoverKind** *enum*
37 hoverKind controls the information that appears in the hover text.
38 SingleLine and Structured are intended for use only by authors of editor plugins.
41 * `"FullDocumentation"`
44 * `"Structured"` is an experimental setting that returns a structured hover format.
45 This format separates the signature from the documentation, so that the client
46 can do more manipulation of these fields.\
47 This should only be used by clients that support this behavior.
49 * `"SynopsisDocumentation"`
52 Default: `"FullDocumentation"`.
53 ### **usePlaceholders** *bool*
54 placeholders enables placeholders for function parameters or struct fields in completion responses.
58 ### **linkTarget** *string*
59 linkTarget controls where documentation links go.
65 If company chooses to use its own `godoc.org`, its address can be used as well.
68 Default: `"pkg.go.dev"`.
69 ### **local** *string*
70 local is the equivalent of the `goimports -local` flag, which puts imports beginning with this string after 3rd-party packages.
71 It should be the prefix of the import path whose imports should be grouped separately.
75 ### **gofumpt** *bool*
76 gofumpt indicates if we should run gofumpt formatting.
80 <!-- END User: DO NOT MANUALLY EDIT THIS SECTION -->
84 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.
86 <!-- BEGIN Experimental: DO NOT MANUALLY EDIT THIS SECTION -->
87 ### **analyses** *map[string]bool*
88 analyses specify analyses that the user would like to enable or disable.
89 A map of the names of analysis passes that should be enabled/disabled.
90 A full list of analyzers that gopls uses can be found [here](analyzers.md)
96 "unreachable": false, // Disable the unreachable analyzer.
97 "unusedparams": true // Enable the unusedparams analyzer.
104 ### **codelens** *map[string]bool*
105 codelens overrides the enabled/disabled state of code lenses. See the "Code Lenses"
106 section of settings.md for the list of supported lenses.
113 "generate": false, // Don't show the `go generate` lens.
114 "gc_details": true // Show a code lens toggling the display of gc's choices.
121 Default: `{"gc_details":false,"generate":true,"regenerate_cgo":true,"tidy":true,"upgrade_dependency":true,"vendor":true}`.
122 ### **completionDocumentation** *bool*
123 completionDocumentation enables documentation with completion results.
127 ### **completeUnimported** *bool*
128 completeUnimported enables completion for packages that you do not currently import.
132 ### **deepCompletion** *bool*
133 deepCompletion enables the ability to return completions from deep inside relevant entities, rather than just the locally accessible ones.
135 Consider this example:
142 type wrapString struct {
147 x := wrapString{"hello world"}
152 At the location of the `<>` in this program, deep completion would suggest the result `x.str`.
156 ### **matcher** *enum*
157 matcher sets the algorithm that is used when calculating completion candidates.
160 * `"CaseInsensitive"`
166 ### **annotations** *map[string]bool*
167 annotations suppress various kinds of optimization diagnostics
168 that would be reported by the gc_details command.
169 * noNilcheck suppresses display of nilchecks.
170 * noEscape suppresses escape choices.
171 * noInline suppresses inlining choices.
172 * noBounds suppresses bounds checking diagnostics.
176 ### **staticcheck** *bool*
177 staticcheck enables additional analyses from staticcheck.io.
181 ### **symbolMatcher** *enum*
182 symbolMatcher sets the algorithm that is used when finding workspace symbols.
185 * `"CaseInsensitive"`
191 ### **symbolStyle** *enum*
192 symbolStyle controls how symbols are qualified in symbol responses.
198 "symbolStyle": "dynamic",
204 * `"Dynamic"` uses whichever qualifier results in the highest scoring
205 match for the given symbol query. Here a "qualifier" is any "/" or "."
206 delimited suffix of the fully qualified symbol. i.e. "to/pkg.Foo.Field" or
209 * `"Full"` is fully qualified symbols, i.e.
210 "path/to/pkg.Foo.Field".
212 * `"Package"` is package qualified symbols i.e.
217 Default: `"Package"`.
218 ### **linksInHover** *bool*
219 linksInHover toggles the presence of links to documentation in hover.
223 ### **tempModfile** *bool*
224 tempModfile controls the use of the -modfile flag in Go 1.14.
228 ### **importShortcut** *enum*
229 importShortcut specifies whether import statements should link to
230 documentation or go to definitions.
239 ### **verboseWorkDoneProgress** *bool*
240 verboseWorkDoneProgress controls whether the LSP server should send
241 progress reports for all work done outside the scope of an RPC.
245 ### **semanticTokens** *bool*
246 semanticTokens controls whether the LSP server will send
247 semantic tokens to the client.
251 ### **expandWorkspaceToModule** *bool*
252 expandWorkspaceToModule instructs `gopls` to expand the scope of the workspace to include the
253 modules containing the workspace folders. Set this to false to avoid loading
254 your entire module. This is particularly useful for those working in a monorepo.
258 ### **experimentalWorkspaceModule** *bool*
259 experimentalWorkspaceModule opts a user into the experimental support
260 for multi-module workspaces.
264 ### **experimentalDiagnosticsDelay** *time.Duration*
265 experimentalDiagnosticsDelay controls the amount of time that gopls waits
266 after the most recent file modification before computing deep diagnostics.
267 Simple diagnostics (parsing and type-checking) are always run immediately
268 on recently modified packages.
270 This option must be set to a valid duration string, for example `"250ms"`.
274 ### **experimentalPackageCacheKey** *bool*
275 experimentalPackageCacheKey controls whether to use a coarser cache key
276 for package type information to increase cache hits. This setting removes
277 the user's environment, build flags, and working directory from the cache
278 key, which should be a safe change as all relevant inputs into the type
279 checking pass are already hashed into the key. This is temporarily guarded
280 by an experiment because caching behavior is subtle and difficult to
281 comprehensively test.
285 <!-- END Experimental: DO NOT MANUALLY EDIT THIS SECTION -->
289 The below settings are for use in debugging `gopls`. Like the experimental options, they may be deprecated or changed in the future.
291 <!-- BEGIN Debugging: DO NOT MANUALLY EDIT THIS SECTION -->
292 ### **verboseOutput** *bool*
293 verboseOutput enables additional debug logging.
297 ### **completionBudget** *time.Duration*
298 completionBudget is the soft latency goal for completion requests. Most
299 requests finish in a couple milliseconds, but in some cases deep
300 completions can take much longer. As we use up our budget we
301 dynamically reduce the search scope to ensure we return timely
302 results. Zero means unlimited.
306 <!-- END Debugging: DO NOT MANUALLY EDIT THIS SECTION -->
310 These are the code lenses that `gopls` currently supports. They can be enabled and disabled using the `codeLenses` setting, documented above. The names and features are subject to change.
312 <!-- BEGIN Lenses: DO NOT MANUALLY EDIT THIS SECTION -->
313 ### **Run go generate**
314 Identifier: `generate`
316 generate runs `go generate` for a given directory.
319 ### **Regenerate cgo**
320 Identifier: `regenerate_cgo`
322 regenerate_cgo regenerates cgo definitions.
328 test runs `go test` for a specific test function.
331 ### **Run go mod tidy**
334 tidy runs `go mod tidy` for a module.
337 ### **Upgrade dependency**
338 Identifier: `upgrade_dependency`
340 upgrade_dependency upgrades a dependency.
343 ### **Run go mod vendor**
346 vendor runs `go mod vendor` for a module.
349 ### **Toggle gc_details**
350 Identifier: `gc_details`
352 gc_details controls calculation of gc annotations.
355 <!-- END Lenses: DO NOT MANUALLY EDIT THIS SECTION -->