Update generated neovim config
This commit is contained in:
@ -0,0 +1,310 @@
|
||||
; Pragma
|
||||
[
|
||||
"pragma"
|
||||
"solidity"
|
||||
] @keyword.directive
|
||||
|
||||
(solidity_pragma_token
|
||||
"||" @string.special.symbol)
|
||||
|
||||
(solidity_pragma_token
|
||||
"-" @string.special.symbol)
|
||||
|
||||
(solidity_version_comparison_operator) @operator
|
||||
|
||||
(solidity_version) @string.special
|
||||
|
||||
; Literals
|
||||
[
|
||||
(string)
|
||||
(yul_string_literal)
|
||||
] @string
|
||||
|
||||
(hex_string_literal
|
||||
"hex" @string.special.symbol
|
||||
(_) @string)
|
||||
|
||||
(unicode_string_literal
|
||||
"unicode" @string.special.symbol
|
||||
(_) @string)
|
||||
|
||||
[
|
||||
(number_literal)
|
||||
(yul_decimal_number)
|
||||
(yul_hex_number)
|
||||
] @number
|
||||
|
||||
(yul_boolean) @boolean
|
||||
|
||||
; Variables
|
||||
[
|
||||
(identifier)
|
||||
(yul_identifier)
|
||||
] @variable
|
||||
|
||||
; Types
|
||||
(type_name
|
||||
(identifier) @type)
|
||||
|
||||
(type_name
|
||||
(user_defined_type
|
||||
(identifier) @type))
|
||||
|
||||
(type_name
|
||||
"mapping" @function.builtin)
|
||||
|
||||
[
|
||||
(primitive_type)
|
||||
(number_unit)
|
||||
] @type.builtin
|
||||
|
||||
(contract_declaration
|
||||
name: (identifier) @type)
|
||||
|
||||
(struct_declaration
|
||||
name: (identifier) @type)
|
||||
|
||||
(struct_member
|
||||
name: (identifier) @variable.member)
|
||||
|
||||
(enum_declaration
|
||||
name: (identifier) @type)
|
||||
|
||||
(emit_statement
|
||||
.
|
||||
(expression (identifier)) @type)
|
||||
|
||||
; Handles ContractA, ContractB in function foo() override(ContractA, contractB) {}
|
||||
(override_specifier
|
||||
(user_defined_type) @type)
|
||||
|
||||
; Functions and parameters
|
||||
(function_definition
|
||||
name: (identifier) @function)
|
||||
|
||||
(modifier_definition
|
||||
name: (identifier) @function)
|
||||
|
||||
(yul_evm_builtin) @function.builtin
|
||||
|
||||
; Use constructor coloring for special functions
|
||||
(constructor_definition
|
||||
"constructor" @constructor)
|
||||
|
||||
(modifier_invocation
|
||||
(identifier) @function)
|
||||
|
||||
; Handles expressions like structVariable.g();
|
||||
(call_expression
|
||||
.
|
||||
(expression(member_expression
|
||||
(identifier) @function.method.call)))
|
||||
|
||||
; Handles expressions like g();
|
||||
(call_expression
|
||||
.
|
||||
(expression (identifier) @function.call))
|
||||
|
||||
; Function parameters
|
||||
(event_parameter
|
||||
name: (_) @variable.parameter)
|
||||
|
||||
(parameter
|
||||
name: (_) @variable.parameter)
|
||||
|
||||
; Yul functions
|
||||
(yul_function_call
|
||||
function: (yul_identifier) @function.call)
|
||||
|
||||
; Yul function parameters
|
||||
(yul_function_definition
|
||||
.
|
||||
(yul_identifier) @function
|
||||
(yul_identifier) @variable.parameter)
|
||||
|
||||
(meta_type_expression
|
||||
"type" @keyword)
|
||||
|
||||
(member_expression
|
||||
property: (_) @variable.member)
|
||||
|
||||
(call_struct_argument
|
||||
name: (_) @variable.member)
|
||||
|
||||
(struct_field_assignment
|
||||
name: (identifier) @variable.member)
|
||||
|
||||
(enum_value) @constant
|
||||
|
||||
; Keywords
|
||||
[
|
||||
"contract"
|
||||
"interface"
|
||||
"library"
|
||||
"is"
|
||||
"struct"
|
||||
"enum"
|
||||
"event"
|
||||
"assembly"
|
||||
"emit"
|
||||
"override"
|
||||
"modifier"
|
||||
"var"
|
||||
"let"
|
||||
"emit"
|
||||
"error"
|
||||
"fallback"
|
||||
"receive"
|
||||
(virtual)
|
||||
] @keyword
|
||||
|
||||
; FIXME: update grammar
|
||||
; (block_statement "unchecked" @keyword)
|
||||
(event_parameter
|
||||
"indexed" @keyword)
|
||||
|
||||
[
|
||||
"public"
|
||||
"internal"
|
||||
"private"
|
||||
"external"
|
||||
"pure"
|
||||
"view"
|
||||
"payable"
|
||||
(immutable)
|
||||
] @keyword.modifier
|
||||
|
||||
[
|
||||
"memory"
|
||||
"storage"
|
||||
"calldata"
|
||||
"constant"
|
||||
] @keyword.modifier
|
||||
|
||||
[
|
||||
"for"
|
||||
"while"
|
||||
"do"
|
||||
"break"
|
||||
"continue"
|
||||
] @keyword.repeat
|
||||
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"switch"
|
||||
"case"
|
||||
"default"
|
||||
] @keyword.conditional
|
||||
|
||||
(ternary_expression
|
||||
"?" @keyword.conditional.ternary
|
||||
":" @keyword.conditional.ternary)
|
||||
|
||||
[
|
||||
"try"
|
||||
"catch"
|
||||
"revert"
|
||||
] @keyword.exception
|
||||
|
||||
[
|
||||
"return"
|
||||
"returns"
|
||||
(yul_leave)
|
||||
] @keyword.return
|
||||
|
||||
"function" @keyword.function
|
||||
|
||||
[
|
||||
"import"
|
||||
"using"
|
||||
] @keyword.import
|
||||
|
||||
(import_directive
|
||||
"as" @keyword.import)
|
||||
|
||||
(import_directive
|
||||
"from" @keyword.import)
|
||||
|
||||
((import_directive
|
||||
source: (string) @string.special.path)
|
||||
(#offset! @string.special.path 0 1 0 -1))
|
||||
|
||||
; Punctuation
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
"."
|
||||
","
|
||||
":"
|
||||
; FIXME: update grammar
|
||||
; (semicolon)
|
||||
"->"
|
||||
"=>"
|
||||
] @punctuation.delimiter
|
||||
|
||||
; Operators
|
||||
[
|
||||
"&&"
|
||||
"||"
|
||||
">>"
|
||||
">>>"
|
||||
"<<"
|
||||
"&"
|
||||
"^"
|
||||
"|"
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"**"
|
||||
"="
|
||||
"<"
|
||||
"<="
|
||||
"=="
|
||||
"!="
|
||||
"!=="
|
||||
">="
|
||||
">"
|
||||
"!"
|
||||
"~"
|
||||
"-"
|
||||
"+"
|
||||
"++"
|
||||
"--"
|
||||
":="
|
||||
] @operator
|
||||
|
||||
[
|
||||
"delete"
|
||||
"new"
|
||||
] @keyword.operator
|
||||
|
||||
(import_directive
|
||||
"*" @character.special)
|
||||
|
||||
; Comments
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///[^/]"))
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^///$"))
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
@ -0,0 +1,217 @@
|
||||
; identifiers
|
||||
; -----------
|
||||
(identifier) @variable
|
||||
(yul_identifier) @variable
|
||||
|
||||
; Pragma
|
||||
(pragma_directive) @tag
|
||||
(solidity_version_comparison_operator _ @tag)
|
||||
|
||||
; Literals
|
||||
; --------
|
||||
|
||||
[
|
||||
(string)
|
||||
(hex_string_literal)
|
||||
(unicode_string_literal)
|
||||
(yul_string_literal)
|
||||
] @string
|
||||
[
|
||||
(number_literal)
|
||||
(yul_decimal_number)
|
||||
(yul_hex_number)
|
||||
] @number
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @constant.builtin
|
||||
|
||||
(comment) @comment
|
||||
|
||||
; Definitions and references
|
||||
; -----------
|
||||
|
||||
(type_name) @type
|
||||
(primitive_type) @type
|
||||
(user_defined_type (identifier) @type)
|
||||
|
||||
(payable_conversion_expression "payable" @type)
|
||||
; Ensures that delimiters in mapping( ... => .. ) are not colored like types
|
||||
(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)
|
||||
|
||||
(function_definition
|
||||
name: (identifier) @function)
|
||||
|
||||
(modifier_definition
|
||||
name: (identifier) @function)
|
||||
(yul_evm_builtin) @function.builtin
|
||||
|
||||
; Use contructor coloring for special functions
|
||||
(constructor_definition "constructor" @constructor)
|
||||
(fallback_receive_definition "receive" @constructor)
|
||||
(fallback_receive_definition "fallback" @constructor)
|
||||
|
||||
(struct_member name: (identifier) @property)
|
||||
(enum_value) @constant
|
||||
|
||||
; Invocations
|
||||
(emit_statement . (_) @type)
|
||||
(modifier_invocation (identifier) @function)
|
||||
|
||||
(call_expression . (_(member_expression property: (_) @function.method)))
|
||||
(call_expression . (expression(identifier)) @function)
|
||||
|
||||
; Function parameters
|
||||
(call_struct_argument name: (_) @field)
|
||||
(event_parameter name: (identifier) @parameter)
|
||||
(parameter name: (identifier) @variable.parameter)
|
||||
|
||||
; Yul functions
|
||||
(yul_function_call function: (yul_identifier) @function)
|
||||
(yul_function_definition . (yul_identifier) @function (yul_identifier) @parameter)
|
||||
|
||||
|
||||
; Structs and members
|
||||
(member_expression property: (identifier) @property)
|
||||
(struct_expression type: ((expression(identifier)) @type .))
|
||||
(struct_field_assignment name: (identifier) @property)
|
||||
|
||||
|
||||
; Tokens
|
||||
; -------
|
||||
|
||||
; Keywords
|
||||
(meta_type_expression "type" @keyword)
|
||||
; Keywords
|
||||
[
|
||||
"pragma"
|
||||
"contract"
|
||||
"interface"
|
||||
"library"
|
||||
"is"
|
||||
"struct"
|
||||
"enum"
|
||||
"event"
|
||||
"using"
|
||||
"assembly"
|
||||
"emit"
|
||||
"public"
|
||||
"internal"
|
||||
"private"
|
||||
"external"
|
||||
"pure"
|
||||
"view"
|
||||
"payable"
|
||||
"modifier"
|
||||
"memory"
|
||||
"storage"
|
||||
"calldata"
|
||||
"var"
|
||||
"constant"
|
||||
(virtual)
|
||||
(override_specifier)
|
||||
(yul_leave)
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"for"
|
||||
"while"
|
||||
"do"
|
||||
] @repeat
|
||||
|
||||
[
|
||||
"break"
|
||||
"continue"
|
||||
"if"
|
||||
"else"
|
||||
"switch"
|
||||
"case"
|
||||
"default"
|
||||
] @conditional
|
||||
|
||||
[
|
||||
"try"
|
||||
"catch"
|
||||
] @exception
|
||||
|
||||
[
|
||||
"return"
|
||||
"returns"
|
||||
] @keyword.return
|
||||
|
||||
"function" @keyword.function
|
||||
|
||||
"import" @include
|
||||
(import_directive "as" @include)
|
||||
(import_directive "from" @include)
|
||||
|
||||
(event_parameter "indexed" @keyword)
|
||||
|
||||
; Punctuation
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
|
||||
[
|
||||
"."
|
||||
","
|
||||
] @punctuation.delimiter
|
||||
|
||||
|
||||
; Operators
|
||||
|
||||
[
|
||||
"&&"
|
||||
"||"
|
||||
">>"
|
||||
">>>"
|
||||
"<<"
|
||||
"&"
|
||||
"^"
|
||||
"|"
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"**"
|
||||
"<"
|
||||
"<="
|
||||
"=="
|
||||
"!="
|
||||
"!=="
|
||||
">="
|
||||
">"
|
||||
"!"
|
||||
"~"
|
||||
"-"
|
||||
"+"
|
||||
"++"
|
||||
"--"
|
||||
] @operator
|
||||
|
||||
[
|
||||
"delete"
|
||||
"new"
|
||||
] @keyword.operator
|
||||
@ -0,0 +1,9 @@
|
||||
(function_definition) @local.scope
|
||||
(block_statement) @local.scope
|
||||
|
||||
(function_definition (parameter name: (_) @local.definition))
|
||||
|
||||
; still have to support tuple assignments
|
||||
(assignment_expression left: (_) @local.definition)
|
||||
|
||||
(identifier) @local.reference
|
||||
@ -0,0 +1,43 @@
|
||||
;; Method and Function declarations
|
||||
(contract_declaration (_
|
||||
(function_definition
|
||||
name: (identifier) @name) @definition.method))
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
name: (identifier) @name) @definition.function)
|
||||
|
||||
;; Contract, struct, enum and interface declarations
|
||||
(contract_declaration
|
||||
name: (identifier) @name) @definition.class
|
||||
|
||||
(interface_declaration
|
||||
name: (identifier) @name) @definition.interface
|
||||
|
||||
(library_declaration
|
||||
name: (identifier) @name) @definition.interface
|
||||
|
||||
(struct_declaration name: (identifier) @name) @definition.class
|
||||
(enum_declaration name: (identifier) @name) @definition.class
|
||||
(event_definition name: (identifier) @name) @definition.class
|
||||
|
||||
;; Function calls
|
||||
(call_expression (expression (identifier)) @name ) @reference.call
|
||||
|
||||
(call_expression
|
||||
(expression (member_expression
|
||||
property: (_) @name ))) @reference.call
|
||||
|
||||
;; Log emit
|
||||
(emit_statement name: (_) @name) @reference.class
|
||||
|
||||
|
||||
;; Inheritance
|
||||
|
||||
(inheritance_specifier
|
||||
ancestor: (user_defined_type (_) @name . )) @reference.class
|
||||
|
||||
|
||||
;; Imports ( note that unknown is not standardised )
|
||||
(import_directive
|
||||
import_name: (_) @name ) @reference.unknown
|
||||
Reference in New Issue
Block a user