mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-11 16:00:02 -04:00
highlights(solidity): use more specific groups
This commit is contained in:
parent
6825dc63b6
commit
08bd9d0e08
2 changed files with 27 additions and 22 deletions
|
|
@ -1,11 +1,10 @@
|
||||||
(comment) @comment
|
(comment) @comment
|
||||||
(
|
;; Handles natspec comments
|
||||||
(comment) @attribute
|
((comment) @preproc
|
||||||
(#match? @attribute "^/// .*")
|
(#match? @preproc "^/// .*"))
|
||||||
) ;; Handles natspec comments
|
|
||||||
|
|
||||||
; Pragma
|
; Pragma
|
||||||
(pragma_directive) @tag
|
(pragma_directive) @attribute
|
||||||
|
|
||||||
|
|
||||||
; Literals
|
; Literals
|
||||||
|
|
@ -34,13 +33,14 @@
|
||||||
(struct_declaration struct_name: (identifier) @type)
|
(struct_declaration struct_name: (identifier) @type)
|
||||||
(struct_member name: (identifier) @field)
|
(struct_member name: (identifier) @field)
|
||||||
(enum_declaration enum_type_name: (identifier) @type)
|
(enum_declaration enum_type_name: (identifier) @type)
|
||||||
; Color payable in payable address conversion as type and not as keyword
|
|
||||||
(payable_conversion_expression "payable" @type)
|
|
||||||
(emit_statement . (identifier) @type)
|
(emit_statement . (identifier) @type)
|
||||||
; Handles ContractA, ContractB in function foo() override(ContractA, contractB) {}
|
; Handles ContractA, ContractB in function foo() override(ContractA, contractB) {}
|
||||||
(override_specifier (identifier) @type)
|
(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)
|
||||||
|
|
||||||
|
|
||||||
; Functions and parameters
|
; Functions and parameters
|
||||||
|
|
@ -89,7 +89,6 @@
|
||||||
|
|
||||||
; Keywords
|
; Keywords
|
||||||
[
|
[
|
||||||
"pragma"
|
|
||||||
"contract"
|
"contract"
|
||||||
"interface"
|
"interface"
|
||||||
"library"
|
"library"
|
||||||
|
|
@ -97,9 +96,15 @@
|
||||||
"struct"
|
"struct"
|
||||||
"enum"
|
"enum"
|
||||||
"event"
|
"event"
|
||||||
"using"
|
|
||||||
"assembly"
|
"assembly"
|
||||||
"emit"
|
"emit"
|
||||||
|
"modifier"
|
||||||
|
"var"
|
||||||
|
(virtual)
|
||||||
|
(override_specifier)
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
[
|
||||||
"public"
|
"public"
|
||||||
"internal"
|
"internal"
|
||||||
"private"
|
"private"
|
||||||
|
|
@ -107,16 +112,14 @@
|
||||||
"pure"
|
"pure"
|
||||||
"view"
|
"view"
|
||||||
"payable"
|
"payable"
|
||||||
"modifier"
|
] @type.qualifier
|
||||||
|
|
||||||
|
[
|
||||||
"memory"
|
"memory"
|
||||||
"storage"
|
"storage"
|
||||||
"calldata"
|
"calldata"
|
||||||
"var"
|
|
||||||
(constant)
|
(constant)
|
||||||
(virtual)
|
] @storageclass
|
||||||
(override_specifier)
|
|
||||||
(yul_leave)
|
|
||||||
] @keyword
|
|
||||||
|
|
||||||
[
|
[
|
||||||
"for"
|
"for"
|
||||||
|
|
@ -142,11 +145,14 @@
|
||||||
[
|
[
|
||||||
"return"
|
"return"
|
||||||
"returns"
|
"returns"
|
||||||
|
(yul_leave)
|
||||||
] @keyword.return
|
] @keyword.return
|
||||||
|
|
||||||
"function" @keyword.function
|
"function" @keyword.function
|
||||||
|
|
||||||
"import" @include
|
"pragma" @preproc
|
||||||
|
|
||||||
|
["import" "using"] @include
|
||||||
(import_directive "as" @include)
|
(import_directive "as" @include)
|
||||||
(import_directive "from" @include)
|
(import_directive "from" @include)
|
||||||
|
|
||||||
|
|
@ -209,4 +215,3 @@
|
||||||
|
|
||||||
(identifier) @variable
|
(identifier) @variable
|
||||||
(yul_identifier) @variable
|
(yul_identifier) @variable
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
// ^ comment
|
// ^ comment
|
||||||
pragma solidity >=0.7.0 <0.9.0;
|
pragma solidity >=0.7.0 <0.9.0;
|
||||||
// ^ keyword
|
// ^ preproc
|
||||||
// ^ tag
|
// ^ attribute
|
||||||
|
|
||||||
import * as something from "anotherFile";
|
import * as something from "anotherFile";
|
||||||
// ^ ^ ^ include
|
// ^ ^ ^ include
|
||||||
|
|
||||||
/// @title Voting with delegation.
|
/// @title Voting with delegation.
|
||||||
// ^ attribute
|
// ^ preproc
|
||||||
contract Ballot {
|
contract Ballot {
|
||||||
// ^keyword
|
// ^keyword
|
||||||
// ^ type
|
// ^ type
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue