@@ -1,10 +1,28 @@
1; Identifier conventions
1; Identifier conventions
3; Assume all-caps names are constants
4; Assume all-caps names are constants
4((identifier) @constant
5((identifier) @constant
5 (#match? @constant "^[A-Z][A-Z\\d_]+$'"))
6 (#match? @constant "^[A-Z][A-Z\\d_]+$'"))
8+; Assume other uppercase names are enum constructors
9+((identifier) @constructor
10+ (#match? @constructor "^[A-Z]"))
7; Assume that uppercase names in paths are types
12; Assume that uppercase names in paths are types
14+ name: (identifier) @namespace)
16+ path: (identifier) @namespace)
19+ name: (identifier) @namespace))
20+(scoped_type_identifier
21+ path: (identifier) @namespace)
22+(scoped_type_identifier
24+ name: (identifier) @namespace))
8((scoped_identifier
26((scoped_identifier
9 path: (identifier) @type)
27 path: (identifier) @type)
10 (#match? @type "^[A-Z]"))
28 (#match? @type "^[A-Z]"))
@@ -13,9 +31,15 @@
13 name: (identifier) @type))
31 name: (identifier) @type))
14 (#match? @type "^[A-Z]"))
32 (#match? @type "^[A-Z]"))
16−; Assume other uppercase names are enum constructors
34+; Namespaces
38+ path: (identifier) @namespace)
40+ path: (scoped_identifier
17−((identifier) @constructor
41+ (identifier) @namespace))
18− (#match? @constructor "^[A-Z]"))
42+(use_list (scoped_identifier (identifier) @namespace . (_)))
20; Function calls
44; Function calls
@@ -38,9 +62,19 @@
38 function: (field_expression
62 function: (field_expression
39 field: (field_identifier) @function.method))
63 field: (field_identifier) @function.method))
66+; macro: (identifier) @function.macro
67+; "!" @function.macro)
69+ macro: (identifier) @function.macro)
41(macro_invocation
70(macro_invocation
71+ macro: (scoped_identifier
42− macro: (identifier) @function.macro
72+ (identifier) @function.macro .))
74+; (metavariable) @variable
75+(metavariable) @function.macro
43− "!" @function.macro)
77+"$" @function.macro
45; Function definitions
79; Function definitions
@@ -73,6 +107,7 @@
73";" @punctuation.delimiter
107";" @punctuation.delimiter
75(parameter (identifier) @variable.parameter)
109(parameter (identifier) @variable.parameter)
110+(closure_parameters (_) @variable.parameter)
77(lifetime (identifier) @label)
112(lifetime (identifier) @label)
@@ -114,9 +149,9 @@
114(scoped_use_list (self) @keyword)
149(scoped_use_list (self) @keyword)
115(scoped_identifier (self) @keyword)
150(scoped_identifier (self) @keyword)
116(super) @keyword
151(super) @keyword
118(self) @variable.builtin
154(self) @variable.builtin
119−(metavariable) @variable
122(char_literal)
157(char_literal)
@@ -133,7 +168,44 @@
133(attribute_item) @attribute
168(attribute_item) @attribute
134(inner_attribute_item) @attribute
169(inner_attribute_item) @attribute
139−"'" @operator
209+] @operator