mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17: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) @attribute
|
||||
(#match? @attribute "^/// .*")
|
||||
) ;; Handles natspec comments
|
||||
;; Handles natspec comments
|
||||
((comment) @preproc
|
||||
(#match? @preproc "^/// .*"))
|
||||
|
||||
; Pragma
|
||||
(pragma_directive) @tag
|
||||
(pragma_directive) @attribute
|
||||
|
||||
|
||||
; Literals
|
||||
|
|
@ -34,13 +33,14 @@
|
|||
(struct_declaration struct_name: (identifier) @type)
|
||||
(struct_member name: (identifier) @field)
|
||||
(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)
|
||||
; Handles ContractA, ContractB in function foo() override(ContractA, contractB) {}
|
||||
; Handles ContractA, ContractB in function foo() override(ContractA, contractB) {}
|
||||
(override_specifier (identifier) @type)
|
||||
; 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
|
||||
|
|
@ -89,7 +89,6 @@
|
|||
|
||||
; Keywords
|
||||
[
|
||||
"pragma"
|
||||
"contract"
|
||||
"interface"
|
||||
"library"
|
||||
|
|
@ -97,9 +96,15 @@
|
|||
"struct"
|
||||
"enum"
|
||||
"event"
|
||||
"using"
|
||||
"assembly"
|
||||
"emit"
|
||||
"modifier"
|
||||
"var"
|
||||
(virtual)
|
||||
(override_specifier)
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"public"
|
||||
"internal"
|
||||
"private"
|
||||
|
|
@ -107,16 +112,14 @@
|
|||
"pure"
|
||||
"view"
|
||||
"payable"
|
||||
"modifier"
|
||||
] @type.qualifier
|
||||
|
||||
[
|
||||
"memory"
|
||||
"storage"
|
||||
"calldata"
|
||||
"var"
|
||||
(constant)
|
||||
(virtual)
|
||||
(override_specifier)
|
||||
(yul_leave)
|
||||
] @keyword
|
||||
] @storageclass
|
||||
|
||||
[
|
||||
"for"
|
||||
|
|
@ -142,11 +145,14 @@
|
|||
[
|
||||
"return"
|
||||
"returns"
|
||||
(yul_leave)
|
||||
] @keyword.return
|
||||
|
||||
"function" @keyword.function
|
||||
|
||||
"import" @include
|
||||
"pragma" @preproc
|
||||
|
||||
["import" "using"] @include
|
||||
(import_directive "as" @include)
|
||||
(import_directive "from" @include)
|
||||
|
||||
|
|
@ -209,4 +215,3 @@
|
|||
|
||||
(identifier) @variable
|
||||
(yul_identifier) @variable
|
||||
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@
|
|||
// SPDX-License-Identifier: GPL-3.0
|
||||
// ^ comment
|
||||
pragma solidity >=0.7.0 <0.9.0;
|
||||
// ^ keyword
|
||||
// ^ tag
|
||||
// ^ preproc
|
||||
// ^ attribute
|
||||
|
||||
import * as something from "anotherFile";
|
||||
// ^ ^ ^ include
|
||||
|
||||
/// @title Voting with delegation.
|
||||
// ^ attribute
|
||||
// ^ preproc
|
||||
contract Ballot {
|
||||
// ^keyword
|
||||
// ^ type
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue