[OCaml] Mobile-friendly clone of cgit.
1
{
2
"$schema":"https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3
"name":"zig",
4
"scopeName":"source.zig",
5
"fileTypes":["zig","zon"],
6
"patterns":[
7
{
8
"include":"#comments"
9
},
10
{
11
"include":"#strings"
12
},
13
{
14
"include":"#keywords"
15
},
16
{
17
"include":"#operators"
18
},
19
{
20
"include":"#punctuation"
21
},
22
{
23
"include":"#numbers"
24
},
25
{
26
"include":"#support"
27
},
28
{
29
"include":"#variables"
30
}
31
],
32
"repository":{
33
"variables":{
34
"patterns":[
35
{
36
"name":"meta.function.declaration.zig",
37
"patterns":[
38
{
39
"match":"\\b(fn)\\s+([A-Z][a-zA-Z0-9]*)\\b",
40
"captures":{
41
"1":{
42
"name":"storage.type.function.zig"
43
},
44
"2":{
45
"name":"entity.name.type.zig"
46
}
47
}
48
},
49
{
50
"match":"\\b(fn)\\s+([_a-zA-Z][_a-zA-Z0-9]*)\\b",
51
"captures":{
52
"1":{
53
"name":"storage.type.function.zig"
54
},
55
"2":{
56
"name":"entity.name.function.zig"
57
}
58
}
59
},
60
{
61
"begin":"\\b(fn)\\s+@\"",
62
"end":"\"",
63
"name":"entity.name.function.string.zig",
64
"beginCaptures":{
65
"1":{
66
"name":"storage.type.function.zig"
67
}
68
},
69
"patterns":[
70
{
71
"include":"#stringcontent"
72
}
73
]
74
},
75
{
76
"name":"keyword.default.zig",
77
"match":"\\b(const|var|fn)\\b"
78
}
79
]
80
},
81
{
82
"name":"meta.function.call.zig",
83
"patterns":[
84
{
85
"match":"([A-Z][a-zA-Z0-9]*)(?=\\s*\\()",
86
"name":"entity.name.type.zig"
87
},
88
{
89
"match":"([_a-zA-Z][_a-zA-Z0-9]*)(?=\\s*\\()",
90
"name":"entity.name.function.zig"
91
}
92
]
93
},
94
{
95
"name":"meta.variable.zig",
96
"patterns":[
97
{
98
"match":"\\b[_a-zA-Z][_a-zA-Z0-9]*\\b",
99
"name":"variable.zig"
100
},
101
{
102
"begin":"@\"",
103
"end":"\"",
104
"name":"variable.string.zig",
105
"patterns":[
106
{
107
"include":"#stringcontent"
108
}
109
]
110
}
111
]
112
}
113
]
114
},
115
"keywords":{
116
"patterns":[
117
{
118
"match":"\\binline\\b(?!\\s*\\bfn\\b)",
119
"name":"keyword.control.repeat.zig"
120
},
121
{
122
"match":"\\b(while|for)\\b",
123
"name":"keyword.control.repeat.zig"
124
},
125
{
126
"name":"keyword.storage.zig",
127
"match":"\\b(extern|packed|export|pub|noalias|inline|comptime|volatile|align|linksection|threadlocal|allowzero|noinline|callconv)\\b"
128
},
129
{
130
"name":"keyword.structure.zig",
131
"match":"\\b(struct|enum|union|opaque)\\b"
132
},
133
{
134
"name":"keyword.statement.zig",
135
"match":"\\b(asm|unreachable)\\b"
136
},
137
{
138
"name":"keyword.control.flow.zig",
139
"match":"\\b(break|return|continue|defer|errdefer)\\b"
140
},
141
{
142
"name":"keyword.control.async.zig",
143
"match":"\\b(resume|suspend|nosuspend)\\b"
144
},
145
{
146
"name":"keyword.control.trycatch.zig",
147
"match":"\\b(try|catch)\\b"
148
},
149
{
150
"name":"keyword.control.conditional.zig",
151
"match":"\\b(if|else|switch|orelse)\\b"
152
},
153
{
154
"name":"keyword.constant.default.zig",
155
"match":"\\b(null|undefined)\\b"
156
},
157
{
158
"name":"keyword.constant.bool.zig",
159
"match":"\\b(true|false)\\b"
160
},
161
{
162
"name":"keyword.default.zig",
163
"match":"\\b(test|and|or)\\b"
164
},
165
{
166
"name":"keyword.type.zig",
167
"match":"\\b(bool|void|noreturn|type|error|anyerror|anyframe|anytype|anyopaque)\\b"
168
},
169
{
170
"name":"keyword.type.integer.zig",
171
"match":"\\b(f16|f32|f64|f80|f128|u\\d+|i\\d+|isize|usize|comptime_int|comptime_float)\\b"
172
},
173
{
174
"name":"keyword.type.c.zig",
175
"match":"\\b(c_char|c_short|c_ushort|c_int|c_uint|c_long|c_ulong|c_longlong|c_ulonglong|c_longdouble)\\b"
176
}
177
]
178
},
179
"operators":{
180
"patterns":[
181
{
182
"name":"keyword.operator.c-pointer.zig",
183
"match":"(?<=\\[)\\*c(?=\\])"
184
},
185
{
186
"name":"keyword.operator.comparison.zig",
187
"match":"(\\b(and|or)\\b)|(==|!=|<=|>=|<|>)"
188
},
189
{
190
"name":"keyword.operator.arithmetic.zig",
191
"match":"(-%?|\\+%?|\\*%?|/|%)=?"
192
},
193
{
194
"name":"keyword.operator.bitwise.zig",
195
"match":"(<<%?|>>|!|~|&|\\^|\\|)=?"
196
},
197
{
198
"name":"keyword.operator.special.zig",
199
"match":"(==|\\+\\+|\\*\\*|->)"
200
},
201
{
202
"name":"keyword.operator.assignment.zig",
203
"match":"="
204
},
205
{
206
"name":"keyword.operator.question.zig",
207
"match":"\\?"
208
}
209
]
210
},
211
"comments":{
212
"patterns":[
213
{
214
"name":"comment.line.documentation.zig",
215
"begin":"//[!/](?=[^/])",
216
"end":"$",
217
"patterns":[
218
{
219
"include":"#commentContents"
220
}
221
]
222
},
223
{
224
"name":"comment.line.double-slash.zig",
225
"begin":"//",
226
"end":"$",
227
"patterns":[
228
{
229
"include":"#commentContents"
230
}
231
]
232
}
233
]
234
},
235
"commentContents":{
236
"patterns":[
237
{
238
"match":"\\b(TODO|FIXME|XXX|NOTE)\\b:?",
239
"name":"keyword.todo.zig"
240
}
241
]
242
},
243
"punctuation":{
244
"patterns":[
245
{
246
"name":"punctuation.accessor.zig",
247
"match":"\\."
248
},
249
{
250
"name":"punctuation.comma.zig",
251
"match":","
252
},
253
{
254
"name":"punctuation.separator.key-value.zig",
255
"match":":"
256
},
257
{
258
"name":"punctuation.terminator.statement.zig",
259
"match":";"
260
}
261
]
262
},
263
"strings":{
264
"patterns":[
265
{
266
"name":"string.quoted.double.zig",
267
"begin":"\"",
268
"end":"\"",
269
"patterns":[
270
{
271
"include":"#stringcontent"
272
}
273
]
274
},
275
{
276
"name":"string.multiline.zig",
277
"begin":"\\\\\\\\",
278
"end":"$"
279
},
280
{
281
"name":"string.quoted.single.zig",
282
"match":"'([^'\\\\]|\\\\(x\\h{2}|[0-2][0-7]{,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.))'"
283
}
284
]
285
},
286
"stringcontent":{
287
"patterns":[
288
{
289
"name":"constant.character.escape.zig",
290
"match":"\\\\([nrt'\"\\\\]|(x[0-9a-fA-F]{2})|(u\\{[0-9a-fA-F]+\\}))"
291
},
292
{
293
"name":"invalid.illegal.unrecognized-string-escape.zig",
294
"match":"\\\\."
295
}
296
]
297
},
298
"numbers":{
299
"patterns":[
300
{
301
"name":"constant.numeric.hexfloat.zig",
302
"match":"\\b0x[0-9a-fA-F][0-9a-fA-F_]*(\\.[0-9a-fA-F][0-9a-fA-F_]*)?([pP][+-]?[0-9a-fA-F_]+)?\\b"
303
},
304
{
305
"name":"constant.numeric.float.zig",
306
"match":"\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?([eE][+-]?[0-9_]+)?\\b"
307
},
308
{
309
"name":"constant.numeric.decimal.zig",
310
"match":"\\b[0-9][0-9_]*\\b"
311
},
312
{
313
"name":"constant.numeric.hexadecimal.zig",
314
"match":"\\b0x[a-fA-F0-9_]+\\b"
315
},
316
{
317
"name":"constant.numeric.octal.zig",
318
"match":"\\b0o[0-7_]+\\b"
319
},
320
{
321
"name":"constant.numeric.binary.zig",
322
"match":"\\b0b[01_]+\\b"
323
},
324
{
325
"name":"constant.numeric.invalid.zig",
326
"match":"\\b[0-9](([eEpP][+-])|[0-9a-zA-Z_])*(\\.(([eEpP][+-])|[0-9a-zA-Z_])*)?([eEpP][+-])?[0-9a-zA-Z_]*\\b"
327
}
328
]
329
},
330
"support":{
331
"patterns":[
332
{
333
"comment":"Built-in functions",
334
"name":"support.function.builtin.zig",
335
"match":"@[_a-zA-Z][_a-zA-Z0-9]*"
336
}
337
]
338
}
339
}
340
}
341