1# YAML
2
3YAML support is available natively in Zed.
4
5- Tree Sitter: [zed-industries/tree-sitter-yaml](https://github.com/zed-industries/tree-sitter-yaml)
6- Language Server: [redhat-developer/yaml-language-server](https://github.com/redhat-developer/yaml-language-server)
7
8## Configuration
9
10You can configure various [yaml-language-server settings](https://github.com/redhat-developer/yaml-language-server?tab=readme-ov-file#language-server-settings) by adding them to your Zed settings.json in a `yaml-language-server` block under the `lsp` key. For example:
11
12```json
13 "lsp": {
14 "yaml-language-server": {
15 "settings": {
16 "yaml": {
17 "keyOrdering": true,
18 "format": {
19 "singleQuote": true
20 },
21 "schemas": {
22 "http://json.schemastore.org/composer": ["/*"],
23 "../relative/path/schema.json": ["/config*.yaml"]
24 }
25 }
26 }
27 }
28 }
29```
30
31Note, settings keys must be nested, so `yaml.keyOrdering` becomes `{"yaml": { "keyOrdering": true }}`.
32
33## Schemas
34
35By 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/).
36
37You 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:
38
39```yaml
40# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
41name: Issue Assignment
42on:
43 issues:
44 types: [oppened]
45```
46
47You can disable the automatic detection and retrieval of schemas from the JSON Schema if desired:
48
49```json
50 "lsp": {
51 "yaml-language-server": {
52 "settings": {
53 "yaml": {
54 "schemaStore": {
55 "enable": false
56 }
57 }
58 }
59 }
60 }
61```
62
63## Custom Tags
64
65Yaml-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
67For 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```