Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

Commit c97a768

Browse files
committed
added highlighting for function return-types
removed meta.function.parameter and meta.block scopes due to issues with the end of the scopes being detected improperly
1 parent 2435c56 commit c97a768

File tree

3 files changed

+333
-308
lines changed

3 files changed

+333
-308
lines changed

Syntaxes/Zig.YAML-tmLanguage

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ repository:
3636
'2':
3737
name: punctuation.separator.zig
3838

39-
end: '([a-zA-Z_][a-zA-Z0-9_]*|@\".+\")(?:(,)|(?=\)))'
40-
39+
end: '([a-zA-Z_][a-zA-Z0-9_]*|@\".+\")?\s*(?:(,)|(\)))'
4140
endCaptures:
4241
'1':
4342
name: storage.type.zig
4443
'2':
4544
name: punctuation.separator.zig
45+
'3':
46+
name: punctuation.section.parens.end.zig
4647

4748
patterns:
4849
- include: '#main'
@@ -263,8 +264,6 @@ repository:
263264
'2':
264265
name: punctuation.section.braces.begin.zig
265266

266-
contentName: meta.block.zig
267-
268267
end: '(\})'
269268
endCaptures:
270269
'1':
@@ -281,17 +280,18 @@ repository:
281280
'2':
282281
name: punctuation.section.parens.begin.zig
283282

284-
contentName: meta.function.parameters.zig
285-
286-
end: '(\))'
283+
end: '(?<=\))([a-zA-Z_][a-zA-Z0-9_]*|@\".+\")'
287284
endCaptures:
288285
'1':
289-
name: punctuation.section.parens.begin.zig
286+
name: storage.type.zig
290287

291288
patterns:
292289
- include: '#param_list'
293290
- include: '#main'
294291

292+
- match: '([a-zA-Z_][a-zA-Z0-9_]*|@\".+\")'
293+
name: storage.type.zig
294+
295295
function_call:
296296
name: variable.function.zig
297297
match: '(?<!fn)\b([a-zA-Z_][a-zA-Z0-9_]*|@\".+\")(?=\s*\()'
@@ -304,17 +304,20 @@ repository:
304304
'2':
305305
name: punctuation.section.parens.begin.zig
306306

307-
contentName: meta.parameters.zig
307+
contentName: meta.function.parameters.zig
308308

309-
end: '(\))'
309+
end: '(?<=\))\s*([a-zA-Z_][a-zA-Z0-9_]*|@\".+\")'
310310
endCaptures:
311311
'1':
312-
name: punctuation.section.parens.end.zig
312+
name: storage.type.zig
313313

314314
patterns:
315315
- include: '#param_list'
316316
- include: '#main'
317317

318+
- match: '([a-zA-Z_][a-zA-Z0-9_]*|@\".+\")'
319+
name: storage.type.zig
320+
318321
var_decl:
319322
begin: '\b(const|var)\s+([a-zA-Z_][a-zA-Z0-9_]*|@\".+\")\s*(:)'
320323
beginCaptures:
@@ -354,5 +357,5 @@ repository:
354357
- include: '#support'
355358
- include: '#field_decl'
356359
- include: '#block'
357-
- include: '#function_call'
358360
- include: '#function_def'
361+
- include: '#function_call'

Syntaxes/Zig.tmLanguage

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
<string>punctuation.section.braces.begin.zig</string>
3535
</dict>
3636
</dict>
37-
<key>contentName</key>
38-
<string>meta.block.zig</string>
3937
<key>end</key>
4038
<string>(\})</string>
4139
<key>endCaptures</key>
@@ -312,16 +310,14 @@
312310
<string>punctuation.section.parens.begin.zig</string>
313311
</dict>
314312
</dict>
315-
<key>contentName</key>
316-
<string>meta.function.parameters.zig</string>
317313
<key>end</key>
318-
<string>(\))</string>
314+
<string>(?&lt;=\))([a-zA-Z_][a-zA-Z0-9_]*|@\".+\")</string>
319315
<key>endCaptures</key>
320316
<dict>
321317
<key>1</key>
322318
<dict>
323319
<key>name</key>
324-
<string>punctuation.section.parens.begin.zig</string>
320+
<string>storage.type.zig</string>
325321
</dict>
326322
</dict>
327323
<key>patterns</key>
@@ -334,6 +330,12 @@
334330
<key>include</key>
335331
<string>#main</string>
336332
</dict>
333+
<dict>
334+
<key>match</key>
335+
<string>([a-zA-Z_][a-zA-Z0-9_]*|@\".+\")</string>
336+
<key>name</key>
337+
<string>storage.type.zig</string>
338+
</dict>
337339
</array>
338340
</dict>
339341
<key>function_type</key>
@@ -354,15 +356,15 @@
354356
</dict>
355357
</dict>
356358
<key>contentName</key>
357-
<string>meta.parameters.zig</string>
359+
<string>meta.function.parameters.zig</string>
358360
<key>end</key>
359-
<string>(\))</string>
361+
<string>(?&lt;=\))\s*([a-zA-Z_][a-zA-Z0-9_]*|@\".+\")</string>
360362
<key>endCaptures</key>
361363
<dict>
362364
<key>1</key>
363365
<dict>
364366
<key>name</key>
365-
<string>punctuation.section.parens.end.zig</string>
367+
<string>storage.type.zig</string>
366368
</dict>
367369
</dict>
368370
<key>patterns</key>
@@ -375,6 +377,12 @@
375377
<key>include</key>
376378
<string>#main</string>
377379
</dict>
380+
<dict>
381+
<key>match</key>
382+
<string>([a-zA-Z_][a-zA-Z0-9_]*|@\".+\")</string>
383+
<key>name</key>
384+
<string>storage.type.zig</string>
385+
</dict>
378386
</array>
379387
</dict>
380388
<key>keywords</key>
@@ -506,11 +514,11 @@
506514
</dict>
507515
<dict>
508516
<key>include</key>
509-
<string>#function_call</string>
517+
<string>#function_def</string>
510518
</dict>
511519
<dict>
512520
<key>include</key>
513-
<string>#function_def</string>
521+
<string>#function_call</string>
514522
</dict>
515523
</array>
516524
</dict>
@@ -580,7 +588,7 @@
580588
</dict>
581589
</dict>
582590
<key>end</key>
583-
<string>([a-zA-Z_][a-zA-Z0-9_]*|@\".+\")(?:(,)|(?=\)))</string>
591+
<string>([a-zA-Z_][a-zA-Z0-9_]*|@\".+\")?\s*(?:(,)|(\)))</string>
584592
<key>endCaptures</key>
585593
<dict>
586594
<key>1</key>
@@ -593,6 +601,11 @@
593601
<key>name</key>
594602
<string>punctuation.separator.zig</string>
595603
</dict>
604+
<key>3</key>
605+
<dict>
606+
<key>name</key>
607+
<string>punctuation.section.parens.end.zig</string>
608+
</dict>
596609
</dict>
597610
<key>patterns</key>
598611
<array>

0 commit comments

Comments
 (0)