Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'runtime/queries/solidity/highlights.scm')
| -rw-r--r-- | runtime/queries/solidity/highlights.scm | 89 |
1 files changed, 50 insertions, 39 deletions
diff --git a/runtime/queries/solidity/highlights.scm b/runtime/queries/solidity/highlights.scm index 0e49429d..73f354a2 100644 --- a/runtime/queries/solidity/highlights.scm +++ b/runtime/queries/solidity/highlights.scm @@ -1,23 +1,17 @@ -; identifiers -; ----------- -(identifier) @variable -((identifier) @variable.builtin (#any-of? @variable.builtin "this" "msg" "block" "tx")) -(yul_identifier) @variable - ; Pragma (pragma_directive) @keyword.directive (solidity_version_comparison_operator _ @keyword.directive) + ; Literals ; -------- + [ (string) (hex_string_literal) (unicode_string_literal) (yul_string_literal) ] @string -(hex_string_literal "hex" @string.special.symbol) -(unicode_string_literal "unicode" @string.special.symbol) [ (number_literal) (yul_decimal_number) @@ -26,13 +20,14 @@ [ (true) (false) - (yul_boolean) ] @constant.builtin.boolean (comment) @comment + ; Definitions and references ; ----------- + (type_name) @type [ @@ -40,8 +35,7 @@ (number_unit) ] @type.builtin -(user_defined_type (_) @type) -(user_defined_type_definition name: (identifier) @type) +(user_defined_type (identifier) @type) (type_alias (identifier) @type) ; Color payable in payable address conversion as type and not as keyword @@ -50,15 +44,24 @@ (type_name "(" @punctuation.bracket "=>" @punctuation.delimiter ")" @punctuation.bracket) ; Definitions -(struct_declaration name: (identifier) @type) -(enum_declaration name: (identifier) @type) -(contract_declaration name: (identifier) @type) -(library_declaration name: (identifier) @type) -(interface_declaration name: (identifier) @type) -(event_definition name: (identifier) @type) -(error_declaration name: (identifier) @type) -(function_definition name: (identifier) @function) -(modifier_definition name: (identifier) @function) +(struct_declaration + name: (identifier) @type) +(enum_declaration + name: (identifier) @type) +(contract_declaration + name: (identifier) @type) +(library_declaration + name: (identifier) @type) +(interface_declaration + name: (identifier) @type) +(event_definition + name: (identifier) @type) + +(function_definition + name: (identifier) @function) + +(modifier_definition + name: (identifier) @function) (yul_evm_builtin) @function.builtin ; Use constructor coloring for special functions @@ -69,16 +72,14 @@ (struct_member name: (identifier) @variable.other.member) (enum_value) @constant -; SCREAMING_SNAKE_CASE identifier are constants -((identifier) @constant (#match? @constant "^[A-Z][A-Z_]+$")) ; Invocations -(emit_statement name: (expression (identifier) @type)) -(revert_statement error: (expression (identifier) @type)) -(modifier_invocation . (_) @function) +(emit_statement . (identifier) @type) +(revert_statement error: (identifier) @type) +(modifier_invocation (identifier) @function) -(call_expression . (_(member_expression property: (_) @function.method))) -(call_expression . (expression (identifier) @function)) +(call_expression . (member_expression property: (identifier) @function.method)) +(call_expression . (identifier) @function) ; Function parameters (call_struct_argument name: (identifier) @field) @@ -86,20 +87,15 @@ (parameter name: (identifier) @variable.parameter) ; Yul functions -(yul_function_call function: (_) @function) -(yul_function_definition - ("function" (yul_identifier) @function "(" ( - (yul_identifier) @variable.parameter ("," (yul_identifier) @variable.parameter)* - ) - ) -) +(yul_function_call function: (yul_identifier) @function) +(yul_function_definition . (yul_identifier) @function (yul_identifier) @variable.parameter) + ; Structs and members (member_expression property: (identifier) @variable.other.member) -(struct_expression type: ((expression (identifier)) @type .)) +(struct_expression type: ((identifier) @type .)) (struct_field_assignment name: (identifier) @variable.other.member) - ; Tokens ; ------- @@ -114,9 +110,9 @@ "struct" "enum" "event" - "type" "assembly" "emit" + "public" "internal" "private" @@ -124,6 +120,7 @@ "pure" "view" "payable" + "modifier" "var" "let" @@ -137,8 +134,6 @@ "storage" "calldata" "constant" - "transient" - (immutable) ] @keyword.storage.modifier [ @@ -177,6 +172,7 @@ (event_parameter "indexed" @keyword) ; Punctuation + [ "(" ")" @@ -186,6 +182,7 @@ "}" ] @punctuation.bracket + [ "." "," @@ -194,11 +191,14 @@ "=>" ] @punctuation.delimiter + ; Operators + [ "&&" "||" ">>" + ">>>" "<<" "&" "^" @@ -213,12 +213,15 @@ "<=" "==" "!=" + "!==" ">=" ">" "!" "~" "-" "+" + "delete" + "new" "++" "--" "+=" @@ -237,3 +240,11 @@ "delete" "new" ] @keyword.operator + +; TODO: move to top when order swapped +; identifiers +; ----------- +((identifier) @variable.builtin + (#match? @variable.builtin "^(this|msg|block|tx)$")) +(identifier) @variable +(yul_identifier) @variable |