aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkin Sowemimo <akin.sowemimo@gmail.com>2020-08-07 12:29:06 +0100
committerThomas Vigouroux <39092278+vigoux@users.noreply.github.com>2020-08-09 19:12:26 +0200
commitd4fbbc05af82c6db93ceccf5c060dae1ca7f7cc6 (patch)
tree7df5ef30a02baec00fab82e826888b74f6fda286
parentLua: highlight function name (diff)
downloadnvim-treesitter-d4fbbc05af82c6db93ceccf5c060dae1ca7f7cc6.tar
nvim-treesitter-d4fbbc05af82c6db93ceccf5c060dae1ca7f7cc6.tar.gz
nvim-treesitter-d4fbbc05af82c6db93ceccf5c060dae1ca7f7cc6.tar.bz2
nvim-treesitter-d4fbbc05af82c6db93ceccf5c060dae1ca7f7cc6.tar.lz
nvim-treesitter-d4fbbc05af82c6db93ceccf5c060dae1ca7f7cc6.tar.xz
nvim-treesitter-d4fbbc05af82c6db93ceccf5c060dae1ca7f7cc6.tar.zst
nvim-treesitter-d4fbbc05af82c6db93ceccf5c060dae1ca7f7cc6.zip
Add new highlight queries
-rw-r--r--queries/dart/highlights.scm141
1 files changed, 97 insertions, 44 deletions
diff --git a/queries/dart/highlights.scm b/queries/dart/highlights.scm
index 9b5a954f6..7915d37bc 100644
--- a/queries/dart/highlights.scm
+++ b/queries/dart/highlights.scm
@@ -12,7 +12,12 @@
(marker_annotation
name: (identifier) @annotation)
-; Operators
+; Operators and Tokens
+
+; FIXME: currently this errors
+; (template_substitution
+; "${" @punctuation.special
+; "}" @punctuation.special) @embedded
[
"@"
@@ -26,6 +31,7 @@
"%"
"<"
">"
+ "="
">="
"<="
"||"
@@ -35,18 +41,22 @@
(additive_operator)
] @operator
-; Delimiters
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
-"." @punctuation.delimiter
-"," @punctuation.delimiter
-";" @punctuation.delimiter
+; Delimiters
-"(" @punctuation.bracket
-")" @punctuation.bracket
-"{" @punctuation.bracket
-"}" @punctuation.bracket
-"[" @punctuation.bracket
-"]" @punctuation.bracket
+[
+ ";"
+ "."
+ ","
+] @punctuation.delimiter
; Types
@@ -61,8 +71,6 @@
scope: (identifier) @type)
(function_signature
name: (identifier) @method)
-; using method_signature does not work
-; so specifically use getter and setter signatures
(getter_signature
(identifier) @method)
(setter_signature
@@ -83,22 +91,45 @@
; Variables
+; var keyword
+(inferred_type) @keyword
+
+(const_builtin) @constant.builtin
+(final_builtin) @constant.builtin
+
((identifier) @type
(#match? @type "^[A-Z]"))
-(this) @constant.builtin
+(identifier) @variable
+
+(this) @variable.builtin
+
+(unconditional_assignable_selector (identifier) @identifier)
+(assignable_selector (identifier) @identifier)
+(assignment_expression
+ left: (assignable_expression) @identifier)
-;; Parameters
+; Parameters
(formal_parameter
name: (identifier) @parameter)
-;; Literals
+; Named arguments
-(hex_integer_literal) @number
-(decimal_integer_literal) @number
-(decimal_floating_point_literal) @float
+(named_argument (label (identifier) @label))
+; Literals
+
+[
+ (hex_integer_literal)
+ (decimal_integer_literal)
+ (decimal_floating_point_literal)
+ ; TODO: inaccessbile nodes
+ ; (octal_integer_literal)
+ ; (hex_floating_point_literal)
+] @number
+
+(symbol_literal) @string.special.symbol
(string_literal) @string
(true) @boolean
(false) @boolean
@@ -111,35 +142,57 @@
["import" "library" "export"] @include
+; TODO: "rethrow" @keyword
+
+; Reserved words (cannot be used as identifiers)
[
- "abstract"
- ;"assert"
- ;"break"
- "on"
- "class"
- "default"
- "enum"
- "extends"
- ;"final"
- "implements"
- "as"
- "mixin"
- "external"
- "new"
- "return"
- "static"
- "required"
- "var"
- ;"const"
- "async"
- "await"
- ] @keyword
-;TODO:
-; "rethrow" @keyword
+ ; "assert"
+ ; "break"
+ "class"
+ "enum"
+ "extends"
+ "in"
+ "is"
+ "new"
+ "return"
+ "super"
+ "var"
+ "with"
+ ; "void"
+] @keyword
+
+[
+ "abstract"
+ "as"
+ "async"
+ "await"
+ "covariant"
+ "deferred"
+ "dynamic"
+ "external"
+ "factory"
+ "Function"
+ "get"
+ "implements"
+ "interface"
+ "library"
+ "operator"
+ "mixin"
+ "part"
+ "set"
+ "static"
+ "typedef"
+] @keyword
["if" "else" "switch" "default"] @conditional
-; TODO: case
["try" "throw" "catch" "finally"] @exception
["do" "while" "continue" "for"] @repeat
+
+((identifier) @variable.builtin
+ (#match? @variable.builtin "^(abstract|as|covariant|deferred|dynamic|export|external|factory|Function|get|implements|import|interface|library|operator|mixin|part|set|static|typedef)$")
+ (#is-not? local))
+
+; Error
+(ERROR) @error