mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-19 11:50:09 -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["structure"] = "TSStructure"
|
||||||
hlmap["include"] = "TSInclude"
|
hlmap["include"] = "TSInclude"
|
||||||
|
|
||||||
|
-- variable
|
||||||
|
hlmap["variable"] = "TSVariable"
|
||||||
|
hlmap["variable.builtin"] = "TSVariableBuiltin"
|
||||||
|
|
||||||
-- Text
|
-- Text
|
||||||
hlmap["text"] = "TSText"
|
hlmap["text"] = "TSText"
|
||||||
hlmap["text.strong"] = "TSStrong"
|
hlmap["text.strong"] = "TSStrong"
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,9 @@ highlight default link TSTypeBuiltin Type
|
||||||
highlight default link TSStructure Structure
|
highlight default link TSStructure Structure
|
||||||
highlight default link TSInclude Include
|
highlight default link TSInclude Include
|
||||||
|
|
||||||
|
highlight default link TSVariable Identifier
|
||||||
|
highlight default link TSVariableBuiltin Special
|
||||||
|
|
||||||
highlight default link TSDefinitionUsage Visual
|
highlight default link TSDefinitionUsage Visual
|
||||||
highlight default link TSDefinition Search
|
highlight default link TSDefinition Search
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,14 @@
|
||||||
|
|
||||||
; Operators and Tokens
|
; Operators and Tokens
|
||||||
|
|
||||||
; FIXME: currently this errors
|
; FIXME: nodes not accessible and ranges
|
||||||
|
; currently incorrect
|
||||||
; (template_substitution
|
; (template_substitution
|
||||||
; "${" @punctuation.special
|
; "${" @punctuation.special
|
||||||
; "}" @punctuation.special) @embedded
|
; "}" @punctuation.special) @embedded
|
||||||
|
|
||||||
|
(template_substitution (identifier) @embedded)
|
||||||
|
|
||||||
[
|
[
|
||||||
"@"
|
"@"
|
||||||
"=>"
|
"=>"
|
||||||
|
|
@ -100,23 +103,27 @@
|
||||||
((identifier) @type
|
((identifier) @type
|
||||||
(#match? @type "^[A-Z]"))
|
(#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
|
(unconditional_assignable_selector
|
||||||
(identifier) @identifier)
|
(identifier) @property)
|
||||||
(assignable_selector
|
(assignable_selector
|
||||||
(identifier) @identifier)
|
(identifier) @property)
|
||||||
|
|
||||||
|
; assignments
|
||||||
(assignment_expression
|
(assignment_expression
|
||||||
left: (assignable_expression) @identifier)
|
left: (assignable_expression) @variable)
|
||||||
|
|
||||||
|
(this) @variable.builtin
|
||||||
|
|
||||||
; Parameters
|
; Parameters
|
||||||
|
|
||||||
(formal_parameter
|
(formal_parameter
|
||||||
name: (identifier) @parameter)
|
name: (identifier) @parameter)
|
||||||
|
|
||||||
; Named arguments
|
|
||||||
|
|
||||||
(named_argument
|
(named_argument
|
||||||
(label (identifier) @label))
|
(label (identifier) @variable.parameter))
|
||||||
|
|
||||||
; Literals
|
; Literals
|
||||||
|
|
||||||
|
|
@ -140,16 +147,13 @@
|
||||||
|
|
||||||
; Keywords
|
; Keywords
|
||||||
|
|
||||||
(this) @keyword
|
|
||||||
|
|
||||||
["import" "library" "export"] @include
|
["import" "library" "export"] @include
|
||||||
|
|
||||||
|
; Reserved words (cannot be used as identifiers)
|
||||||
; TODO: "rethrow" @keyword
|
; TODO: "rethrow" @keyword
|
||||||
|
|
||||||
; Reserved words (cannot be used as identifiers)
|
|
||||||
[
|
[
|
||||||
; "assert"
|
; "assert"
|
||||||
; "break"
|
|
||||||
"class"
|
"class"
|
||||||
"enum"
|
"enum"
|
||||||
"extends"
|
"extends"
|
||||||
|
|
@ -158,7 +162,6 @@
|
||||||
"new"
|
"new"
|
||||||
"return"
|
"return"
|
||||||
"super"
|
"super"
|
||||||
"var"
|
|
||||||
"with"
|
"with"
|
||||||
] @keyword
|
] @keyword
|
||||||
|
|
||||||
|
|
@ -181,6 +184,7 @@
|
||||||
"mixin"
|
"mixin"
|
||||||
"part"
|
"part"
|
||||||
"set"
|
"set"
|
||||||
|
"show"
|
||||||
"static"
|
"static"
|
||||||
"typedef"
|
"typedef"
|
||||||
] @keyword
|
] @keyword
|
||||||
|
|
@ -198,8 +202,7 @@
|
||||||
["do" "while" "continue" "for"] @repeat
|
["do" "while" "continue" "for"] @repeat
|
||||||
|
|
||||||
((identifier) @variable.builtin
|
((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)$")
|
(#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) @error
|
(ERROR) @error
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue