default_semantic_token_rules.json

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