mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-17 10:50:06 -04:00
feat(highlights): capture wildcard patterns as @character.special (#7153)
This commit is contained in:
parent
2b2ac30232
commit
188b1a6d01
13 changed files with 45 additions and 21 deletions
|
|
@ -217,7 +217,6 @@
|
||||||
"module"
|
"module"
|
||||||
"this"
|
"this"
|
||||||
"base"
|
"base"
|
||||||
(discard)
|
|
||||||
] @variable.builtin
|
] @variable.builtin
|
||||||
|
|
||||||
(constructor_declaration
|
(constructor_declaration
|
||||||
|
|
@ -430,6 +429,11 @@
|
||||||
".."
|
".."
|
||||||
] @operator
|
] @operator
|
||||||
|
|
||||||
|
(list_pattern
|
||||||
|
".." @character.special)
|
||||||
|
|
||||||
|
(discard) @character.special
|
||||||
|
|
||||||
[
|
[
|
||||||
";"
|
";"
|
||||||
"."
|
"."
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@
|
||||||
(lower_case_identifier) @variable)
|
(lower_case_identifier) @variable)
|
||||||
|
|
||||||
(anything_pattern
|
(anything_pattern
|
||||||
(underscore) @variable)
|
(underscore) @character.special)
|
||||||
|
|
||||||
(record_base_identifier
|
(record_base_identifier
|
||||||
(lower_case_identifier) @variable)
|
(lower_case_identifier) @variable)
|
||||||
|
|
@ -88,7 +88,7 @@
|
||||||
|
|
||||||
(function_declaration_left
|
(function_declaration_left
|
||||||
(anything_pattern
|
(anything_pattern
|
||||||
(underscore) @variable.parameter))
|
(underscore) @character.special))
|
||||||
|
|
||||||
(function_declaration_left
|
(function_declaration_left
|
||||||
(lower_pattern
|
(lower_pattern
|
||||||
|
|
|
||||||
|
|
@ -129,9 +129,10 @@
|
||||||
(#eq? @keyword.operator "new"))
|
(#eq? @keyword.operator "new"))
|
||||||
|
|
||||||
; Match Pattern
|
; Match Pattern
|
||||||
(underscore) @constant ; The "_" pattern.
|
[
|
||||||
|
(underscore)
|
||||||
(pattern_open_ending) @operator ; The ".." pattern.
|
(pattern_open_ending)
|
||||||
|
] @character.special
|
||||||
|
|
||||||
; Alternations
|
; Alternations
|
||||||
[
|
[
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
; and don't override destructured parameters
|
; and don't override destructured parameters
|
||||||
(variable) @variable
|
(variable) @variable
|
||||||
|
|
||||||
(pattern/wildcard) @variable
|
|
||||||
|
|
||||||
(decl/function
|
(decl/function
|
||||||
patterns: (patterns
|
patterns: (patterns
|
||||||
(_) @variable.parameter))
|
(_) @variable.parameter))
|
||||||
|
|
@ -78,7 +76,6 @@
|
||||||
(operator)
|
(operator)
|
||||||
(constructor_operator)
|
(constructor_operator)
|
||||||
(all_names)
|
(all_names)
|
||||||
(wildcard)
|
|
||||||
"."
|
"."
|
||||||
".."
|
".."
|
||||||
"="
|
"="
|
||||||
|
|
@ -92,6 +89,8 @@
|
||||||
"@"
|
"@"
|
||||||
] @operator
|
] @operator
|
||||||
|
|
||||||
|
(wildcard) @character.special
|
||||||
|
|
||||||
(module
|
(module
|
||||||
(module_id) @module)
|
(module_id) @module)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
; Variables
|
; Variables
|
||||||
(identifier) @variable
|
(identifier) @variable
|
||||||
|
|
||||||
|
(underscore_pattern) @character.special
|
||||||
|
|
||||||
; Methods
|
; Methods
|
||||||
(method_declaration
|
(method_declaration
|
||||||
name: (identifier) @function.method)
|
name: (identifier) @function.method)
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,12 @@
|
||||||
[
|
[
|
||||||
"="
|
"="
|
||||||
"~"
|
"~"
|
||||||
"_"
|
|
||||||
] @operator
|
] @operator
|
||||||
|
|
||||||
(modifier) @operator
|
(modifier) @operator
|
||||||
|
|
||||||
|
"_" @character.special
|
||||||
|
|
||||||
[
|
[
|
||||||
"<"
|
"<"
|
||||||
">"
|
">"
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,9 @@
|
||||||
|
|
||||||
(value_pattern) @variable.parameter
|
(value_pattern) @variable.parameter
|
||||||
|
|
||||||
|
((value_pattern) @character.special
|
||||||
|
(#eq? @character.special "_"))
|
||||||
|
|
||||||
; Functions
|
; Functions
|
||||||
;----------
|
;----------
|
||||||
(let_binding
|
(let_binding
|
||||||
|
|
@ -272,6 +275,9 @@
|
||||||
".."
|
".."
|
||||||
] @punctuation.delimiter
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
(range_pattern
|
||||||
|
".." @character.special)
|
||||||
|
|
||||||
; Operators
|
; Operators
|
||||||
;----------
|
;----------
|
||||||
[
|
[
|
||||||
|
|
|
||||||
|
|
@ -118,11 +118,12 @@
|
||||||
"role" @keyword
|
"role" @keyword
|
||||||
role: (type_role) @keyword.modifier)
|
role: (type_role) @keyword.modifier)
|
||||||
|
|
||||||
(hole) @character.special
|
|
||||||
|
|
||||||
; `_` wildcards in if-then-else and case-of expressions,
|
; `_` wildcards in if-then-else and case-of expressions,
|
||||||
; as well as record updates and operator sections
|
; as well as record updates and operator sections
|
||||||
(wildcard) @variable.parameter
|
[
|
||||||
|
"_"
|
||||||
|
(hole)
|
||||||
|
] @character.special
|
||||||
|
|
||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
; Functions and variables
|
; Functions and variables
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
; https://docs.python.org/3/library/constants.html
|
; https://docs.python.org/3/library/constants.html
|
||||||
"NotImplemented" "Ellipsis" "quit" "exit" "copyright" "credits" "license"))
|
"NotImplemented" "Ellipsis" "quit" "exit" "copyright" "credits" "license"))
|
||||||
|
|
||||||
"_" @constant.builtin ; match wildcard
|
"_" @character.special ; match wildcard
|
||||||
|
|
||||||
((attribute
|
((attribute
|
||||||
attribute: (identifier) @variable.member)
|
attribute: (identifier) @variable.member)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
"#"
|
"#"
|
||||||
] @punctuation.special
|
] @punctuation.special
|
||||||
|
|
||||||
"_" @constant
|
"_" @character.special
|
||||||
|
|
||||||
((parameters
|
((parameters
|
||||||
(identifier) @number)
|
(identifier) @number)
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
(operator)
|
(operator)
|
||||||
] @operator
|
] @operator
|
||||||
|
|
||||||
(wildcard_pattern) @constant.builtin
|
(wildcard_pattern) @character.special
|
||||||
|
|
||||||
[
|
[
|
||||||
"if"
|
"if"
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,9 @@
|
||||||
(mod_item
|
(mod_item
|
||||||
name: (identifier) @module)
|
name: (identifier) @module)
|
||||||
|
|
||||||
[
|
(self) @variable.builtin
|
||||||
(self)
|
|
||||||
"_"
|
"_" @character.special
|
||||||
] @variable.builtin
|
|
||||||
|
|
||||||
(label
|
(label
|
||||||
[
|
[
|
||||||
|
|
@ -376,6 +375,16 @@
|
||||||
(use_wildcard
|
(use_wildcard
|
||||||
"*" @character.special)
|
"*" @character.special)
|
||||||
|
|
||||||
|
(remaining_field_pattern
|
||||||
|
".." @character.special)
|
||||||
|
|
||||||
|
(range_pattern
|
||||||
|
[
|
||||||
|
".."
|
||||||
|
"..="
|
||||||
|
"..."
|
||||||
|
] @character.special)
|
||||||
|
|
||||||
; Punctuation
|
; Punctuation
|
||||||
[
|
[
|
||||||
"("
|
"("
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,8 @@
|
||||||
|
|
||||||
(null_literal) @constant.builtin
|
(null_literal) @constant.builtin
|
||||||
|
|
||||||
(wildcard) @variable.parameter
|
(wildcard
|
||||||
|
"_") @character.special
|
||||||
|
|
||||||
(namespace_wildcard
|
(namespace_wildcard
|
||||||
[
|
[
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue