diff options
| author | ObserverOfTime <chronobserver@disroot.org> | 2022-10-28 17:26:32 +0300 |
|---|---|---|
| committer | ObserverOfTime <chronobserver@disroot.org> | 2022-11-26 13:17:51 +0200 |
| commit | 08bd9d0e088aefa7eb9c1ccf773e2c0f477eeaa3 (patch) | |
| tree | c4fe93e7c7fbfcc37590d8d78889179dddb60bab | |
| parent | highlights(swift): fix captures (diff) | |
| download | nvim-treesitter-08bd9d0e088aefa7eb9c1ccf773e2c0f477eeaa3.tar nvim-treesitter-08bd9d0e088aefa7eb9c1ccf773e2c0f477eeaa3.tar.gz nvim-treesitter-08bd9d0e088aefa7eb9c1ccf773e2c0f477eeaa3.tar.bz2 nvim-treesitter-08bd9d0e088aefa7eb9c1ccf773e2c0f477eeaa3.tar.lz nvim-treesitter-08bd9d0e088aefa7eb9c1ccf773e2c0f477eeaa3.tar.xz nvim-treesitter-08bd9d0e088aefa7eb9c1ccf773e2c0f477eeaa3.tar.zst nvim-treesitter-08bd9d0e088aefa7eb9c1ccf773e2c0f477eeaa3.zip | |
highlights(solidity): use more specific groups
| -rw-r--r-- | queries/solidity/highlights.scm | 43 | ||||
| -rw-r--r-- | tests/query/highlights/solidity/test.sol | 6 |
2 files changed, 27 insertions, 22 deletions
diff --git a/queries/solidity/highlights.scm b/queries/solidity/highlights.scm index 95909e669..932c54f32 100644 --- a/queries/solidity/highlights.scm +++ b/queries/solidity/highlights.scm @@ -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 - diff --git a/tests/query/highlights/solidity/test.sol b/tests/query/highlights/solidity/test.sol index 42a335182..a4b642ee6 100644 --- a/tests/query/highlights/solidity/test.sol +++ b/tests/query/highlights/solidity/test.sol @@ -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 |
