Skip to content

Commit 886decb

Browse files
committed
tools: generate inlay hints settings from gopls settings
This updates the script to generate the inlay hints settings automatically from gopls. I did some manual touch ups on the settings from gopls for now and will send a CL to gopls to make the settings fixes upstream. Change-Id: Ib4d66b1f03b4e6aa0019d6a9094cc172c8dc952a Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/419120 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Run-TryBot: Suzy Mueller <suzmue@golang.org>
1 parent 7467f26 commit 886decb

File tree

3 files changed

+136
-99
lines changed

3 files changed

+136
-99
lines changed

docs/settings.md

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -272,85 +272,68 @@ Infer GOPATH from the workspace root. This is ignored when using Go Modules.
272272
Default: `false`
273273
### `go.inlayHints.assignVariableTypes`
274274

275-
Enable/disable inlay hints for variable types in assign statements.
275+
Enable/disable inlay hints for variable types in assign statements:
276276
```go
277-
278-
i /*int*/, j /*int*/ := 0, len(r)-1
277+
i/* int*/, j/* int*/ := 0, len(r)-1
279278
```
280279

281280
Default: `false`
282281
### `go.inlayHints.compositeLiteralFields`
283282

284-
Enable/disable inlay hints for composite literal field names.
283+
Enable/disable inlay hints for composite literal field names:
285284
```go
286-
287-
for _, c := range []struct {in, want string}{
288-
{/*in:*/ "Hello, world", /*want:*/ "dlrow ,olleH"},
289-
{/*in:*/ "Hello, 世界", /*want:*/ "界世 ,olleH"},
290-
{/*in:*/ "", /*want:*/ ""},
291-
} {
292-
...
293-
}
285+
{/*in: */"Hello, world", /*want: */"dlrow ,olleH"}
294286
```
295287

296288
Default: `false`
297289
### `go.inlayHints.compositeLiteralTypes`
298290

299-
Enable/disable inlay hints for composite literal types.
291+
Enable/disable inlay hints for composite literal types:
300292
```go
301-
302-
for _, c := range []struct {in, want string}{
303-
/*struct{ in, want string }*/{"Hello, world", "dlrow ,olleH"},
304-
/*struct{ in, want string }*/{"Hello, 世界", "界世 ,olleH"},
305-
/*struct{ in, want string }*/{"", ""},
306-
} {
307-
...
308-
}
293+
for _, c := range []struct {
294+
in, want string
295+
}{
296+
/*struct{ in string; want string }*/{"Hello, world", "dlrow ,olleH"},
297+
}
309298
```
310299

311300
Default: `false`
312301
### `go.inlayHints.constantValues`
313302

314-
Enable/disable inlay hints for constant values.
303+
Enable/disable inlay hints for constant values:
315304
```go
316-
317-
const (
318-
KindNone = iota /*= 0*/
319-
KindPrint /*= 1*/
320-
KindPrintf /*= 2*/
321-
KindErrorf /*= 3*/
322-
)
305+
const (
306+
KindNone Kind = iota/* = 0*/
307+
KindPrint/* = 1*/
308+
KindPrintf/* = 2*/
309+
KindErrorf/* = 3*/
310+
)
323311
```
324312

325313
Default: `false`
326314
### `go.inlayHints.functionTypeParameters`
327315

328-
Enable/disable inlay hints for implicit type parameters on generic functions.
316+
Enable/disable inlay hints for implicit type parameters on generic functions:
329317
```go
330-
331-
func myFunc[T any](a T) { ... }
332-
333-
func main() {
334-
myFunc/*[int]*/(1)
335-
}
318+
myFoo/*[int, string]*/(1, "hello")
336319
```
337320

338321
Default: `false`
339322
### `go.inlayHints.parameterNames`
340323

341-
Enable/disable inlay hints for parameter names.
324+
Enable/disable inlay hints for parameter names:
342325
```go
343-
344-
http.HandleFunc(/*pattern:*/ "/", /*handler:*/ indexHandler)
326+
parseInt(/* str: */ "123", /* radix: */ 8)
345327
```
346328

347329
Default: `false`
348330
### `go.inlayHints.rangeVariableTypes`
349331

350-
Enable/disable inlay hints for variable types in range statements.
332+
Enable/disable inlay hints for variable types in range statements:
351333
```go
352-
353-
for k /*int*/, v /*string*/ := range []string{} { ... }
334+
for k/* int*/, v/* string*/ := range []string{} {
335+
fmt.Println(k, v)
336+
}
354337
```
355338

356339
Default: `false`
@@ -744,6 +727,7 @@ Example Usage:
744727
| `gc_details` | Toggle the calculation of gc annotations. <br/> Default: `false` |
745728
| `generate` | Runs `go generate` for a given directory. <br/> Default: `true` |
746729
| `regenerate_cgo` | Regenerates cgo definitions. <br/> Default: `true` |
730+
| `run_vulncheck_exp` | Run vulnerability check (`govulncheck`). <br/> Default: `false` |
747731
| `test` | Runs `go test` for a specific set of test or benchmark functions. <br/> Default: `false` |
748732
| `tidy` | Runs `go mod tidy` for a module. <br/> Default: `true` |
749733
| `upgrade_dependency` | Upgrades a dependency in the go.mod file for a module. <br/> Default: `true` |
@@ -837,12 +821,14 @@ Example Usage:
837821
| `stubmethods` | stub methods analyzer <br/> This analyzer generates method stubs for concrete types in order to implement a target interface <br/> Default: `true` |
838822
| `testinggoroutine` | report calls to (*testing.T).Fatal from goroutines started by a test. <br/> Functions that abruptly terminate a test, such as the Fatal, Fatalf, FailNow, and Skip{,f,Now} methods of *testing.T, must be called from the test goroutine itself. This checker detects calls to these functions that occur within a goroutine started by the test. For example: <br/> func TestFoo(t *testing.T) { go func() { t.Fatal("oops") // error: (*T).Fatal called from non-test goroutine }() } <br/> <br/> Default: `true` |
839823
| `tests` | check for common mistaken usages of tests and examples <br/> The tests checker walks Test, Benchmark and Example functions checking malformed names, wrong signatures and examples documenting non-existent identifiers. <br/> Please see the documentation for package testing in golang.org/pkg/testing for the conventions that are enforced for Tests, Benchmarks, and Examples. <br/> Default: `true` |
824+
| `timeformat` | check for calls of (time.Time).Format or time.Parse with 2006-02-01 <br/> The timeformat checker looks for time formats with the 2006-02-01 (yyyy-dd-mm) format. Internationally, "yyyy-dd-mm" does not occur in common calendar date standards, and so it is more likely that 2006-01-02 (yyyy-mm-dd) was intended. <br/> <br/> Default: `true` |
840825
| `undeclaredname` | suggested fixes for "undeclared name: <>" <br/> This checker provides suggested fixes for type errors of the type "undeclared name: <>". It will either insert a new statement, such as: <br/> "<> := " <br/> or a new function declaration, such as: <br/> func <>(inferred parameters) { <pre>panic("implement me!")</pre>} <br/> <br/> Default: `true` |
841826
| `unmarshal` | report passing non-pointer or non-interface values to unmarshal <br/> The unmarshal analysis reports calls to functions such as json.Unmarshal in which the argument type is not a pointer or an interface. <br/> Default: `true` |
842827
| `unreachable` | check for unreachable code <br/> The unreachable analyzer finds statements that execution can never reach because they are preceded by an return statement, a call to panic, an infinite loop, or similar constructs. <br/> Default: `true` |
843828
| `unsafeptr` | check for invalid conversions of uintptr to unsafe.Pointer <br/> The unsafeptr analyzer reports likely incorrect uses of unsafe.Pointer to convert integers to pointers. A conversion from uintptr to unsafe.Pointer is invalid if it implies that there is a uintptr-typed word in memory that holds a pointer value, because that word will be invisible to stack copying and to the garbage collector. <br/> Default: `true` |
844829
| `unusedparams` | check for unused parameters of functions <br/> The unusedparams analyzer checks functions to see if there are any parameters that are not being used. <br/> To reduce false positives it ignores: - methods - parameters that do not have a name or are underscored - functions in test files - functions with empty bodies or those with just a return stmt <br/> Default: `false` |
845830
| `unusedresult` | check for unused results of calls to some functions <br/> Some functions like fmt.Errorf return a result and have no side effects, so it is always a mistake to discard the result. This analyzer reports calls to certain functions in which the result of the call is ignored. <br/> The set of functions may be controlled using flags. <br/> Default: `true` |
831+
| `unusedvariable` | check for unused variables <br/> The unusedvariable analyzer suggests fixes for unused variables errors. <br/> <br/> Default: `false` |
846832
| `unusedwrite` | checks for unused writes <br/> The analyzer reports instances of writes to struct fields and arrays that are never read. Specifically, when a struct object or an array is copied, its elements are copied implicitly by the compiler, and any element write to this copy does nothing with the original object. <br/> For example: <br/> <pre>type T struct { x int }<br/>func f(input []T) {<br/> for i, v := range input { // v is a copy<br/> v.x = i // unused write to field x<br/> }<br/>}</pre><br/> Another example is about non-pointer receiver: <br/> <pre>type T struct { x int }<br/>func (t T) f() { // t is a copy<br/> t.x = i // unused write to field x<br/>}</pre><br/> <br/> Default: `false` |
847833
| `useany` | check for constraints that could be simplified to "any" <br/> Default: `false` |
848834
### `ui.diagnostic.annotations`
@@ -912,6 +898,9 @@ It might be one of:
912898

913899
If company chooses to use its own `godoc.org`, its address can be used as well.
914900

901+
Modules matching the GOPRIVATE environment variable will not have
902+
documentation links in hover.
903+
915904

916905
Default: `"pkg.go.dev"`
917906
### `ui.documentation.linksInHover`
@@ -962,6 +951,18 @@ just "Foo.Field".
962951

963952

964953
Default: `"Dynamic"`
954+
### `ui.noSemanticNumber`
955+
956+
(Experimental) noSemanticNumber turns off the sending of the semantic token 'number'
957+
958+
959+
Default: `false`
960+
### `ui.noSemanticString`
961+
962+
(Experimental) noSemanticString turns off the sending of the semantic token 'string'
963+
964+
965+
Default: `false`
965966
### `ui.semanticTokens`
966967

967968
(Experimental) semanticTokens controls whether the LSP server will send

package.json

Lines changed: 63 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,41 +2049,6 @@
20492049
"scope": "resource",
20502050
"type": "boolean"
20512051
},
2052-
"go.inlayHints.assignVariableTypes": {
2053-
"type": "boolean",
2054-
"markdownDescription": "Enable/disable inlay hints for variable types in assign statements.\n```go\n\ni /*int*/, j /*int*/ := 0, len(r)-1\n```",
2055-
"default": false
2056-
},
2057-
"go.inlayHints.compositeLiteralFields": {
2058-
"type": "boolean",
2059-
"markdownDescription": "Enable/disable inlay hints for composite literal field names.\n```go\n\nfor _, c := range []struct {in, want string}{\n\t{/*in:*/ \"Hello, world\", /*want:*/ \"dlrow ,olleH\"},\n\t{/*in:*/ \"Hello, 世界\", /*want:*/ \"界世 ,olleH\"},\n\t{/*in:*/ \"\", /*want:*/ \"\"},\n} {\n\t...\n}\n```",
2060-
"default": false
2061-
},
2062-
"go.inlayHints.compositeLiteralTypes": {
2063-
"type": "boolean",
2064-
"markdownDescription": "Enable/disable inlay hints for composite literal types.\n```go\n\nfor _, c := range []struct {in, want string}{\n\t/*struct{ in, want string }*/{\"Hello, world\", \"dlrow ,olleH\"},\n\t/*struct{ in, want string }*/{\"Hello, 世界\", \"界世 ,olleH\"},\n\t/*struct{ in, want string }*/{\"\", \"\"},\n} {\n\t...\n}\n```",
2065-
"default": false
2066-
},
2067-
"go.inlayHints.constantValues": {
2068-
"type": "boolean",
2069-
"markdownDescription": "Enable/disable inlay hints for constant values.\n```go\n\nconst (\n\tKindNone = iota\t/*= 0*/\n\tKindPrint\t/*= 1*/\n\tKindPrintf\t/*= 2*/\n\tKindErrorf\t/*= 3*/\n)\n```",
2070-
"default": false
2071-
},
2072-
"go.inlayHints.functionTypeParameters": {
2073-
"type": "boolean",
2074-
"markdownDescription": "Enable/disable inlay hints for implicit type parameters on generic functions.\n```go\n\nfunc myFunc[T any](a T) { ... }\n\nfunc main() {\n\tmyFunc/*[int]*/(1)\n}\n```",
2075-
"default": false
2076-
},
2077-
"go.inlayHints.parameterNames": {
2078-
"type": "boolean",
2079-
"markdownDescription": "Enable/disable inlay hints for parameter names.\n```go\n\nhttp.HandleFunc(/*pattern:*/ \"/\", /*handler:*/ indexHandler)\n```",
2080-
"default": false
2081-
},
2082-
"go.inlayHints.rangeVariableTypes": {
2083-
"type": "boolean",
2084-
"markdownDescription": "Enable/disable inlay hints for variable types in range statements.\n```go\n\nfor k /*int*/, v /*string*/ := range []string{} { ... }\n```",
2085-
"default": false
2086-
},
20872052
"gopls": {
20882053
"type": "object",
20892054
"markdownDescription": "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.",
@@ -2196,6 +2161,11 @@
21962161
"markdownDescription": "Regenerates cgo definitions.",
21972162
"default": true
21982163
},
2164+
"run_vulncheck_exp": {
2165+
"type": "boolean",
2166+
"markdownDescription": "Run vulnerability check (`govulncheck`).",
2167+
"default": false
2168+
},
21992169
"test": {
22002170
"type": "boolean",
22012171
"markdownDescription": "Runs `go test` for a specific set of test or benchmark functions.",
@@ -2442,6 +2412,11 @@
24422412
"markdownDescription": "check for common mistaken usages of tests and examples\n\nThe tests checker walks Test, Benchmark and Example functions checking\nmalformed names, wrong signatures and examples documenting non-existent\nidentifiers.\n\nPlease see the documentation for package testing in golang.org/pkg/testing\nfor the conventions that are enforced for Tests, Benchmarks, and Examples.",
24432413
"default": true
24442414
},
2415+
"timeformat": {
2416+
"type": "boolean",
2417+
"markdownDescription": "check for calls of (time.Time).Format or time.Parse with 2006-02-01\n\nThe timeformat checker looks for time formats with the 2006-02-01 (yyyy-dd-mm)\nformat. Internationally, \"yyyy-dd-mm\" does not occur in common calendar date\nstandards, and so it is more likely that 2006-01-02 (yyyy-mm-dd) was intended.\n",
2418+
"default": true
2419+
},
24452420
"undeclaredname": {
24462421
"type": "boolean",
24472422
"markdownDescription": "suggested fixes for \"undeclared name: <>\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"undeclared name: <>\". It will either insert a new statement,\nsuch as:\n\n\"<> := \"\n\nor a new function declaration, such as:\n\nfunc <>(inferred parameters) {\n\tpanic(\"implement me!\")\n}\n",
@@ -2472,6 +2447,11 @@
24722447
"markdownDescription": "check for unused results of calls to some functions\n\nSome functions like fmt.Errorf return a result and have no side effects,\nso it is always a mistake to discard the result. This analyzer reports\ncalls to certain functions in which the result of the call is ignored.\n\nThe set of functions may be controlled using flags.",
24732448
"default": true
24742449
},
2450+
"unusedvariable": {
2451+
"type": "boolean",
2452+
"markdownDescription": "check for unused variables\n\nThe unusedvariable analyzer suggests fixes for unused variables errors.\n",
2453+
"default": false
2454+
},
24752455
"unusedwrite": {
24762456
"type": "boolean",
24772457
"markdownDescription": "checks for unused writes\n\nThe analyzer reports instances of writes to struct fields and\narrays that are never read. Specifically, when a struct object\nor an array is copied, its elements are copied implicitly by\nthe compiler, and any element write to this copy does nothing\nwith the original object.\n\nFor example:\n\n\ttype T struct { x int }\n\tfunc f(input []T) {\n\t\tfor i, v := range input { // v is a copy\n\t\t\tv.x = i // unused write to field x\n\t\t}\n\t}\n\nAnother example is about non-pointer receiver:\n\n\ttype T struct { x int }\n\tfunc (t T) f() { // t is a copy\n\t\tt.x = i // unused write to field x\n\t}\n",
@@ -2551,7 +2531,7 @@
25512531
},
25522532
"ui.documentation.linkTarget": {
25532533
"type": "string",
2554-
"markdownDescription": "linkTarget controls where documentation links go.\nIt might be one of:\n\n* `\"godoc.org\"`\n* `\"pkg.go.dev\"`\n\nIf company chooses to use its own `godoc.org`, its address can be used as well.\n",
2534+
"markdownDescription": "linkTarget controls where documentation links go.\nIt might be one of:\n\n* `\"godoc.org\"`\n* `\"pkg.go.dev\"`\n\nIf company chooses to use its own `godoc.org`, its address can be used as well.\n\nModules matching the GOPRIVATE environment variable will not have\ndocumentation links in hover.\n",
25552535
"default": "pkg.go.dev",
25562536
"scope": "resource"
25572537
},
@@ -2611,6 +2591,18 @@
26112591
"default": "Dynamic",
26122592
"scope": "resource"
26132593
},
2594+
"ui.noSemanticNumber": {
2595+
"type": "boolean",
2596+
"markdownDescription": "(Experimental) noSemanticNumber turns off the sending of the semantic token 'number'\n",
2597+
"default": false,
2598+
"scope": "resource"
2599+
},
2600+
"ui.noSemanticString": {
2601+
"type": "boolean",
2602+
"markdownDescription": "(Experimental) noSemanticString turns off the sending of the semantic token 'string'\n",
2603+
"default": false,
2604+
"scope": "resource"
2605+
},
26142606
"ui.semanticTokens": {
26152607
"type": "boolean",
26162608
"markdownDescription": "(Experimental) semanticTokens controls whether the LSP server will send\nsemantic tokens to the client.\n",
@@ -2624,6 +2616,41 @@
26242616
"scope": "resource"
26252617
}
26262618
}
2619+
},
2620+
"go.inlayHints.assignVariableTypes": {
2621+
"type": "boolean",
2622+
"markdownDescription": "Enable/disable inlay hints for variable types in assign statements:\n```go\n\ti/* int*/, j/* int*/ := 0, len(r)-1\n```",
2623+
"default": false
2624+
},
2625+
"go.inlayHints.compositeLiteralFields": {
2626+
"type": "boolean",
2627+
"markdownDescription": "Enable/disable inlay hints for composite literal field names:\n```go\n\t{/*in: */\"Hello, world\", /*want: */\"dlrow ,olleH\"}\n```",
2628+
"default": false
2629+
},
2630+
"go.inlayHints.compositeLiteralTypes": {
2631+
"type": "boolean",
2632+
"markdownDescription": "Enable/disable inlay hints for composite literal types:\n```go\n\tfor _, c := range []struct {\n\t\tin, want string\n\t}{\n\t\t/*struct{ in string; want string }*/{\"Hello, world\", \"dlrow ,olleH\"},\n\t}\n```",
2633+
"default": false
2634+
},
2635+
"go.inlayHints.constantValues": {
2636+
"type": "boolean",
2637+
"markdownDescription": "Enable/disable inlay hints for constant values:\n```go\n\tconst (\n\t\tKindNone Kind = iota/* = 0*/\n\t\tKindPrint/* = 1*/\n\t\tKindPrintf/* = 2*/\n\t\tKindErrorf/* = 3*/\n\t)\n```",
2638+
"default": false
2639+
},
2640+
"go.inlayHints.functionTypeParameters": {
2641+
"type": "boolean",
2642+
"markdownDescription": "Enable/disable inlay hints for implicit type parameters on generic functions:\n```go\n\tmyFoo/*[int, string]*/(1, \"hello\")\n```",
2643+
"default": false
2644+
},
2645+
"go.inlayHints.parameterNames": {
2646+
"type": "boolean",
2647+
"markdownDescription": "Enable/disable inlay hints for parameter names:\n```go\n\tparseInt(/* str: */ \"123\", /* radix: */ 8)\n```",
2648+
"default": false
2649+
},
2650+
"go.inlayHints.rangeVariableTypes": {
2651+
"type": "boolean",
2652+
"markdownDescription": "Enable/disable inlay hints for variable types in range statements:\n```go\n\tfor k/* int*/, v/* string*/ := range []string{} {\n\t\tfmt.Println(k, v)\n\t}\n```",
2653+
"default": false
26272654
}
26282655
}
26292656
},

0 commit comments

Comments
 (0)