mirror of https://github.com/golang/go.git
internal/lsp: update inlay hints documentation to include go snippets
Update the markdown documentation for inlay hints and fix a couple of typos in the examples. Change-Id: I114502a81999bc5e4f25384ab619888f3e31a731 Reviewed-on: https://go-review.googlesource.com/c/tools/+/419496 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> gopls-CI: kokoro <noreply+kokoro@google.com> Run-TryBot: Suzy Mueller <suzmue@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
8b47d4e187
commit
c83f42da70
|
|
@ -6,67 +6,74 @@ This document describes the inlay hints that `gopls` uses inside the editor.
|
|||
## **assignVariableTypes**
|
||||
|
||||
Enable/disable inlay hints for variable types in assign statements:
|
||||
|
||||
i/* int/*, j/* int/* := 0, len(r)-1
|
||||
```go
|
||||
i/* int*/, j/* int*/ := 0, len(r)-1
|
||||
```
|
||||
|
||||
**Disabled by default. Enable it by setting `"hints": {"assignVariableTypes": true}`.**
|
||||
|
||||
## **compositeLiteralFields**
|
||||
|
||||
Enable/disable inlay hints for composite literal field names:
|
||||
|
||||
{in: "Hello, world", want: "dlrow ,olleH"}
|
||||
```go
|
||||
{/*in: */"Hello, world", /*want: */"dlrow ,olleH"}
|
||||
```
|
||||
|
||||
**Disabled by default. Enable it by setting `"hints": {"compositeLiteralFields": true}`.**
|
||||
|
||||
## **compositeLiteralTypes**
|
||||
|
||||
Enable/disable inlay hints for composite literal types:
|
||||
|
||||
```go
|
||||
for _, c := range []struct {
|
||||
in, want string
|
||||
}{
|
||||
/*struct{ in string; want string }*/{"Hello, world", "dlrow ,olleH"},
|
||||
}
|
||||
```
|
||||
|
||||
**Disabled by default. Enable it by setting `"hints": {"compositeLiteralTypes": true}`.**
|
||||
|
||||
## **constantValues**
|
||||
|
||||
Enable/disable inlay hints for constant values:
|
||||
|
||||
```go
|
||||
const (
|
||||
KindNone Kind = iota/* = 0*/
|
||||
KindPrint/* = 1*/
|
||||
KindPrintf/* = 2*/
|
||||
KindErrorf/* = 3*/
|
||||
)
|
||||
```
|
||||
|
||||
**Disabled by default. Enable it by setting `"hints": {"constantValues": true}`.**
|
||||
|
||||
## **functionTypeParameters**
|
||||
|
||||
Enable/disable inlay hints for implicit type parameters on generic functions:
|
||||
|
||||
```go
|
||||
myFoo/*[int, string]*/(1, "hello")
|
||||
```
|
||||
|
||||
**Disabled by default. Enable it by setting `"hints": {"functionTypeParameters": true}`.**
|
||||
|
||||
## **parameterNames**
|
||||
|
||||
Enable/disable inlay hints for parameter names:
|
||||
|
||||
```go
|
||||
parseInt(/* str: */ "123", /* radix: */ 8)
|
||||
```
|
||||
|
||||
**Disabled by default. Enable it by setting `"hints": {"parameterNames": true}`.**
|
||||
|
||||
## **rangeVariableTypes**
|
||||
|
||||
Enable/disable inlay hints for variable types in range statements:
|
||||
|
||||
for k/* int*/, v/* string/* := range []string{} {
|
||||
```go
|
||||
for k/* int*/, v/* string*/ := range []string{} {
|
||||
fmt.Println(k, v)
|
||||
}
|
||||
```
|
||||
|
||||
**Disabled by default. Enable it by setting `"hints": {"rangeVariableTypes": true}`.**
|
||||
|
||||
|
|
|
|||
|
|
@ -517,37 +517,37 @@ var GeneratedAPIJSON = &APIJSON{
|
|||
EnumKeys: EnumKeys{Keys: []EnumKey{
|
||||
{
|
||||
Name: "\"assignVariableTypes\"",
|
||||
Doc: "Enable/disable inlay hints for variable types in assign statements:\n\n\ti/* int/*, j/* int/* := 0, len(r)-1",
|
||||
Doc: "Enable/disable inlay hints for variable types in assign statements:\n```go\n\ti/* int*/, j/* int*/ := 0, len(r)-1\n```",
|
||||
Default: "false",
|
||||
},
|
||||
{
|
||||
Name: "\"compositeLiteralFields\"",
|
||||
Doc: "Enable/disable inlay hints for composite literal field names:\n\n\t{in: \"Hello, world\", want: \"dlrow ,olleH\"}",
|
||||
Doc: "Enable/disable inlay hints for composite literal field names:\n```go\n\t{/*in: */\"Hello, world\", /*want: */\"dlrow ,olleH\"}\n```",
|
||||
Default: "false",
|
||||
},
|
||||
{
|
||||
Name: "\"compositeLiteralTypes\"",
|
||||
Doc: "Enable/disable inlay hints for composite literal types:\n\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}",
|
||||
Doc: "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```",
|
||||
Default: "false",
|
||||
},
|
||||
{
|
||||
Name: "\"constantValues\"",
|
||||
Doc: "Enable/disable inlay hints for constant values:\n\n\tconst (\n\t\tKindNone Kind = iota/* = 0*/\n\t\tKindPrint/* = 1*/\n\t\tKindPrintf/* = 2*/\n\t\tKindErrorf/* = 3*/\n\t)",
|
||||
Doc: "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```",
|
||||
Default: "false",
|
||||
},
|
||||
{
|
||||
Name: "\"functionTypeParameters\"",
|
||||
Doc: "Enable/disable inlay hints for implicit type parameters on generic functions:\n\n\tmyFoo/*[int, string]*/(1, \"hello\")",
|
||||
Doc: "Enable/disable inlay hints for implicit type parameters on generic functions:\n```go\n\tmyFoo/*[int, string]*/(1, \"hello\")\n```",
|
||||
Default: "false",
|
||||
},
|
||||
{
|
||||
Name: "\"parameterNames\"",
|
||||
Doc: "Enable/disable inlay hints for parameter names:\n\n\tparseInt(/* str: */ \"123\", /* radix: */ 8)",
|
||||
Doc: "Enable/disable inlay hints for parameter names:\n```go\n\tparseInt(/* str: */ \"123\", /* radix: */ 8)\n```",
|
||||
Default: "false",
|
||||
},
|
||||
{
|
||||
Name: "\"rangeVariableTypes\"",
|
||||
Doc: "Enable/disable inlay hints for variable types in range statements:\n\n\tfor k/* int*/, v/* string/* := range []string{} {\n\t\tfmt.Println(k, v)\n\t}",
|
||||
Doc: "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```",
|
||||
Default: "false",
|
||||
},
|
||||
}},
|
||||
|
|
@ -1036,31 +1036,31 @@ var GeneratedAPIJSON = &APIJSON{
|
|||
Hints: []*HintJSON{
|
||||
{
|
||||
Name: "assignVariableTypes",
|
||||
Doc: "Enable/disable inlay hints for variable types in assign statements:\n\n\ti/* int/*, j/* int/* := 0, len(r)-1",
|
||||
Doc: "Enable/disable inlay hints for variable types in assign statements:\n```go\n\ti/* int*/, j/* int*/ := 0, len(r)-1\n```",
|
||||
},
|
||||
{
|
||||
Name: "compositeLiteralFields",
|
||||
Doc: "Enable/disable inlay hints for composite literal field names:\n\n\t{in: \"Hello, world\", want: \"dlrow ,olleH\"}",
|
||||
Doc: "Enable/disable inlay hints for composite literal field names:\n```go\n\t{/*in: */\"Hello, world\", /*want: */\"dlrow ,olleH\"}\n```",
|
||||
},
|
||||
{
|
||||
Name: "compositeLiteralTypes",
|
||||
Doc: "Enable/disable inlay hints for composite literal types:\n\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}",
|
||||
Doc: "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```",
|
||||
},
|
||||
{
|
||||
Name: "constantValues",
|
||||
Doc: "Enable/disable inlay hints for constant values:\n\n\tconst (\n\t\tKindNone Kind = iota/* = 0*/\n\t\tKindPrint/* = 1*/\n\t\tKindPrintf/* = 2*/\n\t\tKindErrorf/* = 3*/\n\t)",
|
||||
Doc: "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```",
|
||||
},
|
||||
{
|
||||
Name: "functionTypeParameters",
|
||||
Doc: "Enable/disable inlay hints for implicit type parameters on generic functions:\n\n\tmyFoo/*[int, string]*/(1, \"hello\")",
|
||||
Doc: "Enable/disable inlay hints for implicit type parameters on generic functions:\n```go\n\tmyFoo/*[int, string]*/(1, \"hello\")\n```",
|
||||
},
|
||||
{
|
||||
Name: "parameterNames",
|
||||
Doc: "Enable/disable inlay hints for parameter names:\n\n\tparseInt(/* str: */ \"123\", /* radix: */ 8)",
|
||||
Doc: "Enable/disable inlay hints for parameter names:\n```go\n\tparseInt(/* str: */ \"123\", /* radix: */ 8)\n```",
|
||||
},
|
||||
{
|
||||
Name: "rangeVariableTypes",
|
||||
Doc: "Enable/disable inlay hints for variable types in range statements:\n\n\tfor k/* int*/, v/* string/* := range []string{} {\n\t\tfmt.Println(k, v)\n\t}",
|
||||
Doc: "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```",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,63 +44,38 @@ const (
|
|||
var AllInlayHints = map[string]*Hint{
|
||||
AssignVariableTypes: {
|
||||
Name: AssignVariableTypes,
|
||||
Doc: `Enable/disable inlay hints for variable types in assign statements:
|
||||
|
||||
i/* int/*, j/* int/* := 0, len(r)-1`,
|
||||
Run: assignVariableTypes,
|
||||
Doc: "Enable/disable inlay hints for variable types in assign statements:\n```go\n\ti/* int*/, j/* int*/ := 0, len(r)-1\n```",
|
||||
Run: assignVariableTypes,
|
||||
},
|
||||
ParameterNames: {
|
||||
Name: ParameterNames,
|
||||
Doc: `Enable/disable inlay hints for parameter names:
|
||||
|
||||
parseInt(/* str: */ "123", /* radix: */ 8)`,
|
||||
Run: parameterNames,
|
||||
Doc: "Enable/disable inlay hints for parameter names:\n```go\n\tparseInt(/* str: */ \"123\", /* radix: */ 8)\n```",
|
||||
Run: parameterNames,
|
||||
},
|
||||
ConstantValues: {
|
||||
Name: ConstantValues,
|
||||
Doc: `Enable/disable inlay hints for constant values:
|
||||
|
||||
const (
|
||||
KindNone Kind = iota/* = 0*/
|
||||
KindPrint/* = 1*/
|
||||
KindPrintf/* = 2*/
|
||||
KindErrorf/* = 3*/
|
||||
)`,
|
||||
Run: constantValues,
|
||||
Doc: "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```",
|
||||
Run: constantValues,
|
||||
},
|
||||
RangeVariableTypes: {
|
||||
Name: RangeVariableTypes,
|
||||
Doc: `Enable/disable inlay hints for variable types in range statements:
|
||||
|
||||
for k/* int*/, v/* string/* := range []string{} {
|
||||
fmt.Println(k, v)
|
||||
}`,
|
||||
Run: rangeVariableTypes,
|
||||
Doc: "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```",
|
||||
Run: rangeVariableTypes,
|
||||
},
|
||||
CompositeLiteralTypes: {
|
||||
Name: CompositeLiteralTypes,
|
||||
Doc: `Enable/disable inlay hints for composite literal types:
|
||||
|
||||
for _, c := range []struct {
|
||||
in, want string
|
||||
}{
|
||||
/*struct{ in string; want string }*/{"Hello, world", "dlrow ,olleH"},
|
||||
}`,
|
||||
Run: compositeLiteralTypes,
|
||||
Doc: "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```",
|
||||
Run: compositeLiteralTypes,
|
||||
},
|
||||
CompositeLiteralFieldNames: {
|
||||
Name: CompositeLiteralFieldNames,
|
||||
Doc: `Enable/disable inlay hints for composite literal field names:
|
||||
|
||||
{in: "Hello, world", want: "dlrow ,olleH"}`,
|
||||
Run: compositeLiteralFields,
|
||||
Doc: "Enable/disable inlay hints for composite literal field names:\n```go\n\t{/*in: */\"Hello, world\", /*want: */\"dlrow ,olleH\"}\n```",
|
||||
Run: compositeLiteralFields,
|
||||
},
|
||||
FunctionTypeParameters: {
|
||||
Name: FunctionTypeParameters,
|
||||
Doc: `Enable/disable inlay hints for implicit type parameters on generic functions:
|
||||
|
||||
myFoo/*[int, string]*/(1, "hello")`,
|
||||
Run: funcTypeParams,
|
||||
Doc: "Enable/disable inlay hints for implicit type parameters on generic functions:\n```go\n\tmyFoo/*[int, string]*/(1, \"hello\")\n```",
|
||||
Run: funcTypeParams,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue