mirror of
https://github.com/ilyakooo0/helix.git
synced 2024-09-11 16:07:00 +03:00
tree-sitter-solidity: Use upstream, update queries
This commit is contained in:
parent
44b447947c
commit
20ed8c2595
@ -1192,7 +1192,7 @@ language-server = { command = "solc", args = ["--lsp"] }
|
|||||||
|
|
||||||
[[grammar]]
|
[[grammar]]
|
||||||
name = "solidity"
|
name = "solidity"
|
||||||
source = { git = "https://github.com/slinlee/tree-sitter-solidity", rev = "f3a002274744e859bf64cf3524985f8c31ea84fd" }
|
source = { git = "https://github.com/JoranHonig/tree-sitter-solidity", rev = "9004b86531cb424bd379424cf7266a4585f2af7d" }
|
||||||
|
|
||||||
[[language]]
|
[[language]]
|
||||||
name = "gleam"
|
name = "gleam"
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
(comment) @comment
|
; identifiers
|
||||||
|
; -----------
|
||||||
|
(identifier) @variable
|
||||||
|
(yul_identifier) @variable
|
||||||
|
|
||||||
; Pragma
|
; Pragma
|
||||||
(pragma_directive) @tag
|
(pragma_directive) @tag
|
||||||
(solidity_version_comparison_operator ">=" @tag)
|
(solidity_version_comparison_operator _ @tag)
|
||||||
(solidity_version_comparison_operator "<=" @tag)
|
|
||||||
(solidity_version_comparison_operator "=" @tag)
|
|
||||||
(solidity_version_comparison_operator "~" @tag)
|
|
||||||
(solidity_version_comparison_operator "^" @tag)
|
|
||||||
|
|
||||||
|
|
||||||
; Literals
|
; Literals
|
||||||
|
; --------
|
||||||
|
|
||||||
[
|
[
|
||||||
(string)
|
(string)
|
||||||
(hex_string_literal)
|
(hex_string_literal)
|
||||||
@ -26,26 +27,38 @@
|
|||||||
(false)
|
(false)
|
||||||
] @constant.builtin
|
] @constant.builtin
|
||||||
|
|
||||||
|
(comment) @comment
|
||||||
|
|
||||||
|
|
||||||
|
; Definitions and references
|
||||||
|
; -----------
|
||||||
|
|
||||||
; Type
|
|
||||||
(type_name) @type
|
(type_name) @type
|
||||||
(primitive_type) @type
|
(primitive_type) @type
|
||||||
(struct_declaration struct_name: (identifier) @type)
|
(user_defined_type (identifier) @type)
|
||||||
(enum_declaration enum_type_name: (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
|
||||||
(payable_conversion_expression "payable" @type)
|
(payable_conversion_expression "payable" @type)
|
||||||
(emit_statement . (identifier) @type)
|
|
||||||
; Handles ContractA, ContractB in function foo() override(ContractA, contractB) {}
|
|
||||||
(override_specifier (identifier) @type)
|
|
||||||
; Ensures that delimiters in mapping( ... => .. ) are not colored like types
|
; Ensures that delimiters in mapping( ... => .. ) are not colored like types
|
||||||
(type_name "(" @punctuation.bracket "=>" @punctuation.delimiter ")" @punctuation.bracket)
|
(type_name "(" @punctuation.bracket "=>" @punctuation.delimiter ")" @punctuation.bracket)
|
||||||
|
|
||||||
|
; Definitions
|
||||||
|
(struct_declaration
|
||||||
; Functions and parameters
|
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
|
(function_definition
|
||||||
function_name: (identifier) @function)
|
name: (identifier) @function)
|
||||||
|
|
||||||
(modifier_definition
|
(modifier_definition
|
||||||
name: (identifier) @function)
|
name: (identifier) @function)
|
||||||
(yul_evm_builtin) @function.builtin
|
(yul_evm_builtin) @function.builtin
|
||||||
@ -55,37 +68,38 @@
|
|||||||
(fallback_receive_definition "receive" @constructor)
|
(fallback_receive_definition "receive" @constructor)
|
||||||
(fallback_receive_definition "fallback" @constructor)
|
(fallback_receive_definition "fallback" @constructor)
|
||||||
|
|
||||||
|
(struct_member name: (identifier) @variable.other.member)
|
||||||
|
(enum_value) @constant
|
||||||
|
|
||||||
|
; Invocations
|
||||||
|
(emit_statement . (identifier) @type)
|
||||||
(modifier_invocation (identifier) @function)
|
(modifier_invocation (identifier) @function)
|
||||||
|
|
||||||
; Handles expressions like structVariable.g();
|
(call_expression . (member_expression property: (identifier) @function.method))
|
||||||
(call_expression . (member_expression (property_identifier) @function.method))
|
|
||||||
|
|
||||||
; Handles expressions like g();
|
|
||||||
(call_expression . (identifier) @function)
|
(call_expression . (identifier) @function)
|
||||||
|
|
||||||
; Function parameters
|
; Function parameters
|
||||||
(event_paramater name: (identifier) @variable.parameter) ; TODO fix spelling once fixed upstream
|
(call_struct_argument name: (identifier) @field)
|
||||||
(function_definition
|
(event_paramater name: (identifier) @variable.parameter)
|
||||||
function_name: (identifier) @variable.parameter)
|
(parameter name: (identifier) @variable.parameter)
|
||||||
|
|
||||||
; Yul functions
|
; Yul functions
|
||||||
(yul_function_call function: (yul_identifier) @function)
|
(yul_function_call function: (yul_identifier) @function)
|
||||||
|
|
||||||
; Yul function parameters
|
|
||||||
(yul_function_definition . (yul_identifier) @function (yul_identifier) @variable.parameter)
|
(yul_function_definition . (yul_identifier) @function (yul_identifier) @variable.parameter)
|
||||||
|
|
||||||
(meta_type_expression "type" @keyword)
|
|
||||||
|
|
||||||
(member_expression (property_identifier) @variable.other.member)
|
; Structs and members
|
||||||
(property_identifier) @variable.other.member
|
(member_expression property: (identifier) @variable.other.member)
|
||||||
(struct_expression ((identifier) @variable.other.member . ":"))
|
(struct_expression type: ((identifier) @type .))
|
||||||
(enum_value) @variable.other.member
|
(struct_field_assignment name: (identifier) @variable.other.member)
|
||||||
|
|
||||||
|
; Tokens
|
||||||
|
; -------
|
||||||
|
|
||||||
; Keywords
|
; Keywords
|
||||||
|
(meta_type_expression "type" @keyword)
|
||||||
[
|
[
|
||||||
"pragma"
|
"pragma"
|
||||||
"import"
|
|
||||||
"contract"
|
"contract"
|
||||||
"interface"
|
"interface"
|
||||||
"library"
|
"library"
|
||||||
@ -95,19 +109,6 @@
|
|||||||
"event"
|
"event"
|
||||||
"using"
|
"using"
|
||||||
"assembly"
|
"assembly"
|
||||||
"switch"
|
|
||||||
"case"
|
|
||||||
"default"
|
|
||||||
"break"
|
|
||||||
"continue"
|
|
||||||
"if"
|
|
||||||
"else"
|
|
||||||
"for"
|
|
||||||
"while"
|
|
||||||
"do"
|
|
||||||
"try"
|
|
||||||
"catch"
|
|
||||||
"return"
|
|
||||||
"emit"
|
"emit"
|
||||||
"public"
|
"public"
|
||||||
"internal"
|
"internal"
|
||||||
@ -117,20 +118,47 @@
|
|||||||
"view"
|
"view"
|
||||||
"payable"
|
"payable"
|
||||||
"modifier"
|
"modifier"
|
||||||
"returns"
|
|
||||||
"memory"
|
"memory"
|
||||||
"storage"
|
"storage"
|
||||||
"calldata"
|
"calldata"
|
||||||
"function"
|
|
||||||
"var"
|
"var"
|
||||||
(constant)
|
"constant"
|
||||||
(virtual)
|
(virtual)
|
||||||
(override_specifier)
|
(override_specifier)
|
||||||
(yul_leave)
|
(yul_leave)
|
||||||
] @keyword
|
] @keyword
|
||||||
|
|
||||||
(import_directive "as" @keyword)
|
[
|
||||||
(import_directive "from" @keyword)
|
"for"
|
||||||
|
"while"
|
||||||
|
"do"
|
||||||
|
] @keyword.control.repeat
|
||||||
|
|
||||||
|
[
|
||||||
|
"break"
|
||||||
|
"continue"
|
||||||
|
"if"
|
||||||
|
"else"
|
||||||
|
"switch"
|
||||||
|
"case"
|
||||||
|
"default"
|
||||||
|
] @keyword.control.conditional
|
||||||
|
|
||||||
|
[
|
||||||
|
"try"
|
||||||
|
"catch"
|
||||||
|
] @keyword.control.exception
|
||||||
|
|
||||||
|
[
|
||||||
|
"return"
|
||||||
|
"returns"
|
||||||
|
] @keyword.control.return
|
||||||
|
|
||||||
|
"function" @keyword.function
|
||||||
|
|
||||||
|
"import" @keyword.control.import
|
||||||
|
(import_directive "as" @keyword.control.import)
|
||||||
|
(import_directive "from" @keyword.control.import)
|
||||||
(event_paramater "indexed" @keyword) ; TODO fix spelling once fixed upstream
|
(event_paramater "indexed" @keyword) ; TODO fix spelling once fixed upstream
|
||||||
|
|
||||||
; Punctuation
|
; Punctuation
|
||||||
@ -142,7 +170,7 @@
|
|||||||
"]"
|
"]"
|
||||||
"{"
|
"{"
|
||||||
"}"
|
"}"
|
||||||
] @punctuation.bracket
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
|
||||||
[
|
[
|
||||||
@ -185,5 +213,7 @@
|
|||||||
"--"
|
"--"
|
||||||
] @operator
|
] @operator
|
||||||
|
|
||||||
(identifier) @variable
|
[
|
||||||
(yul_identifier) @variable
|
"delete"
|
||||||
|
"new"
|
||||||
|
] @keyword.operator
|
||||||
|
9
runtime/queries/solidity/locals.scm
Normal file
9
runtime/queries/solidity/locals.scm
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
(function_definition) @local.scope
|
||||||
|
(block_statement) @local.scope
|
||||||
|
|
||||||
|
(function_definition (parameter name: (identifier) @local.definition))
|
||||||
|
|
||||||
|
; still have to support tuple assignments
|
||||||
|
(assignment_expression left: (identifier) @local.definition)
|
||||||
|
|
||||||
|
(identifier) @local.reference
|
Loading…
Reference in New Issue
Block a user