mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-05 04:50:03 -04:00
Change capture groups and add variable highlights
This commit is contained in:
parent
aaa990053a
commit
1427c43cf0
3 changed files with 25 additions and 15 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue