|
| 1 | +; identifiers |
| 2 | +; ----------- |
| 3 | +(identifier) @variable |
| 4 | +(yul_identifier) @variable |
| 5 | + |
| 6 | +; Pragma |
| 7 | +(pragma_directive) @tag |
| 8 | +(solidity_version_comparison_operator _ @tag) |
| 9 | + |
| 10 | +; Literals |
| 11 | +; -------- |
| 12 | + |
| 13 | +[ |
| 14 | + (string) |
| 15 | + (hex_string_literal) |
| 16 | + (unicode_string_literal) |
| 17 | + (yul_string_literal) |
| 18 | +] @string |
| 19 | +[ |
| 20 | + (number_literal) |
| 21 | + (yul_decimal_number) |
| 22 | + (yul_hex_number) |
| 23 | +] @number |
| 24 | +[ |
| 25 | + (true) |
| 26 | + (false) |
| 27 | +] @constant.builtin |
| 28 | + |
| 29 | +(comment) @comment |
| 30 | + |
| 31 | +; Definitions and references |
| 32 | +; ----------- |
| 33 | + |
| 34 | +(type_name) @type |
| 35 | +(primitive_type) @type |
| 36 | +(user_defined_type (identifier) @type) |
| 37 | + |
| 38 | +(payable_conversion_expression "payable" @type) |
| 39 | +; Ensures that delimiters in mapping( ... => .. ) are not colored like types |
| 40 | +(type_name "(" @punctuation.bracket "=>" @punctuation.delimiter ")" @punctuation.bracket) |
| 41 | + |
| 42 | +; Definitions |
| 43 | +(struct_declaration |
| 44 | + name: (identifier) @type) |
| 45 | +(enum_declaration |
| 46 | + name: (identifier) @type) |
| 47 | +(contract_declaration |
| 48 | + name: (identifier) @type) |
| 49 | +(library_declaration |
| 50 | + name: (identifier) @type) |
| 51 | +(interface_declaration |
| 52 | + name: (identifier) @type) |
| 53 | +(event_definition |
| 54 | + name: (identifier) @type) |
| 55 | + |
| 56 | +(function_definition |
| 57 | + name: (identifier) @function) |
| 58 | + |
| 59 | +(modifier_definition |
| 60 | + name: (identifier) @function) |
| 61 | +(yul_evm_builtin) @function.builtin |
| 62 | + |
| 63 | +; Use contructor coloring for special functions |
| 64 | +(constructor_definition "constructor" @constructor) |
| 65 | +(fallback_receive_definition "receive" @constructor) |
| 66 | +(fallback_receive_definition "fallback" @constructor) |
| 67 | + |
| 68 | +(struct_member name: (identifier) @property) |
| 69 | +(enum_value) @constant |
| 70 | + |
| 71 | +; Invocations |
| 72 | +(emit_statement . (identifier) @type) |
| 73 | +(modifier_invocation (identifier) @function) |
| 74 | + |
| 75 | +(call_expression . (member_expression property: (identifier) @function.method)) |
| 76 | +(call_expression . (identifier) @function) |
| 77 | + |
| 78 | +; Function parameters |
| 79 | +(call_struct_argument name: (identifier) @field) |
| 80 | +(event_paramater name: (identifier) @parameter) |
| 81 | +(parameter name: (identifier) @variable.parameter) |
| 82 | + |
| 83 | +; Yul functions |
| 84 | +(yul_function_call function: (yul_identifier) @function) |
| 85 | +(yul_function_definition . (yul_identifier) @function (yul_identifier) @parameter) |
| 86 | + |
| 87 | + |
| 88 | +; Structs and members |
| 89 | +(member_expression property: (identifier) @property) |
| 90 | +(struct_expression type: ((identifier) @type .)) |
| 91 | +(struct_field_assignment name: (identifier) @property) |
| 92 | + |
| 93 | + |
| 94 | +; Tokens |
| 95 | +; ------- |
| 96 | + |
| 97 | +; Keywords |
| 98 | +(meta_type_expression "type" @keyword) |
| 99 | +; Keywords |
| 100 | +[ |
| 101 | + "pragma" |
| 102 | + "contract" |
| 103 | + "interface" |
| 104 | + "library" |
| 105 | + "is" |
| 106 | + "struct" |
| 107 | + "enum" |
| 108 | + "event" |
| 109 | + "using" |
| 110 | + "assembly" |
| 111 | + "emit" |
| 112 | + "public" |
| 113 | + "internal" |
| 114 | + "private" |
| 115 | + "external" |
| 116 | + "pure" |
| 117 | + "view" |
| 118 | + "payable" |
| 119 | + "modifier" |
| 120 | + "memory" |
| 121 | + "storage" |
| 122 | + "calldata" |
| 123 | + "var" |
| 124 | + "constant" |
| 125 | + (virtual) |
| 126 | + (override_specifier) |
| 127 | + (yul_leave) |
| 128 | +] @keyword |
| 129 | + |
| 130 | +[ |
| 131 | + "for" |
| 132 | + "while" |
| 133 | + "do" |
| 134 | +] @repeat |
| 135 | + |
| 136 | +[ |
| 137 | + "break" |
| 138 | + "continue" |
| 139 | + "if" |
| 140 | + "else" |
| 141 | + "switch" |
| 142 | + "case" |
| 143 | + "default" |
| 144 | +] @conditional |
| 145 | + |
| 146 | +[ |
| 147 | + "try" |
| 148 | + "catch" |
| 149 | +] @exception |
| 150 | + |
| 151 | +[ |
| 152 | + "return" |
| 153 | + "returns" |
| 154 | +] @keyword.return |
| 155 | + |
| 156 | +"function" @keyword.function |
| 157 | + |
| 158 | +"import" @include |
| 159 | +(import_directive "as" @include) |
| 160 | +(import_directive "from" @include) |
| 161 | + |
| 162 | +(event_paramater "indexed" @keyword) |
| 163 | + |
| 164 | +; Punctuation |
| 165 | + |
| 166 | +[ |
| 167 | + "(" |
| 168 | + ")" |
| 169 | + "[" |
| 170 | + "]" |
| 171 | + "{" |
| 172 | + "}" |
| 173 | +] @punctuation.bracket |
| 174 | + |
| 175 | + |
| 176 | +[ |
| 177 | + "." |
| 178 | + "," |
| 179 | +] @punctuation.delimiter |
| 180 | + |
| 181 | + |
| 182 | +; Operators |
| 183 | + |
| 184 | +[ |
| 185 | + "&&" |
| 186 | + "||" |
| 187 | + ">>" |
| 188 | + ">>>" |
| 189 | + "<<" |
| 190 | + "&" |
| 191 | + "^" |
| 192 | + "|" |
| 193 | + "+" |
| 194 | + "-" |
| 195 | + "*" |
| 196 | + "/" |
| 197 | + "%" |
| 198 | + "**" |
| 199 | + "<" |
| 200 | + "<=" |
| 201 | + "==" |
| 202 | + "!=" |
| 203 | + "!==" |
| 204 | + ">=" |
| 205 | + ">" |
| 206 | + "!" |
| 207 | + "~" |
| 208 | + "-" |
| 209 | + "+" |
| 210 | + "++" |
| 211 | + "--" |
| 212 | +] @operator |
| 213 | + |
| 214 | +[ |
| 215 | + "delete" |
| 216 | + "new" |
| 217 | +] @keyword.operator |
0 commit comments