1// Default semantic token rules for Zed (read-only).
2//
3// These rules map LSP semantic token types to syntax theme styles.
4// To customize, add rules to "semantic_token_rules" in your settings.json.
5// User-defined rules are prepended to these defaults and take precedence.
6//
7// Each rule has the following properties:
8// - `token_type`: The LSP semantic token type to match. If omitted, matches all types.
9// - `token_modifiers`: A list of LSP semantic token modifiers to match. All must be present.
10// - `style`: A list of syntax theme styles to try. The first one found is used.
11// - `foreground_color`: Override foreground color in hex format (e.g., "#ff0000").
12// - `background_color`: Override background color in hex format.
13// - `underline`: Boolean or color to underline with. If `true`, uses text color.
14// - `strikethrough`: Boolean or color. If `true`, uses text color.
15// - `font_weight`: One of "normal", "bold".
16// - `font_style`: One of "normal", "italic".
17//
18// See the VSCode docs [1] and the LSP Spec [2] for reasoning behind these defaults.
19//
20// [1]: https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#standard-token-types-and-modifiers
21// [2]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#semanticTokenTypes
22[
23 // Types
24 {
25 "token_type": "namespace",
26 "token_modifiers": [],
27 "style": ["namespace", "module", "type"],
28 },
29 {
30 "token_type": "class",
31 "token_modifiers": ["declaration"],
32 "style": ["type.class.definition", "type.definition"],
33 },
34 {
35 "token_type": "class",
36 "token_modifiers": ["definition"],
37 "style": ["type.class.definition", "type.definition"],
38 },
39 {
40 "token_type": "class",
41 "token_modifiers": [],
42 "style": ["type.class", "class", "type"],
43 },
44 {
45 "token_type": "enum",
46 "token_modifiers": ["declaration"],
47 "style": ["type.enum.definition", "type.definition"],
48 },
49 {
50 "token_type": "enum",
51 "token_modifiers": ["definition"],
52 "style": ["type.enum.definition", "type.definition"],
53 },
54 {
55 "token_type": "enum",
56 "token_modifiers": [],
57 "style": ["type.enum", "enum", "type"],
58 },
59 {
60 "token_type": "interface",
61 "token_modifiers": ["declaration"],
62 "style": ["type.interface.definition", "type.definition"],
63 },
64 {
65 "token_type": "interface",
66 "token_modifiers": ["definition"],
67 "style": ["type.interface.definition", "type.definition"],
68 },
69 {
70 "token_type": "interface",
71 "token_modifiers": [],
72 "style": ["type.interface", "interface", "type"],
73 },
74 {
75 "token_type": "struct",
76 "token_modifiers": ["declaration"],
77 "style": ["type.struct.definition", "type.definition"],
78 },
79 {
80 "token_type": "struct",
81 "token_modifiers": ["definition"],
82 "style": ["type.struct.definition", "type.definition"],
83 },
84 {
85 "token_type": "struct",
86 "token_modifiers": [],
87 "style": ["type.struct", "struct", "type"],
88 },
89 {
90 "token_type": "typeParameter",
91 "token_modifiers": ["declaration"],
92 "style": ["type.parameter.definition", "type.definition"],
93 },
94 {
95 "token_type": "typeParameter",
96 "token_modifiers": ["definition"],
97 "style": ["type.parameter.definition", "type.definition"],
98 },
99 {
100 "token_type": "typeParameter",
101 "token_modifiers": [],
102 "style": ["type.parameter", "type"],
103 },
104 {
105 "token_type": "type",
106 "token_modifiers": ["declaration"],
107 "style": ["type.definition"],
108 },
109 {
110 "token_type": "type",
111 "token_modifiers": ["definition"],
112 "style": ["type.definition"],
113 },
114 {
115 "token_type": "type",
116 "token_modifiers": [],
117 "style": ["type"],
118 },
119 // References
120 {
121 "token_type": "parameter",
122 "token_modifiers": [],
123 "style": ["variable"],
124 },
125 {
126 "token_type": "variable",
127 "token_modifiers": ["defaultLibrary", "constant"],
128 "style": ["constant.builtin"],
129 },
130 {
131 "token_type": "variable",
132 "token_modifiers": ["defaultLibrary"],
133 "style": ["variable.builtin"],
134 },
135 {
136 "token_type": "variable",
137 "token_modifiers": ["constant"],
138 "style": ["constant"],
139 },
140 {
141 "token_type": "variable",
142 "token_modifiers": [],
143 "style": ["variable"],
144 },
145 {
146 "token_type": "property",
147 "token_modifiers": [],
148 "style": ["property"],
149 },
150 {
151 "token_type": "enumMember",
152 "token_modifiers": [],
153 "style": ["type.enum.member", "type.enum", "variant"],
154 },
155 {
156 "token_type": "decorator",
157 "token_modifiers": [],
158 "style": ["function.decorator", "function.annotation", "attribute"],
159 },
160 // Declarations in the docs, but in practice, also references
161 {
162 "token_type": "function",
163 "token_modifiers": ["defaultLibrary"],
164 "style": ["function.builtin"],
165 },
166 {
167 "token_type": "function",
168 "token_modifiers": [],
169 "style": ["function"],
170 },
171 {
172 "token_type": "method",
173 "token_modifiers": ["defaultLibrary"],
174 "style": ["function.builtin"],
175 },
176 {
177 "token_type": "method",
178 "token_modifiers": [],
179 "style": ["function.method", "function"],
180 },
181 {
182 "token_type": "macro",
183 "token_modifiers": [],
184 "style": ["function.macro", "function"],
185 },
186 {
187 "token_type": "label",
188 "token_modifiers": [],
189 "style": ["label"],
190 },
191 // Tokens
192 {
193 "token_type": "comment",
194 "token_modifiers": ["documentation"],
195 "style": ["comment.documentation", "comment.doc"],
196 },
197 {
198 "token_type": "comment",
199 "token_modifiers": [],
200 "style": ["comment"],
201 },
202 {
203 "token_type": "string",
204 "token_modifiers": [],
205 "style": ["string"],
206 },
207 {
208 "token_type": "keyword",
209 "token_modifiers": [],
210 "style": ["keyword"],
211 },
212 {
213 "token_type": "number",
214 "token_modifiers": [],
215 "style": ["number"],
216 },
217 {
218 "token_type": "regexp",
219 "token_modifiers": [],
220 "style": ["string.regexp", "string"],
221 },
222 {
223 "token_type": "operator",
224 "token_modifiers": [],
225 "style": ["operator"],
226 },
227 // Not in the VS Code docs, but in the LSP spec.
228 {
229 "token_type": "modifier",
230 "token_modifiers": [],
231 "style": ["keyword.modifier"],
232 },
233 // C#
234 {
235 "token_type": "event",
236 "token_modifiers": [],
237 "style": ["type.event", "type"],
238 },
239]