diff options
| -rw-r--r-- | lua/nvim-treesitter/highlight.lua | 4 | ||||
| -rw-r--r-- | plugin/nvim-treesitter.vim | 3 | ||||
| -rw-r--r-- | queries/dart/highlights.scm | 33 |
3 files changed, 25 insertions, 15 deletions
diff --git a/lua/nvim-treesitter/highlight.lua b/lua/nvim-treesitter/highlight.lua index 1737d526c..ed2d7e301 100644 --- a/lua/nvim-treesitter/highlight.lua +++ b/lua/nvim-treesitter/highlight.lua @@ -54,6 +54,10 @@ hlmap["type.builtin"] = "TSTypeBuiltin" hlmap["structure"] = "TSStructure" hlmap["include"] = "TSInclude" +-- variable +hlmap["variable"] = "TSVariable" +hlmap["variable.builtin"] = "TSVariableBuiltin" + -- Text hlmap["text"] = "TSText" hlmap["text.strong"] = "TSStrong" diff --git a/plugin/nvim-treesitter.vim b/plugin/nvim-treesitter.vim index 742af5814..479be5ec6 100644 --- a/plugin/nvim-treesitter.vim +++ b/plugin/nvim-treesitter.vim @@ -62,6 +62,9 @@ highlight default link TSTypeBuiltin Type highlight default link TSStructure Structure highlight default link TSInclude Include +highlight default link TSVariable Identifier +highlight default link TSVariableBuiltin Special + highlight default link TSDefinitionUsage Visual highlight default link TSDefinition Search diff --git a/queries/dart/highlights.scm b/queries/dart/highlights.scm index c49e1eab8..a088dff9c 100644 --- a/queries/dart/highlights.scm +++ b/queries/dart/highlights.scm @@ -14,11 +14,14 @@ ; Operators and Tokens -; FIXME: currently this errors +; FIXME: nodes not accessible and ranges +; currently incorrect ; (template_substitution ; "${" @punctuation.special ; "}" @punctuation.special) @embedded +(template_substitution (identifier) @embedded) + [ "@" "=>" @@ -100,23 +103,27 @@ ((identifier) @type (#match? @type "^[A-Z]")) -; TODO: currently not working +; properties +; TODO: add method/call_expression to grammar and +; distinguish method call from variable access (unconditional_assignable_selector - (identifier) @identifier) + (identifier) @property) (assignable_selector - (identifier) @identifier) + (identifier) @property) + +; assignments (assignment_expression - left: (assignable_expression) @identifier) + left: (assignable_expression) @variable) + +(this) @variable.builtin ; Parameters (formal_parameter name: (identifier) @parameter) -; Named arguments - (named_argument - (label (identifier) @label)) + (label (identifier) @variable.parameter)) ; Literals @@ -140,16 +147,13 @@ ; Keywords -(this) @keyword - ["import" "library" "export"] @include +; Reserved words (cannot be used as identifiers) ; TODO: "rethrow" @keyword -; Reserved words (cannot be used as identifiers) [ ; "assert" - ; "break" "class" "enum" "extends" @@ -158,7 +162,6 @@ "new" "return" "super" - "var" "with" ] @keyword @@ -181,6 +184,7 @@ "mixin" "part" "set" + "show" "static" "typedef" ] @keyword @@ -198,8 +202,7 @@ ["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)) + (#match? @variable.builtin "^(abstract|as|covariant|deferred|dynamic|export|external|factory|Function|get|implements|import|interface|library|operator|mixin|part|set|static|typedef)$")) ; Error (ERROR) @error |
