1(type_identifier) @type
2(primitive_type) @type.builtin
3(self) @variable.special
4(field_identifier) @property
5
6(trait_item name: (type_identifier) @type.interface)
7(impl_item trait: (type_identifier) @type.interface)
8(abstract_type trait: (type_identifier) @type.interface)
9(dynamic_type trait: (type_identifier) @type.interface)
10(trait_bounds (type_identifier) @type.interface)
11
12(call_expression
13 function: [
14 (identifier) @function
15 (scoped_identifier
16 name: (identifier) @function)
17 (field_expression
18 field: (field_identifier) @function.method)
19 ])
20
21(generic_function
22 function: [
23 (identifier) @function
24 (scoped_identifier
25 name: (identifier) @function)
26 (field_expression
27 field: (field_identifier) @function.method)
28 ])
29
30(function_item name: (identifier) @function.definition)
31(function_signature_item name: (identifier) @function.definition)
32
33(macro_invocation
34 macro: [
35 (identifier) @function.special
36 (scoped_identifier
37 name: (identifier) @function.special)
38 ])
39
40(macro_definition
41 name: (identifier) @function.special.definition)
42
43; Identifier conventions
44
45; Assume uppercase names are types/enum-constructors
46((identifier) @type
47 (#match? @type "^[A-Z]"))
48
49; Assume all-caps names are constants
50((identifier) @constant
51 (#match? @constant "^_*[A-Z][A-Z\\d_]*$"))
52
53[
54 "("
55 ")"
56 "{"
57 "}"
58 "["
59 "]"
60] @punctuation.bracket
61
62(_
63 .
64 "<" @punctuation.bracket
65 ">" @punctuation.bracket)
66
67[
68 ";"
69 ","
70 "::"
71] @punctuation.delimiter
72
73[
74 "#"
75] @punctuation.special
76
77[
78 "as"
79 "async"
80 "await"
81 "break"
82 "const"
83 "continue"
84 "default"
85 "dyn"
86 "else"
87 "enum"
88 "extern"
89 "fn"
90 "for"
91 "if"
92 "impl"
93 "in"
94 "let"
95 "loop"
96 "macro_rules!"
97 "match"
98 "mod"
99 "move"
100 "pub"
101 "ref"
102 "return"
103 "static"
104 "struct"
105 "trait"
106 "type"
107 "union"
108 "unsafe"
109 "use"
110 "where"
111 "while"
112 "yield"
113 (crate)
114 (mutable_specifier)
115 (super)
116] @keyword
117
118[
119 (string_literal)
120 (raw_string_literal)
121 (char_literal)
122] @string
123
124[
125 (integer_literal)
126 (float_literal)
127] @number
128
129(boolean_literal) @constant
130
131[
132 (line_comment)
133 (block_comment)
134] @comment
135
136[
137 "!"
138 "!="
139 "%"
140 "%="
141 "&"
142 "&="
143 "&&"
144 "*"
145 "*="
146 "*"
147 "+"
148 "+="
149 ","
150 "-"
151 "-="
152 "->"
153 "."
154 ".."
155 "..="
156 "..."
157 "/"
158 "/="
159 ":"
160 ";"
161 "<<"
162 "<<="
163 "<"
164 "<="
165 "="
166 "=="
167 "=>"
168 ">"
169 ">="
170 ">>"
171 ">>="
172 "@"
173 "^"
174 "^="
175 "|"
176 "|="
177 "||"
178 "?"
179] @operator
180
181(lifetime) @lifetime