|
1 |
| -(comment) @comment |
| 1 | +; identifiers |
| 2 | +; ----------- |
| 3 | +(identifier) @variable |
| 4 | +(yul_identifier) @variable |
2 | 5 |
|
3 | 6 | ; Pragma
|
4 | 7 | (pragma_directive) @tag
|
5 |
| -(solidity_version_comparison_operator ">=" @tag) |
6 |
| -(solidity_version_comparison_operator "<=" @tag) |
7 |
| -(solidity_version_comparison_operator "=" @tag) |
8 |
| -(solidity_version_comparison_operator "~" @tag) |
9 |
| -(solidity_version_comparison_operator "^" @tag) |
| 8 | +(solidity_version_comparison_operator _ @tag) |
10 | 9 |
|
11 | 10 |
|
12 | 11 | ; Literals
|
| 12 | +; -------- |
| 13 | + |
13 | 14 | [
|
14 | 15 | (string)
|
15 | 16 | (hex_string_literal)
|
|
26 | 27 | (false)
|
27 | 28 | ] @constant.builtin
|
28 | 29 |
|
| 30 | +(comment) @comment |
| 31 | + |
| 32 | + |
| 33 | +; Definitions and references |
| 34 | +; ----------- |
29 | 35 |
|
30 |
| -; Type |
31 | 36 | (type_name) @type
|
32 | 37 | (primitive_type) @type
|
33 |
| -(struct_declaration struct_name: (identifier) @type) |
34 |
| -(enum_declaration enum_type_name: (identifier) @type) |
| 38 | +(user_defined_type (identifier) @type) |
| 39 | + |
35 | 40 | ; Color payable in payable address conversion as type and not as keyword
|
36 | 41 | (payable_conversion_expression "payable" @type)
|
37 |
| -(emit_statement . (identifier) @type) |
38 |
| -; Handles ContractA, ContractB in function foo() override(ContractA, contractB) {} |
39 |
| -(override_specifier (identifier) @type) |
40 | 42 | ; Ensures that delimiters in mapping( ... => .. ) are not colored like types
|
41 | 43 | (type_name "(" @punctuation.bracket "=>" @punctuation.delimiter ")" @punctuation.bracket)
|
42 | 44 |
|
43 |
| - |
44 |
| - |
45 |
| -; Functions and parameters |
| 45 | +; Definitions |
| 46 | +(struct_declaration |
| 47 | + name: (identifier) @type) |
| 48 | +(enum_declaration |
| 49 | + name: (identifier) @type) |
| 50 | +(contract_declaration |
| 51 | + name: (identifier) @type) |
| 52 | +(library_declaration |
| 53 | + name: (identifier) @type) |
| 54 | +(interface_declaration |
| 55 | + name: (identifier) @type) |
| 56 | +(event_definition |
| 57 | + name: (identifier) @type) |
46 | 58 |
|
47 | 59 | (function_definition
|
48 |
| - function_name: (identifier) @function) |
| 60 | + name: (identifier) @function) |
| 61 | + |
49 | 62 | (modifier_definition
|
50 | 63 | name: (identifier) @function)
|
51 | 64 | (yul_evm_builtin) @function.builtin
|
|
55 | 68 | (fallback_receive_definition "receive" @constructor)
|
56 | 69 | (fallback_receive_definition "fallback" @constructor)
|
57 | 70 |
|
58 |
| -(modifier_invocation (identifier) @function) |
| 71 | +(struct_member name: (identifier) @variable.other.member) |
| 72 | +(enum_value) @constant |
59 | 73 |
|
60 |
| -; Handles expressions like structVariable.g(); |
61 |
| -(call_expression . (member_expression (property_identifier) @function.method)) |
| 74 | +; Invocations |
| 75 | +(emit_statement . (identifier) @type) |
| 76 | +(modifier_invocation (identifier) @function) |
62 | 77 |
|
63 |
| -; Handles expressions like g(); |
| 78 | +(call_expression . (member_expression property: (identifier) @function.method)) |
64 | 79 | (call_expression . (identifier) @function)
|
65 | 80 |
|
66 | 81 | ; Function parameters
|
67 |
| -(event_paramater name: (identifier) @variable.parameter) ; TODO fix spelling once fixed upstream |
68 |
| -(function_definition |
69 |
| - function_name: (identifier) @variable.parameter) |
| 82 | +(call_struct_argument name: (identifier) @field) |
| 83 | +(event_paramater name: (identifier) @variable.parameter) |
| 84 | +(parameter name: (identifier) @variable.parameter) |
70 | 85 |
|
71 | 86 | ; Yul functions
|
72 | 87 | (yul_function_call function: (yul_identifier) @function)
|
73 |
| - |
74 |
| -; Yul function parameters |
75 | 88 | (yul_function_definition . (yul_identifier) @function (yul_identifier) @variable.parameter)
|
76 | 89 |
|
77 |
| -(meta_type_expression "type" @keyword) |
78 | 90 |
|
79 |
| -(member_expression (property_identifier) @variable.other.member) |
80 |
| -(property_identifier) @variable.other.member |
81 |
| -(struct_expression ((identifier) @variable.other.member . ":")) |
82 |
| -(enum_value) @variable.other.member |
| 91 | +; Structs and members |
| 92 | +(member_expression property: (identifier) @variable.other.member) |
| 93 | +(struct_expression type: ((identifier) @type .)) |
| 94 | +(struct_field_assignment name: (identifier) @variable.other.member) |
83 | 95 |
|
| 96 | +; Tokens |
| 97 | +; ------- |
84 | 98 |
|
85 | 99 | ; Keywords
|
| 100 | +(meta_type_expression "type" @keyword) |
86 | 101 | [
|
87 | 102 | "pragma"
|
88 |
| - "import" |
89 | 103 | "contract"
|
90 | 104 | "interface"
|
91 | 105 | "library"
|
|
95 | 109 | "event"
|
96 | 110 | "using"
|
97 | 111 | "assembly"
|
98 |
| - "switch" |
99 |
| - "case" |
100 |
| - "default" |
101 |
| - "break" |
102 |
| - "continue" |
103 |
| - "if" |
104 |
| - "else" |
105 |
| - "for" |
106 |
| - "while" |
107 |
| - "do" |
108 |
| - "try" |
109 |
| - "catch" |
110 |
| - "return" |
111 | 112 | "emit"
|
112 | 113 | "public"
|
113 | 114 | "internal"
|
|
117 | 118 | "view"
|
118 | 119 | "payable"
|
119 | 120 | "modifier"
|
120 |
| - "returns" |
121 | 121 | "memory"
|
122 | 122 | "storage"
|
123 | 123 | "calldata"
|
124 |
| - "function" |
125 | 124 | "var"
|
126 |
| - (constant) |
| 125 | + "constant" |
127 | 126 | (virtual)
|
128 | 127 | (override_specifier)
|
129 | 128 | (yul_leave)
|
130 | 129 | ] @keyword
|
131 | 130 |
|
132 |
| -(import_directive "as" @keyword) |
133 |
| -(import_directive "from" @keyword) |
| 131 | +[ |
| 132 | + "for" |
| 133 | + "while" |
| 134 | + "do" |
| 135 | +] @keyword.control.repeat |
| 136 | + |
| 137 | +[ |
| 138 | + "break" |
| 139 | + "continue" |
| 140 | + "if" |
| 141 | + "else" |
| 142 | + "switch" |
| 143 | + "case" |
| 144 | + "default" |
| 145 | +] @keyword.control.conditional |
| 146 | + |
| 147 | +[ |
| 148 | + "try" |
| 149 | + "catch" |
| 150 | +] @keyword.control.exception |
| 151 | + |
| 152 | +[ |
| 153 | + "return" |
| 154 | + "returns" |
| 155 | +] @keyword.control.return |
| 156 | + |
| 157 | +"function" @keyword.function |
| 158 | + |
| 159 | +"import" @keyword.control.import |
| 160 | +(import_directive "as" @keyword.control.import) |
| 161 | +(import_directive "from" @keyword.control.import) |
134 | 162 | (event_paramater "indexed" @keyword) ; TODO fix spelling once fixed upstream
|
135 | 163 |
|
136 | 164 | ; Punctuation
|
|
142 | 170 | "]"
|
143 | 171 | "{"
|
144 | 172 | "}"
|
145 |
| -] @punctuation.bracket |
| 173 | +] @punctuation.bracket |
146 | 174 |
|
147 | 175 |
|
148 | 176 | [
|
|
185 | 213 | "--"
|
186 | 214 | ] @operator
|
187 | 215 |
|
188 |
| -(identifier) @variable |
189 |
| -(yul_identifier) @variable |
| 216 | +[ |
| 217 | + "delete" |
| 218 | + "new" |
| 219 | +] @keyword.operator |
0 commit comments