on master help sign in
update zig grammar and highlight rules (#3621)
6e5e38cvoroskoi
languages.toml+1−2
@@ -735,10 +735,9 @@ language-server = { command = "zls" }
735indent = { tab-width = 4, unit = " " }
735indent = { tab-width = 4, unit = " " }
736formatter = { command = "zig" , args = ["fmt", "--stdin"] }
736formatter = { command = "zig" , args = ["fmt", "--stdin"] }
737
737
738−
739[[grammar]]
738[[grammar]]
740name = "zig"
739name = "zig"
741−source = { git = "https://github.com/maxxnino/tree-sitter-zig", rev = "93331b8bd8b4ebee2b575490b2758f16ad4e9f30" }
740+source = { git = "https://github.com/maxxnino/tree-sitter-zig", rev = "8d3224c3bd0890fe08358886ebf54fca2ed448a6" }
742
741
743[[language]]
742[[language]]
744name = "prolog"
743name = "prolog"
runtime/queries/zig/highlights.scm+45−51
@@ -1,20 +1,11 @@
1[
1[
2 (container_doc_comment)
2 (container_doc_comment)
3 (doc_comment)
3 (doc_comment)
4− (line_comment)
5−] @comment
4+] @comment.documentation
6
5
7[
6[
8− variable: (IDENTIFIER)
7+ (line_comment)
9− variable_type_function: (IDENTIFIER)
8+] @comment.line
10−] @variable
11−
12−parameter: (IDENTIFIER) @variable.parameter
13−
14−[
15− field_member: (IDENTIFIER)
16− field_access: (IDENTIFIER)
17−] @variable.other.member
18
9
19;; assume TitleCase is a type
10;; assume TitleCase is a type
20(
11(
@@ -25,6 +16,7 @@ parameter: (IDENTIFIER) @variable.parameter
25 ] @type
16 ] @type
26 (#match? @type "^[A-Z]([a-z]+[A-Za-z0-9]*)*$")
17 (#match? @type "^[A-Z]([a-z]+[A-Za-z0-9]*)*$")
27)
18)
19+
28;; assume camelCase is a function
20;; assume camelCase is a function
29(
21(
30 [
22 [
@@ -44,29 +36,33 @@ parameter: (IDENTIFIER) @variable.parameter
44 (#match? @constant "^[A-Z][A-Z_0-9]+$")
36 (#match? @constant "^[A-Z][A-Z_0-9]+$")
45)
37)
46
38
47−[
39+;; _
48− function_call: (IDENTIFIER)
49− function: (IDENTIFIER)
50−] @function
51−
52−exception: "!" @function.macro
53−
54(
40(
55 (IDENTIFIER) @variable.builtin
41 (IDENTIFIER) @variable.builtin
56 (#eq? @variable.builtin "_")
42 (#eq? @variable.builtin "_")
57)
43)
58
44
45+;; C Pointers [*c]T
59(PtrTypeStart "c" @variable.builtin)
46(PtrTypeStart "c" @variable.builtin)
60
47
61−(
48+[
62− (ContainerDeclType
49+ variable: (IDENTIFIER)
50+ variable_type_function: (IDENTIFIER)
51+] @variable
52+
53+parameter: (IDENTIFIER) @variable.parameter
54+
63− [
55+[
64− (ErrorUnionExpr)
56+ field_member: (IDENTIFIER)
65− "enum"
57+ field_access: (IDENTIFIER)
66− ]
58+] @variable.other.member
67− )
59+
60+[
61+ function_call: (IDENTIFIER)
68− (ContainerField (IDENTIFIER) @constant)
62+ function: (IDENTIFIER)
69−)
63+] @function
64+
65+exception: "!" @keyword.control.exception
70
66
71field_constant: (IDENTIFIER) @constant
67field_constant: (IDENTIFIER) @constant
72
68
@@ -89,8 +85,6 @@ field_constant: (IDENTIFIER) @constant
89(FormatSequence) @string.special
85(FormatSequence) @string.special
90
86
91[
87[
92− "allowzero"
93− "volatile"
94 "anytype"
88 "anytype"
95 "anyframe"
89 "anyframe"
96 (BuildinTypeExpr)
90 (BuildinTypeExpr)
@@ -125,44 +119,53 @@ field_constant: (IDENTIFIER) @constant
125 "or"
119 "or"
126 "and"
120 "and"
127 "orelse"
121 "orelse"
128−] @operator
122+] @keyword.operator
129
123
130[
124[
131 "struct"
125 "struct"
132 "enum"
126 "enum"
133 "union"
127 "union"
134− "error"
135 "packed"
128 "packed"
136 "opaque"
129 "opaque"
130+ "export"
131+ "extern"
132+ "linksection"
137−] @keyword
133+] @keyword.storage.type
134+
135+[
136+ "const"
137+ "var"
138+ "threadlocal"
139+ "allowzero"
140+ "volatile"
141+ "align"
142+] @keyword.storage.modifier
138
143
139[
144[
140 "try"
145 "try"
141 "error"
146 "error"
142 "catch"
147 "catch"
143−] @function.macro
148+] @keyword.control.exception
144
149
145−; VarDecl
146[
150[
147− "threadlocal"
148 "fn"
151 "fn"
149] @keyword.function
152] @keyword.function
150
153
151[
154[
152− "const"
153− "var"
154 "test"
155 "test"
156+] @keyword
157+
158+[
155 "pub"
159 "pub"
156 "usingnamespace"
160 "usingnamespace"
157−] @keyword
161+] @keyword.control.import
158
162
159[
163[
160 "return"
164 "return"
161 "break"
165 "break"
162 "continue"
166 "continue"
163−] @keyword.control
167+] @keyword.control.return
164
168
165−; Macro
166[
169[
167 "defer"
170 "defer"
168 "errdefer"
171 "errdefer"
@@ -171,11 +174,8 @@ field_constant: (IDENTIFIER) @constant
171 "await"
174 "await"
172 "suspend"
175 "suspend"
173 "resume"
176 "resume"
174− "export"
175− "extern"
176] @function.macro
177] @function.macro
177
178
178−; PrecProc
179[
179[
180 "comptime"
180 "comptime"
181 "inline"
181 "inline"
@@ -185,11 +185,6 @@ field_constant: (IDENTIFIER) @constant
185 "noalias"
185 "noalias"
186] @keyword.directive
186] @keyword.directive
187
187
188−[
189− "linksection"
190− "align"
191−] @function.builtin
192−
193[
188[
194 (CompareOp)
189 (CompareOp)
195 (BitwiseOp)
190 (BitwiseOp)
@@ -230,5 +225,4 @@ field_constant: (IDENTIFIER) @constant
230 (PtrIndexPayload "|")
225 (PtrIndexPayload "|")
231] @punctuation.bracket
226] @punctuation.bracket
232
227
233−; Error
234−(ERROR) @keyword
228+(ERROR) @keyword.control.exception