Skip to content

Commit bd63db5

Browse files
committed
[release] tools/goplssetting: handle changes in gopls setting structure
This CL handles the various changes in my current stack of gopls CLs and it shouldn't be merged until CL 280355 is merged. It handles the new gopls settings hierarchies, maps keyed by enums, and changes to default values. I was struggling to work with the method writing out the lines directly, so I switched to a JSON struct. This works fine in most cases, except when writing out the default values. I think gopls should probably produce interface{} for default values, but that will need to be dealt with later. For now, I added a relatively basic work-around. Change-Id: Ie4b69074f1bf02023fa39488ebc1c5c9660a03fc Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/279728 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: kokoro <[email protected]> Trust: Rebecca Stambler <[email protected]> Trust: Hyang-Ah Hana Kim <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]> (cherry picked from commit de64eaa) Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/282372 Run-TryBot: Hyang-Ah Hana Kim <[email protected]>
1 parent d9eab14 commit bd63db5

File tree

7 files changed

+718
-334
lines changed

7 files changed

+718
-334
lines changed

docs/settings.md

Lines changed: 105 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Default: `false`
7979

8080
### `go.buildFlags`
8181

82-
Flags to `go build`/`go test` used during build-on-save or running tests. (e.g. ["-ldflags='-s'"]) This is propagated to the language server if `gopls.buildFlags` is not specified.
82+
Flags to `go build`/`go test` used during build-on-save or running tests. (e.g. ["-ldflags='-s'"]) This is propagated to the language server if `gopls.build.buildFlags` is not specified.
8383

8484
### `go.buildOnSave`
8585

@@ -91,7 +91,7 @@ Default: `package`
9191

9292
### `go.buildTags`
9393

94-
The Go build tags to use for all commands, that support a `-tags '...'` argument. When running tests, go.testTags will be used instead if it was set. This is propagated to the language server if `gopls.buildFlags` is not specified.
94+
The Go build tags to use for all commands, that support a `-tags '...'` argument. When running tests, go.testTags will be used instead if it was set. This is propagated to the language server if `gopls.build.buildFlags` is not specified.
9595

9696
Default: ``
9797

@@ -576,76 +576,26 @@ Default: `package`
576576

577577
Configure the default Go language server ('gopls'). In most cases, configuring this section is unnecessary. See [the documentation](https://github.com/golang/tools/blob/master/gopls/doc/settings.md) for all available settings.
578578

579-
#### `allowImplicitNetworkAccess`
579+
#### `build.allowImplicitNetworkAccess`
580580
(Experimental) allowImplicitNetworkAccess disables GOPROXY=off, allowing implicit module
581581
downloads rather than requiring user action. This option will eventually
582582
be removed.
583583

584584

585-
#### `allowModfileModifications`
585+
#### `build.allowModfileModifications`
586586
(Experimental) allowModfileModifications disables -mod=readonly, allowing imports from
587587
out-of-scope modules. This option will eventually be removed.
588588

589589

590-
#### `analyses`
591-
analyses specify analyses that the user would like to enable or disable.
592-
A map of the names of analysis passes that should be enabled/disabled.
593-
A full list of analyzers that gopls uses can be found [here](analyzers.md)
594-
595-
Example Usage:
596-
```json5
597-
...
598-
"analyses": {
599-
"unreachable": false, // Disable the unreachable analyzer.
600-
"unusedparams": true // Enable the unusedparams analyzer.
601-
}
602-
...
603-
```
604-
605-
606-
#### `annotations`
607-
(Experimental) annotations suppress various kinds of optimization diagnostics
608-
that would be reported by the gc_details command.
609-
* noNilcheck suppresses display of nilchecks.
610-
* noEscape suppresses escape choices.
611-
* noInline suppresses inlining choices.
612-
* noBounds suppresses bounds checking diagnostics.
613-
614-
615-
#### `buildFlags`
590+
#### `build.buildFlags`
616591
buildFlags is the set of flags passed on to the build system when invoked.
617592
It is applied to queries like `go list`, which is used when discovering files.
618593
The most common use is to set `-tags`.
619594

620595
If unspecified, values of `go.buildFlags, go.buildTags` will be propagated.
621596

622597

623-
#### `codelenses`
624-
codelenses overrides the enabled/disabled state of code lenses. See the "Code Lenses"
625-
section of settings.md for the list of supported lenses.
626-
627-
Example Usage:
628-
```json5
629-
"gopls": {
630-
...
631-
"codelens": {
632-
"generate": false, // Don't show the `go generate` lens.
633-
"gc_details": true // Show a code lens toggling the display of gc's choices.
634-
}
635-
...
636-
}
637-
```
638-
639-
640-
#### `completionBudget`
641-
(For Debugging) completionBudget is the soft latency goal for completion requests. Most
642-
requests finish in a couple milliseconds, but in some cases deep
643-
completions can take much longer. As we use up our budget we
644-
dynamically reduce the search scope to ensure we return timely
645-
results. Zero means unlimited.
646-
647-
648-
#### `directoryFilters`
598+
#### `build.directoryFilters`
649599
directoryFilters can be used to exclude unwanted directories from the
650600
workspace. By default, all directories are included. Filters are an
651601
operator, `+` to include and `-` to exclude, followed by a path prefix
@@ -659,11 +609,11 @@ Include only project_a: `-` (exclude everything), `+project_a`
659609
Include only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`
660610

661611

662-
#### `env`
612+
#### `build.env`
663613
env adds environment variables to external commands run by `gopls`, most notably `go list`.
664614

665615

666-
#### `expandWorkspaceToModule`
616+
#### `build.expandWorkspaceToModule`
667617
(Experimental) expandWorkspaceToModule instructs `gopls` to adjust the scope of the
668618
workspace to find the best available module root. `gopls` first looks for
669619
a go.mod file in any parent directory of the workspace folder, expanding
@@ -672,16 +622,7 @@ found, gopls will check if there is exactly one child directory containing
672622
a go.mod file, narrowing the scope to that directory if it exists.
673623

674624

675-
#### `experimentalDiagnosticsDelay`
676-
(Experimental) experimentalDiagnosticsDelay controls the amount of time that gopls waits
677-
after the most recent file modification before computing deep diagnostics.
678-
Simple diagnostics (parsing and type-checking) are always run immediately
679-
on recently modified packages.
680-
681-
This option must be set to a valid duration string, for example `"250ms"`.
682-
683-
684-
#### `experimentalPackageCacheKey`
625+
#### `build.experimentalPackageCacheKey`
685626
(Experimental) experimentalPackageCacheKey controls whether to use a coarser cache key
686627
for package type information to increase cache hits. This setting removes
687628
the user's environment, build flags, and working directory from the cache
@@ -691,65 +632,129 @@ by an experiment because caching behavior is subtle and difficult to
691632
comprehensively test.
692633

693634

694-
#### `experimentalWorkspaceModule`
635+
#### `build.experimentalWorkspaceModule`
695636
(Experimental) experimentalWorkspaceModule opts a user into the experimental support
696637
for multi-module workspaces.
697638

698639

699-
#### `gofumpt`
640+
#### `formatting.gofumpt`
700641
gofumpt indicates if we should run gofumpt formatting.
701642

702643

703-
#### `hoverKind`
704-
hoverKind controls the information that appears in the hover text.
705-
SingleLine and Structured are intended for use only by authors of editor plugins.
644+
#### `formatting.local`
645+
local is the equivalent of the `goimports -local` flag, which puts
646+
imports beginning with this string after third-party packages. It should
647+
be the prefix of the import path whose imports should be grouped
648+
separately.
706649

707650

708-
#### `importShortcut`
709-
importShortcut specifies whether import statements should link to
710-
documentation or go to definitions.
651+
#### `ui.codelenses`
652+
codelenses overrides the enabled/disabled state of code lenses. See the
653+
"Code Lenses" section of the
654+
[Settings page](https://github.com/golang/tools/blob/master/gopls/doc/settings.md)
655+
for the list of supported lenses.
711656

657+
Example Usage:
712658

713-
#### `linkTarget`
714-
linkTarget controls where documentation links go.
715-
It might be one of:
659+
```json5
660+
"gopls": {
661+
...
662+
"codelens": {
663+
"generate": false, // Don't show the `go generate` lens.
664+
"gc_details": true // Show a code lens toggling the display of gc's choices.
665+
}
666+
...
667+
}
668+
```
716669

717-
* `"godoc.org"`
718-
* `"pkg.go.dev"`
719670

720-
If company chooses to use its own `godoc.org`, its address can be used as well.
671+
#### `ui.completion.completionBudget`
672+
(For Debugging) completionBudget is the soft latency goal for completion requests. Most
673+
requests finish in a couple milliseconds, but in some cases deep
674+
completions can take much longer. As we use up our budget we
675+
dynamically reduce the search scope to ensure we return timely
676+
results. Zero means unlimited.
721677

722678

723-
#### `linksInHover`
724-
linksInHover toggles the presence of links to documentation in hover.
679+
#### `ui.completion.matcher`
680+
(Advanced) matcher sets the algorithm that is used when calculating completion
681+
candidates.
725682

726683

727-
#### `local`
728-
local is the equivalent of the `goimports -local` flag, which puts imports beginning with this string after 3rd-party packages.
729-
It should be the prefix of the import path whose imports should be grouped separately.
684+
#### `ui.completion.usePlaceholders`
685+
placeholders enables placeholders for function parameters or struct
686+
fields in completion responses.
730687

731688

732-
#### `matcher`
733-
matcher sets the algorithm that is used when calculating completion candidates.
689+
#### `ui.diagnostic.analyses`
690+
analyses specify analyses that the user would like to enable or disable.
691+
A map of the names of analysis passes that should be enabled/disabled.
692+
A full list of analyzers that gopls uses can be found
693+
[here](https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md).
734694

695+
Example Usage:
735696

736-
#### `semanticTokens`
737-
(Experimental) semanticTokens controls whether the LSP server will send
738-
semantic tokens to the client.
697+
```json5
698+
...
699+
"analyses": {
700+
"unreachable": false, // Disable the unreachable analyzer.
701+
"unusedparams": true // Enable the unusedparams analyzer.
702+
}
703+
...
704+
```
705+
706+
707+
#### `ui.diagnostic.annotations`
708+
(Experimental) annotations specifies the various kinds of optimization diagnostics
709+
that should be reported by the gc_details command.
710+
711+
712+
#### `ui.diagnostic.experimentalDiagnosticsDelay`
713+
(Experimental) experimentalDiagnosticsDelay controls the amount of time that gopls waits
714+
after the most recent file modification before computing deep diagnostics.
715+
Simple diagnostics (parsing and type-checking) are always run immediately
716+
on recently modified packages.
717+
718+
This option must be set to a valid duration string, for example `"250ms"`.
739719

740720

741-
#### `staticcheck`
721+
#### `ui.diagnostic.staticcheck`
742722
(Experimental) staticcheck enables additional analyses from staticcheck.io.
743723

744724

745-
#### `symbolMatcher`
746-
symbolMatcher sets the algorithm that is used when finding workspace symbols.
725+
#### `ui.documentation.hoverKind`
726+
hoverKind controls the information that appears in the hover text.
727+
SingleLine and Structured are intended for use only by authors of editor plugins.
747728

748729

749-
#### `symbolStyle`
750-
symbolStyle controls how symbols are qualified in symbol responses.
730+
#### `ui.documentation.linkTarget`
731+
linkTarget controls where documentation links go.
732+
It might be one of:
733+
734+
* `"godoc.org"`
735+
* `"pkg.go.dev"`
736+
737+
If company chooses to use its own `godoc.org`, its address can be used as well.
738+
739+
740+
#### `ui.documentation.linksInHover`
741+
linksInHover toggles the presence of links to documentation in hover.
742+
743+
744+
#### `ui.navigation.importShortcut`
745+
importShortcut specifies whether import statements should link to
746+
documentation or go to definitions.
747+
748+
749+
#### `ui.navigation.symbolMatcher`
750+
(Advanced) symbolMatcher sets the algorithm that is used when finding workspace symbols.
751+
752+
753+
#### `ui.navigation.symbolStyle`
754+
(Advanced) symbolStyle controls how symbols are qualified in symbol responses.
751755

752756
Example Usage:
757+
753758
```json5
754759
"gopls": {
755760
...
@@ -759,8 +764,9 @@ Example Usage:
759764
```
760765

761766

762-
#### `usePlaceholders`
763-
placeholders enables placeholders for function parameters or struct fields in completion responses.
767+
#### `ui.semanticTokens`
768+
(Experimental) semanticTokens controls whether the LSP server will send
769+
semantic tokens to the client.
764770

765771

766772
#### `verboseOutput`

0 commit comments

Comments
 (0)