|
2 | 2 | (pragma_directive) @keyword.directive |
3 | 3 | (solidity_version_comparison_operator _ @keyword.directive) |
4 | 4 |
|
5 | | - |
6 | 5 | ; Literals |
7 | 6 | ; -------- |
8 | | - |
9 | 7 | [ |
10 | 8 | (string) |
11 | 9 | (hex_string_literal) |
|
27 | 25 |
|
28 | 26 | (comment) @comment |
29 | 27 |
|
30 | | - |
31 | 28 | ; Definitions and references |
32 | 29 | ; ----------- |
33 | | - |
34 | 30 | (type_name) @type |
35 | 31 |
|
36 | 32 | [ |
37 | 33 | (primitive_type) |
38 | 34 | (number_unit) |
39 | 35 | ] @type.builtin |
40 | 36 |
|
41 | | -(user_defined_type (identifier) @type) |
| 37 | +(user_defined_type (_) @type) |
| 38 | +(user_defined_type_definition name: (identifier) @type) |
42 | 39 | (type_alias (identifier) @type) |
43 | 40 |
|
44 | 41 | ; Color payable in payable address conversion as type and not as keyword |
|
47 | 44 | (type_name "(" @punctuation.bracket "=>" @punctuation.delimiter ")" @punctuation.bracket) |
48 | 45 |
|
49 | 46 | ; Definitions |
50 | | -(struct_declaration |
51 | | - name: (identifier) @type) |
52 | | -(enum_declaration |
53 | | - name: (identifier) @type) |
54 | | -(contract_declaration |
55 | | - name: (identifier) @type) |
56 | | -(library_declaration |
57 | | - name: (identifier) @type) |
58 | | -(interface_declaration |
59 | | - name: (identifier) @type) |
60 | | -(event_definition |
61 | | - name: (identifier) @type) |
62 | | - |
63 | | -(function_definition |
64 | | - name: (identifier) @function) |
65 | | - |
66 | | -(modifier_definition |
67 | | - name: (identifier) @function) |
| 47 | +(struct_declaration name: (identifier) @type) |
| 48 | +(enum_declaration name: (identifier) @type) |
| 49 | +(contract_declaration name: (identifier) @type) |
| 50 | +(library_declaration name: (identifier) @type) |
| 51 | +(interface_declaration name: (identifier) @type) |
| 52 | +(event_definition name: (identifier) @type) |
| 53 | +(error_declaration name: (identifier) @type) |
| 54 | +(function_definition name: (identifier) @function) |
| 55 | +(modifier_definition name: (identifier) @function) |
68 | 56 | (yul_evm_builtin) @function.builtin |
69 | 57 |
|
70 | 58 | ; Use constructor coloring for special functions |
|
75 | 63 |
|
76 | 64 | (struct_member name: (identifier) @variable.other.member) |
77 | 65 | (enum_value) @constant |
| 66 | +; SCREAMING_SNAKE_CASE identifier are constants |
| 67 | +((identifier) @constant (#match? @constant "^[A-Z][A-Z_]+$")) |
78 | 68 |
|
79 | 69 | ; Invocations |
80 | | -(emit_statement . (identifier) @type) |
81 | | -(revert_statement error: (identifier) @type) |
82 | | -(modifier_invocation (identifier) @function) |
| 70 | +(emit_statement name: (expression (identifier) @type)) |
| 71 | +(revert_statement error: (expression (identifier) @type)) |
| 72 | +(modifier_invocation . (_) @function) |
83 | 73 |
|
84 | | -(call_expression . (member_expression property: (identifier) @function.method)) |
85 | | -(call_expression . (identifier) @function) |
| 74 | +(call_expression . (_(member_expression property: (_) @function.method))) |
| 75 | +(call_expression . (expression (identifier) @function)) |
86 | 76 |
|
87 | 77 | ; Function parameters |
88 | 78 | (call_struct_argument name: (identifier) @field) |
89 | 79 | (event_parameter name: (identifier) @variable.parameter) |
90 | 80 | (parameter name: (identifier) @variable.parameter) |
91 | 81 |
|
92 | 82 | ; Yul functions |
93 | | -(yul_function_call function: (yul_identifier) @function) |
94 | | -(yul_function_definition . (yul_identifier) @function (yul_identifier) @variable.parameter) |
95 | | - |
| 83 | +(yul_function_call function: (_) @function) |
| 84 | +(yul_function_definition |
| 85 | + ("function" (yul_identifier) @function "(" ( |
| 86 | + (yul_identifier) @variable.parameter ("," (yul_identifier) @variable.parameter)* |
| 87 | + ) |
| 88 | + ) |
| 89 | +) |
96 | 90 |
|
97 | 91 | ; Structs and members |
98 | 92 | (member_expression property: (identifier) @variable.other.member) |
99 | | -(struct_expression type: ((identifier) @type .)) |
| 93 | +(struct_expression type: ((expression (identifier)) @type .)) |
100 | 94 | (struct_field_assignment name: (identifier) @variable.other.member) |
101 | 95 |
|
| 96 | + |
102 | 97 | ; Tokens |
103 | 98 | ; ------- |
104 | 99 |
|
|
113 | 108 | "struct" |
114 | 109 | "enum" |
115 | 110 | "event" |
| 111 | + "type" |
116 | 112 | "assembly" |
117 | 113 | "emit" |
118 | | - |
119 | 114 | "public" |
120 | 115 | "internal" |
121 | 116 | "private" |
122 | 117 | "external" |
123 | 118 | "pure" |
124 | 119 | "view" |
125 | 120 | "payable" |
126 | | - |
127 | 121 | "modifier" |
128 | 122 | "var" |
129 | 123 | "let" |
|
137 | 131 | "storage" |
138 | 132 | "calldata" |
139 | 133 | "constant" |
| 134 | + "transient" |
| 135 | + (immutable) |
140 | 136 | ] @keyword.storage.modifier |
141 | 137 |
|
142 | 138 | [ |
|
175 | 171 | (event_parameter "indexed" @keyword) |
176 | 172 |
|
177 | 173 | ; Punctuation |
178 | | - |
179 | 174 | [ |
180 | 175 | "(" |
181 | 176 | ")" |
|
185 | 180 | "}" |
186 | 181 | ] @punctuation.bracket |
187 | 182 |
|
188 | | - |
189 | 183 | [ |
190 | 184 | "." |
191 | 185 | "," |
|
194 | 188 | "=>" |
195 | 189 | ] @punctuation.delimiter |
196 | 190 |
|
197 | | - |
198 | 191 | ; Operators |
199 | | - |
200 | 192 | [ |
201 | 193 | "&&" |
202 | 194 | "||" |
203 | 195 | ">>" |
204 | | - ">>>" |
205 | 196 | "<<" |
206 | 197 | "&" |
207 | 198 | "^" |
|
216 | 207 | "<=" |
217 | 208 | "==" |
218 | 209 | "!=" |
219 | | - "!==" |
220 | 210 | ">=" |
221 | 211 | ">" |
222 | 212 | "!" |
223 | 213 | "~" |
224 | 214 | "-" |
225 | 215 | "+" |
226 | | - "delete" |
227 | | - "new" |
228 | 216 | "++" |
229 | 217 | "--" |
230 | 218 | "+=" |
|
244 | 232 | "new" |
245 | 233 | ] @keyword.operator |
246 | 234 |
|
247 | | -; TODO: move to top when order swapped |
248 | 235 | ; identifiers |
249 | 236 | ; ----------- |
250 | | -((identifier) @variable.builtin |
251 | | - (#match? @variable.builtin "^(this|msg|block|tx)$")) |
| 237 | +((identifier) @variable.builtin (#any-of? @variable.builtin "this" "msg" "block" "tx")) |
252 | 238 | (identifier) @variable |
253 | 239 | (yul_identifier) @variable |
| 240 | + |
0 commit comments