mirror of https://github.com/helix-editor/helix
chore(solidity): update to newest grammar and fix queries (#12457)
parent
19f7bc9ecb
commit
29dda1403f
|
@ -1951,7 +1951,7 @@ language-servers = [ "solc" ]
|
||||||
|
|
||||||
[[grammar]]
|
[[grammar]]
|
||||||
name = "solidity"
|
name = "solidity"
|
||||||
source = { git = "https://github.com/JoranHonig/tree-sitter-solidity", rev = "08338dcee32603383fcef08f36321900bb7a354b" }
|
source = { git = "https://github.com/JoranHonig/tree-sitter-solidity", rev = "f7f5251a3f5b1d04f0799b3571b12918af177fc8" }
|
||||||
|
|
||||||
[[language]]
|
[[language]]
|
||||||
name = "gleam"
|
name = "gleam"
|
||||||
|
|
|
@ -2,10 +2,8 @@
|
||||||
(pragma_directive) @keyword.directive
|
(pragma_directive) @keyword.directive
|
||||||
(solidity_version_comparison_operator _ @keyword.directive)
|
(solidity_version_comparison_operator _ @keyword.directive)
|
||||||
|
|
||||||
|
|
||||||
; Literals
|
; Literals
|
||||||
; --------
|
; --------
|
||||||
|
|
||||||
[
|
[
|
||||||
(string)
|
(string)
|
||||||
(hex_string_literal)
|
(hex_string_literal)
|
||||||
|
@ -27,10 +25,8 @@
|
||||||
|
|
||||||
(comment) @comment
|
(comment) @comment
|
||||||
|
|
||||||
|
|
||||||
; Definitions and references
|
; Definitions and references
|
||||||
; -----------
|
; -----------
|
||||||
|
|
||||||
(type_name) @type
|
(type_name) @type
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -38,7 +34,8 @@
|
||||||
(number_unit)
|
(number_unit)
|
||||||
] @type.builtin
|
] @type.builtin
|
||||||
|
|
||||||
(user_defined_type (identifier) @type)
|
(user_defined_type (_) @type)
|
||||||
|
(user_defined_type_definition name: (identifier) @type)
|
||||||
(type_alias (identifier) @type)
|
(type_alias (identifier) @type)
|
||||||
|
|
||||||
; Color payable in payable address conversion as type and not as keyword
|
; Color payable in payable address conversion as type and not as keyword
|
||||||
|
@ -47,24 +44,15 @@
|
||||||
(type_name "(" @punctuation.bracket "=>" @punctuation.delimiter ")" @punctuation.bracket)
|
(type_name "(" @punctuation.bracket "=>" @punctuation.delimiter ")" @punctuation.bracket)
|
||||||
|
|
||||||
; Definitions
|
; Definitions
|
||||||
(struct_declaration
|
(struct_declaration name: (identifier) @type)
|
||||||
name: (identifier) @type)
|
(enum_declaration name: (identifier) @type)
|
||||||
(enum_declaration
|
(contract_declaration name: (identifier) @type)
|
||||||
name: (identifier) @type)
|
(library_declaration name: (identifier) @type)
|
||||||
(contract_declaration
|
(interface_declaration name: (identifier) @type)
|
||||||
name: (identifier) @type)
|
(event_definition name: (identifier) @type)
|
||||||
(library_declaration
|
(error_declaration name: (identifier) @type)
|
||||||
name: (identifier) @type)
|
(function_definition name: (identifier) @function)
|
||||||
(interface_declaration
|
(modifier_definition name: (identifier) @function)
|
||||||
name: (identifier) @type)
|
|
||||||
(event_definition
|
|
||||||
name: (identifier) @type)
|
|
||||||
|
|
||||||
(function_definition
|
|
||||||
name: (identifier) @function)
|
|
||||||
|
|
||||||
(modifier_definition
|
|
||||||
name: (identifier) @function)
|
|
||||||
(yul_evm_builtin) @function.builtin
|
(yul_evm_builtin) @function.builtin
|
||||||
|
|
||||||
; Use constructor coloring for special functions
|
; Use constructor coloring for special functions
|
||||||
|
@ -75,14 +63,16 @@
|
||||||
|
|
||||||
(struct_member name: (identifier) @variable.other.member)
|
(struct_member name: (identifier) @variable.other.member)
|
||||||
(enum_value) @constant
|
(enum_value) @constant
|
||||||
|
; SCREAMING_SNAKE_CASE identifier are constants
|
||||||
|
((identifier) @constant (#match? @constant "^[A-Z][A-Z_]+$"))
|
||||||
|
|
||||||
; Invocations
|
; Invocations
|
||||||
(emit_statement . (identifier) @type)
|
(emit_statement name: (expression (identifier) @type))
|
||||||
(revert_statement error: (identifier) @type)
|
(revert_statement error: (expression (identifier) @type))
|
||||||
(modifier_invocation (identifier) @function)
|
(modifier_invocation . (_) @function)
|
||||||
|
|
||||||
(call_expression . (member_expression property: (identifier) @function.method))
|
(call_expression . (_(member_expression property: (_) @function.method)))
|
||||||
(call_expression . (identifier) @function)
|
(call_expression . (expression (identifier) @function))
|
||||||
|
|
||||||
; Function parameters
|
; Function parameters
|
||||||
(call_struct_argument name: (identifier) @field)
|
(call_struct_argument name: (identifier) @field)
|
||||||
|
@ -90,15 +80,20 @@
|
||||||
(parameter name: (identifier) @variable.parameter)
|
(parameter name: (identifier) @variable.parameter)
|
||||||
|
|
||||||
; Yul functions
|
; Yul functions
|
||||||
(yul_function_call function: (yul_identifier) @function)
|
(yul_function_call function: (_) @function)
|
||||||
(yul_function_definition . (yul_identifier) @function (yul_identifier) @variable.parameter)
|
(yul_function_definition
|
||||||
|
("function" (yul_identifier) @function "(" (
|
||||||
|
(yul_identifier) @variable.parameter ("," (yul_identifier) @variable.parameter)*
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
; Structs and members
|
; Structs and members
|
||||||
(member_expression property: (identifier) @variable.other.member)
|
(member_expression property: (identifier) @variable.other.member)
|
||||||
(struct_expression type: ((identifier) @type .))
|
(struct_expression type: ((expression (identifier)) @type .))
|
||||||
(struct_field_assignment name: (identifier) @variable.other.member)
|
(struct_field_assignment name: (identifier) @variable.other.member)
|
||||||
|
|
||||||
|
|
||||||
; Tokens
|
; Tokens
|
||||||
; -------
|
; -------
|
||||||
|
|
||||||
|
@ -113,9 +108,9 @@
|
||||||
"struct"
|
"struct"
|
||||||
"enum"
|
"enum"
|
||||||
"event"
|
"event"
|
||||||
|
"type"
|
||||||
"assembly"
|
"assembly"
|
||||||
"emit"
|
"emit"
|
||||||
|
|
||||||
"public"
|
"public"
|
||||||
"internal"
|
"internal"
|
||||||
"private"
|
"private"
|
||||||
|
@ -123,7 +118,6 @@
|
||||||
"pure"
|
"pure"
|
||||||
"view"
|
"view"
|
||||||
"payable"
|
"payable"
|
||||||
|
|
||||||
"modifier"
|
"modifier"
|
||||||
"var"
|
"var"
|
||||||
"let"
|
"let"
|
||||||
|
@ -137,6 +131,8 @@
|
||||||
"storage"
|
"storage"
|
||||||
"calldata"
|
"calldata"
|
||||||
"constant"
|
"constant"
|
||||||
|
"transient"
|
||||||
|
(immutable)
|
||||||
] @keyword.storage.modifier
|
] @keyword.storage.modifier
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -175,7 +171,6 @@
|
||||||
(event_parameter "indexed" @keyword)
|
(event_parameter "indexed" @keyword)
|
||||||
|
|
||||||
; Punctuation
|
; Punctuation
|
||||||
|
|
||||||
[
|
[
|
||||||
"("
|
"("
|
||||||
")"
|
")"
|
||||||
|
@ -185,7 +180,6 @@
|
||||||
"}"
|
"}"
|
||||||
] @punctuation.bracket
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
|
||||||
[
|
[
|
||||||
"."
|
"."
|
||||||
","
|
","
|
||||||
|
@ -194,14 +188,11 @@
|
||||||
"=>"
|
"=>"
|
||||||
] @punctuation.delimiter
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
|
||||||
; Operators
|
; Operators
|
||||||
|
|
||||||
[
|
[
|
||||||
"&&"
|
"&&"
|
||||||
"||"
|
"||"
|
||||||
">>"
|
">>"
|
||||||
">>>"
|
|
||||||
"<<"
|
"<<"
|
||||||
"&"
|
"&"
|
||||||
"^"
|
"^"
|
||||||
|
@ -216,15 +207,12 @@
|
||||||
"<="
|
"<="
|
||||||
"=="
|
"=="
|
||||||
"!="
|
"!="
|
||||||
"!=="
|
|
||||||
">="
|
">="
|
||||||
">"
|
">"
|
||||||
"!"
|
"!"
|
||||||
"~"
|
"~"
|
||||||
"-"
|
"-"
|
||||||
"+"
|
"+"
|
||||||
"delete"
|
|
||||||
"new"
|
|
||||||
"++"
|
"++"
|
||||||
"--"
|
"--"
|
||||||
"+="
|
"+="
|
||||||
|
@ -244,10 +232,9 @@
|
||||||
"new"
|
"new"
|
||||||
] @keyword.operator
|
] @keyword.operator
|
||||||
|
|
||||||
; TODO: move to top when order swapped
|
|
||||||
; identifiers
|
; identifiers
|
||||||
; -----------
|
; -----------
|
||||||
((identifier) @variable.builtin
|
((identifier) @variable.builtin (#any-of? @variable.builtin "this" "msg" "block" "tx"))
|
||||||
(#match? @variable.builtin "^(this|msg|block|tx)$"))
|
|
||||||
(identifier) @variable
|
(identifier) @variable
|
||||||
(yul_identifier) @variable
|
(yul_identifier) @variable
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
(function_definition) @local.scope
|
(function_definition) @local.scope
|
||||||
|
(constructor_definition) @local.scope
|
||||||
(block_statement) @local.scope
|
(block_statement) @local.scope
|
||||||
|
|
||||||
(function_definition (parameter name: (identifier) @local.definition))
|
(function_definition (parameter name: (identifier) @local.definition))
|
||||||
|
(constructor_definition (parameter name: (identifier) @local.definition))
|
||||||
|
(variable_declaration name: (identifier) @local.definition)
|
||||||
|
|
||||||
; still have to support tuple assignments
|
(identifier) @local.reference
|
||||||
(assignment_expression left: (identifier) @local.definition)
|
|
||||||
|
|
||||||
(identifier) @local.reference
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
((parameter) @parameter.inside . ","? @parameter.around) @parameter.around)
|
((parameter) @parameter.inside . ","? @parameter.around) @parameter.around)
|
||||||
|
|
||||||
(return_type_definition
|
(return_type_definition
|
||||||
((parameter) @parameter.inside . ","? @parameter.around) @parameter.around)
|
((parameter) @entry.inside . ","? @entry.around) @entry.around)
|
||||||
|
|
||||||
(modifier_definition
|
(modifier_definition
|
||||||
((parameter) @parameter.inside . ","? @parameter.around) @parameter.around)
|
((parameter) @parameter.inside . ","? @parameter.around) @parameter.around)
|
||||||
|
@ -29,13 +29,13 @@
|
||||||
((error_parameter) @parameter.inside . ","? @parameter.around) @parameter.around)
|
((error_parameter) @parameter.inside . ","? @parameter.around) @parameter.around)
|
||||||
|
|
||||||
(call_argument
|
(call_argument
|
||||||
((call_struct_argument) @parameter.inside . ","? @parameter.around) @parameter.around)
|
((call_struct_argument) @entry.inside . ","? @entry.around) @entry.around)
|
||||||
|
|
||||||
(call_expression
|
(call_expression
|
||||||
((call_argument) @parameter.inside . ","? @parameter.around) @parameter.around)
|
((call_argument) @parameter.inside . ","? @parameter.around) @parameter.around)
|
||||||
|
|
||||||
(variable_declaration_tuple
|
(variable_declaration_tuple
|
||||||
((variable_declaration) @parameter.inside . ","? @parameter.around) @parameter.around)
|
((variable_declaration) @entry.inside . ","? @entry.around) @entry.around)
|
||||||
|
|
||||||
(emit_statement
|
(emit_statement
|
||||||
((call_argument) @parameter.inside . ","? @parameter.around) @parameter.around)
|
((call_argument) @parameter.inside . ","? @parameter.around) @parameter.around)
|
||||||
|
@ -52,3 +52,4 @@
|
||||||
(comment) @comment.inside
|
(comment) @comment.inside
|
||||||
|
|
||||||
(comment)+ @comment.around
|
(comment)+ @comment.around
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue