@@ -1,10 +1,28 @@
11; Identifier conventions
22
3+
34; Assume all-caps names are constants
45((identifier) @constant
56 (#match? @constant "^[A-Z][A-Z\\d_]+$'"))
67
8+; Assume other uppercase names are enum constructors
9+((identifier) @constructor
10+ (#match? @constructor "^[A-Z]"))
11+
712; Assume that uppercase names in paths are types
13+(mod_item
14+ name: (identifier) @namespace)
15+(scoped_identifier
16+ path: (identifier) @namespace)
17+(scoped_identifier
18+ (scoped_identifier
19+ name: (identifier) @namespace))
20+(scoped_type_identifier
21+ path: (identifier) @namespace)
22+(scoped_type_identifier
23+ (scoped_identifier
24+ name: (identifier) @namespace))
25+
826((scoped_identifier
927 path: (identifier) @type)
1028 (#match? @type "^[A-Z]"))
@@ -13,9 +31,15 @@
1331 name: (identifier) @type))
1432 (#match? @type "^[A-Z]"))
1533
16−; Assume other uppercase names are enum constructors
17−((identifier) @constructor
18− (#match? @constructor "^[A-Z]"))
34+; Namespaces
35+
36+(crate) @namespace
37+(scoped_use_list
38+ path: (identifier) @namespace)
39+(scoped_use_list
40+ path: (scoped_identifier
41+ (identifier) @namespace))
42+(use_list (scoped_identifier (identifier) @namespace . (_)))
1943
2044; Function calls
2145
@@ -38,9 +62,19 @@
3862 function: (field_expression
3963 field: (field_identifier) @function.method))
4064
65+; (macro_invocation
66+; macro: (identifier) @function.macro
67+; "!" @function.macro)
68+(macro_invocation
69+ macro: (identifier) @function.macro)
4170(macro_invocation
42− macro: (identifier) @function.macro
43− "!" @function.macro)
71+ macro: (scoped_identifier
72+ (identifier) @function.macro .))
73+
74+; (metavariable) @variable
75+(metavariable) @function.macro
76+
77+"$" @function.macro
4478
4579; Function definitions
4680
@@ -73,6 +107,7 @@
73107";" @punctuation.delimiter
74108
75109(parameter (identifier) @variable.parameter)
110+(closure_parameters (_) @variable.parameter)
76111
77112(lifetime (identifier) @label)
78113
@@ -114,9 +149,9 @@
114149(scoped_use_list (self) @keyword)
115150(scoped_identifier (self) @keyword)
116151(super) @keyword
152+"as" @keyword
117153
118154(self) @variable.builtin
119−(metavariable) @variable
120155
121156[
122157(char_literal)
@@ -133,7 +168,44 @@
133168(attribute_item) @attribute
134169(inner_attribute_item) @attribute
135170
136−"as" @operator
137−"*" @operator
138−"&" @operator
139−"'" @operator
171+[
172+"*"
173+"'"
174+"->"
175+"=>"
176+"<="
177+"="
178+"=="
179+"!"
180+"!="
181+"%"
182+"%="
183+"&"
184+"&="
185+"&&"
186+"|"
187+"|="
188+"||"
189+"^"
190+"^="
191+"*"
192+"*="
193+"-"
194+"-="
195+"+"
196+"+="
197+"/"
198+"/="
199+">"
200+"<"
201+">="
202+">>"
203+"<<"
204+">>="
205+"@"
206+".."
207+"..="
208+"'"
209+] @operator
210+
211+"?" @special