@@ -0,0 +1,135 @@
1+; Identifier conventions
2+
3+; Assume all-caps names are constants
4+((identifier) @constant
5+ (#match? @constant "^[A-Z][A-Z\\d_]+$'"))
6+
7+; Assume that uppercase names in paths are types
8+((scoped_identifier
9+ path: (identifier) @type)
10+ (#match? @type "^[A-Z]"))
11+((scoped_identifier
12+ path: (scoped_identifier
13+ name: (identifier) @type))
14+ (#match? @type "^[A-Z]"))
15+
16+; Assume other uppercase names are enum constructors
17+((identifier) @constructor
18+ (#match? @constructor "^[A-Z]"))
19+
20+; Function calls
21+
22+(call_expression
23+ function: (identifier) @function)
24+(call_expression
25+ function: (field_expression
26+ field: (field_identifier) @function.method))
27+(call_expression
28+ function: (scoped_identifier
29+ "::"
30+ name: (identifier) @function))
31+
32+(generic_function
33+ function: (identifier) @function)
34+(generic_function
35+ function: (scoped_identifier
36+ name: (identifier) @function))
37+(generic_function
38+ function: (field_expression
39+ field: (field_identifier) @function.method))
40+
41+(macro_invocation
42+ macro: (identifier) @function.macro
43+ "!" @function.macro)
44+
45+; Function definitions
46+
47+(function_item (identifier) @function)
48+(function_signature_item (identifier) @function)
49+
50+; Other identifiers
51+
52+(type_identifier) @type
53+(primitive_type) @type.builtin
54+(field_identifier) @property
55+
56+(line_comment) @comment
57+(block_comment) @comment
58+
59+"(" @punctuation.bracket
60+")" @punctuation.bracket
61+"[" @punctuation.bracket
62+"]" @punctuation.bracket
63+
64+(type_arguments
65+ "<" @punctuation.bracket
66+ ">" @punctuation.bracket)
67+(type_parameters
68+ "<" @punctuation.bracket
69+ ">" @punctuation.bracket)
70+
71+"::" @punctuation.delimiter
72+"." @punctuation.delimiter
73+";" @punctuation.delimiter
74+
75+(parameter (identifier) @variable.parameter)
76+
77+(lifetime (identifier) @label)
78+
79+"break" @keyword
80+"const" @keyword
81+"continue" @keyword
82+"default" @keyword
83+"dyn" @keyword
84+"else" @keyword
85+"enum" @keyword
86+"extern" @keyword
87+"fn" @keyword
88+"for" @keyword
89+"if" @keyword
90+"impl" @keyword
91+"in" @keyword
92+"let" @keyword
93+"let" @keyword
94+"loop" @keyword
95+"macro_rules!" @keyword
96+"match" @keyword
97+"mod" @keyword
98+"move" @keyword
99+"pub" @keyword
100+"ref" @keyword
101+"return" @keyword
102+"static" @keyword
103+"struct" @keyword
104+"trait" @keyword
105+"type" @keyword
106+"union" @keyword
107+"unsafe" @keyword
108+"use" @keyword
109+"where" @keyword
110+"while" @keyword
111+(mutable_specifier) @keyword
112+(use_list (self) @keyword)
113+(scoped_use_list (self) @keyword)
114+(scoped_identifier (self) @keyword)
115+(super) @keyword
116+
117+(self) @variable.builtin
118+
119+(char_literal) @string
120+(string_literal) @string
121+(raw_string_literal) @string
122+
123+(boolean_literal) @constant.builtin
124+(integer_literal) @constant.builtin
125+(float_literal) @constant.builtin
126+
127+(escape_sequence) @escape
128+
129+(attribute_item) @attribute
130+(inner_attribute_item) @attribute
131+
132+"as" @operator
133+"*" @operator
134+"&" @operator
135+"'" @operator