Debian Codegraph @

runtime/queries/zig/highlights.scm

raw symbols SCIP
1 ; Variables
2
3 (identifier) @variable
4
5 ; Parameters
6
7 (parameter
8 name: (identifier) @variable.parameter)
9
10 (payload
11 (identifier) @variable.parameter)
12
13 ; Types
14
15 (parameter
16 type: (identifier) @type)
17
18 ((identifier) @type
19 (#match? @type "^[A-Z_][a-zA-Z0-9_]*"))
20
21 (variable_declaration
22 (identifier) @type
23 "="
24 [
25 (struct_declaration)
26 (enum_declaration)
27 (union_declaration)
28 (opaque_declaration)
29 ])
30
31 [
32 (builtin_type)
33 "anyframe"
34 ] @type.builtin
35
36 ; Constants
37
38 ((identifier) @constant
39 (#match? @constant "^[A-Z][A-Z_0-9]+$"))
40
41 [
42 "null"
43 "unreachable"
44 "undefined"
45 ] @constant.builtin
46
47 (field_expression
48 .
49 member: (identifier) @constant)
50
51 (enum_declaration
52 (container_field
53 type: (identifier) @constant))
54
55 ; Labels
56
57 (block_label
58 (identifier) @label)
59
60 (break_label
61 (identifier) @label)
62
63 ; Fields
64
65 (field_initializer
66 .
67 (identifier) @variable.other.member)
68
69 (field_expression
70 (_)
71 member: (identifier) @variable.other.member)
72
73 (field_expression
74 (_)
75 member: (identifier) @type (#match? @type "^[A-Z_][a-zA-Z0-9_]*"))
76
77 (field_expression
78 (_)
79 member: (identifier) @constant (#match? @constant "^[A-Z][A-Z_0-9]+$"))
80
81 (container_field
82 name: (identifier) @variable.other.member)
83
84 (initializer_list
85 (assignment_expression
86 left: (field_expression
87 .
88 member: (identifier) @variable.other.member)))
89
90 ; Functions
91
92 (builtin_identifier) @function.builtin
93
94 (call_expression
95 function: (identifier) @function)
96
97 (call_expression
98 function: (field_expression
99 member: (identifier) @function.method))
100
101 (function_declaration
102 name: (identifier) @function)
103
104 ; Modules
105
106 (variable_declaration
107 (_)
108 (builtin_function
109 (builtin_identifier) @keyword.control.import
110 (#any-of? @keyword.control.import "@import" "@cImport")))
111
112 (variable_declaration
113 (_)
114 (field_expression
115 object: (builtin_function
116 (builtin_identifier) @keyword.control.import
117 (#any-of? @keyword.control.import "@import" "@cImport"))))
118
119 ; Builtins
120
121 [
122 "c"
123 "..."
124 ] @variable.builtin
125
126 ((identifier) @variable.builtin
127 (#eq? @variable.builtin "_"))
128
129 (calling_convention
130 (identifier) @variable.builtin)
131
132 ; Keywords
133
134 [
135 "asm"
136 "test"
137 ] @keyword
138
139 [
140 "error"
141 "const"
142 "var"
143 "struct"
144 "union"
145 "enum"
146 "opaque"
147 ] @keyword.storage.type
148
149 ; todo: keyword.coroutine
150 [
151 "async"
152 "await"
153 "suspend"
154 "nosuspend"
155 "resume"
156 ] @keyword
157
158 "fn" @keyword.function
159
160 [
161 "and"
162 "or"
163 "orelse"
164 ] @keyword.operator
165
166 [
167 "try"
168 "unreachable"
169 "return"
170 ] @keyword.control.return
171
172 [
173 "if"
174 "else"
175 "switch"
176 "catch"
177 ] @keyword.control.conditional
178
179 [
180 "for"
181 "while"
182 "break"
183 "continue"
184 ] @keyword.control.repeat
185
186 [
187 "usingnamespace"
188 "export"
189 ] @keyword.control.import
190
191 [
192 "defer"
193 "errdefer"
194 ] @keyword.control.exception
195
196 [
197 "volatile"
198 "allowzero"
199 "noalias"
200 "addrspace"
201 "align"
202 "callconv"
203 "linksection"
204 "pub"
205 "inline"
206 "noinline"
207 "extern"
208 "comptime"
209 "packed"
210 "threadlocal"
211 ] @keyword.storage.modifier
212
213 ; Operator
214
215 [
216 "="
217 "*="
218 "*%="
219 "*|="
220 "/="
221 "%="
222 "+="
223 "+%="
224 "+|="
225 "-="
226 "-%="
227 "-|="
228 "<<="
229 "<<|="
230 ">>="
231 "&="
232 "^="
233 "|="
234 "!"
235 "~"
236 "-"
237 "-%"
238 "&"
239 "=="
240 "!="
241 ">"
242 ">="
243 "<="
244 "<"
245 "&"
246 "^"
247 "|"
248 "<<"
249 ">>"
250 "<<|"
251 "+"
252 "++"
253 "+%"
254 "-%"
255 "+|"
256 "-|"
257 "*"
258 "/"
259 "%"
260 "**"
261 "*%"
262 "*|"
263 "||"
264 ".*"
265 ".?"
266 "?"
267 ".."
268 ] @operator
269
270 ; Literals
271
272 (character) @constant.character
273
274 [
275 (string)
276 (multiline_string)
277 ] @string
278
279 (integer) @constant.numeric.integer
280
281 (float) @constant.numeric.float
282
283 (boolean) @constant.builtin.boolean
284
285 (escape_sequence) @constant.character.escape
286
287 ; Punctuation
288
289 [
290 "["
291 "]"
292 "("
293 ")"
294 "{"
295 "}"
296 ] @punctuation.bracket
297
298 [
299 ";"
300 "."
301 ","
302 ":"
303 "=>"
304 "->"
305 ] @punctuation.delimiter
306
307 (payload "|" @punctuation.bracket)
308
309 ; Comments
310
311 (comment) @comment.line
312
313 ((comment) @comment.block.documentation
314 (#match? @comment.block.documentation "^//!"))