Skip to content

Commit 3fd690a

Browse files
authored
docs: Update lsp.settings examples for yaml-language-server (#18081)
1 parent e9f2e72 commit 3fd690a

File tree

3 files changed

+108
-19
lines changed

3 files changed

+108
-19
lines changed

docs/src/configuring-zed.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,13 @@ Each option controls displaying of a particular toolbar element. If all elements
575575
The following settings can be overridden for specific language servers:
576576

577577
- `initialization_options`
578+
- `settings`
578579

579-
To override settings for a language, add an entry for that language server's name to the `lsp` value. Example:
580+
To override configuration for a language server, add an entry for that language server's name to the `lsp` value.
581+
582+
Some options are passed via `initialization_options` to the language server. These are for options which must be specified at language server startup and when changed will require restarting the language server.
583+
584+
For example to pass the `check` option to `rust-analyzer`, use the following configuration:
580585

581586
```json
582587
"lsp": {
@@ -590,6 +595,20 @@ To override settings for a language, add an entry for that language server's nam
590595
}
591596
```
592597

598+
While other options may be changed at a runtime and should be placed under `settings`:
599+
600+
```json
601+
"lsp": {
602+
"yaml-language-server": {
603+
"settings": {
604+
"yaml": {
605+
"keyOrdering": true // Enforces alphabetical ordering of keys in maps
606+
}
607+
}
608+
}
609+
}
610+
```
611+
593612
## Format On Save
594613

595614
- Description: Whether or not to perform a buffer format before saving.

docs/src/languages/typescript.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,20 @@ You can override these settings in your configuration file:
7272

7373
```json
7474
"lsp": {
75-
"$LANGUAGE_SERVER_NAME": {
76-
"initialization_options": {
77-
"preferences": {
78-
"includeInlayParameterNameHints": "all",
79-
"includeInlayParameterNameHintsWhenArgumentMatchesName": true,
80-
"includeInlayFunctionParameterTypeHints": true,
81-
"includeInlayVariableTypeHints": true,
82-
"includeInlayVariableTypeHintsWhenTypeMatchesName": true,
83-
"includeInlayPropertyDeclarationTypeHints": true,
84-
"includeInlayFunctionLikeReturnTypeHints": true,
85-
"includeInlayEnumMemberValueHints": true,
86-
}
87-
}
75+
"$LANGUAGE_SERVER_NAME": {
76+
"initialization_options": {
77+
"preferences": {
78+
"includeInlayParameterNameHints": "all",
79+
"includeInlayParameterNameHintsWhenArgumentMatchesName": true,
80+
"includeInlayFunctionParameterTypeHints": true,
81+
"includeInlayVariableTypeHints": true,
82+
"includeInlayVariableTypeHintsWhenTypeMatchesName": true,
83+
"includeInlayPropertyDeclarationTypeHints": true,
84+
"includeInlayFunctionLikeReturnTypeHints": true,
85+
"includeInlayEnumMemberValueHints": true,
86+
}
8887
}
88+
}
8989
}
9090
```
9191

docs/src/languages/yaml.md

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ You can configure various [yaml-language-server settings](https://github.com/red
1212
```json
1313
"lsp": {
1414
"yaml-language-server": {
15-
"initialization_options": {
15+
"settings": {
1616
"yaml": {
1717
"keyOrdering": true,
1818
"format": {
@@ -32,9 +32,9 @@ Note, settings keys must be nested, so `yaml.keyOrdering` becomes `{"yaml": { "k
3232

3333
## Schemas
3434

35-
By default yaml-language-server will attempt to determine the correct schema for a given yaml file and retrieve the appropriate JSON Schema from [Json Schema Store].
35+
By default yaml-language-server will attempt to determine the correct schema for a given yaml file and retrieve the appropriate JSON Schema from [Json Schema Store](https://schemastore.org/).
3636

37-
You can override this by [using an inlined schema] reference via a modeline comment at the top of your yaml file:
37+
You can override any auto-detected schema via the `schemas` settings key (demonstrated above) or by providing an [inlined schema](https://github.com/redhat-developer/yaml-language-server#using-inlined-schema) reference via a modeline comment at the top of your yaml file:
3838

3939
```yaml
4040
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
@@ -44,12 +44,12 @@ on:
4444
types: [oppened]
4545
```
4646
47-
You can disable this functionality entirely if desired:
47+
You can disable the automatic detection and retrieval of schemas from the JSON Schema if desired:
4848
4949
```json
5050
"lsp": {
5151
"yaml-language-server": {
52-
"initialization_options": {
52+
"settings": {
5353
"yaml": {
5454
"schemaStore": {
5555
"enable": false
@@ -59,3 +59,73 @@ You can disable this functionality entirely if desired:
5959
}
6060
}
6161
```
62+
63+
## Custom Tags
64+
65+
Yaml-language-server supports [custom tags](https://github.com/redhat-developer/yaml-language-server#adding-custom-tags) which can be used to inject custom application functionality at runtime into your yaml files.
66+
67+
For example Amazon CloudFormation YAML uses a number of custom tags, to support these you can add the following to your settings.json:
68+
69+
```json
70+
"lsp": {
71+
"yaml-language-server": {
72+
"settings": {
73+
"yaml": {
74+
"customTags": [
75+
"!And scalar",
76+
"!And mapping",
77+
"!And sequence",
78+
"!If scalar",
79+
"!If mapping",
80+
"!If sequence",
81+
"!Not scalar",
82+
"!Not mapping",
83+
"!Not sequence",
84+
"!Equals scalar",
85+
"!Equals mapping",
86+
"!Equals sequence",
87+
"!Or scalar",
88+
"!Or mapping",
89+
"!Or sequence",
90+
"!FindInMap scalar",
91+
"!FindInMap mapping",
92+
"!FindInMap sequence",
93+
"!Base64 scalar",
94+
"!Base64 mapping",
95+
"!Base64 sequence",
96+
"!Cidr scalar",
97+
"!Cidr mapping",
98+
"!Cidr sequence",
99+
"!Ref scalar",
100+
"!Ref mapping",
101+
"!Ref sequence",
102+
"!Sub scalar",
103+
"!Sub mapping",
104+
"!Sub sequence",
105+
"!GetAtt scalar",
106+
"!GetAtt mapping",
107+
"!GetAtt sequence",
108+
"!GetAZs scalar",
109+
"!GetAZs mapping",
110+
"!GetAZs sequence",
111+
"!ImportValue scalar",
112+
"!ImportValue mapping",
113+
"!ImportValue sequence",
114+
"!Select scalar",
115+
"!Select mapping",
116+
"!Select sequence",
117+
"!Split scalar",
118+
"!Split mapping",
119+
"!Split sequence",
120+
"!Join scalar",
121+
"!Join mapping",
122+
"!Join sequence",
123+
"!Condition scalar",
124+
"!Condition mapping",
125+
"!Condition sequence"
126+
]
127+
}
128+
}
129+
}
130+
}
131+
```

0 commit comments

Comments
 (0)