mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-17 19:00:02 -04:00
Improve Python highlights
- Highlight types in attributes as @type (**Foo**.a) - Highlight superclasses @type - Highlight ^[A-Z] as @type - Highlight isinstance(*, type) as @type - Highlight default_parameter and keyword_argument as @parameter - Highlight *args, **kwargs as @parameter - Highlight -> as @operator
This commit is contained in:
parent
cdc92965d6
commit
807d6e11fa
1 changed files with 33 additions and 0 deletions
|
|
@ -9,6 +9,9 @@
|
||||||
(identifier)) @type)
|
(identifier)) @type)
|
||||||
(match? @type "^[A-Z]"))
|
(match? @type "^[A-Z]"))
|
||||||
|
|
||||||
|
((identifier) @type
|
||||||
|
(match? @type "^[A-Z]"))
|
||||||
|
|
||||||
((identifier) @constant
|
((identifier) @constant
|
||||||
(match? @constant "^[A-Z][A-Z_]*$"))
|
(match? @constant "^[A-Z][A-Z_]*$"))
|
||||||
|
|
||||||
|
|
@ -43,8 +46,30 @@
|
||||||
(identifier) @variable
|
(identifier) @variable
|
||||||
(attribute attribute: (identifier) @property)
|
(attribute attribute: (identifier) @property)
|
||||||
(type (identifier) @type)
|
(type (identifier) @type)
|
||||||
|
((call
|
||||||
|
function: (identifier) @isinstance
|
||||||
|
arguments: (argument_list
|
||||||
|
(*)
|
||||||
|
(identifier) @type))
|
||||||
|
(eq? @isinstance "isinstance"))
|
||||||
|
|
||||||
|
; Normal parameters
|
||||||
(parameters
|
(parameters
|
||||||
(identifier) @parameter)
|
(identifier) @parameter)
|
||||||
|
; Default parameters
|
||||||
|
(keyword_argument
|
||||||
|
name: (identifier) @parameter)
|
||||||
|
; Naming parameters on call-site
|
||||||
|
(default_parameter
|
||||||
|
name: (identifier) @parameter)
|
||||||
|
; Variadic parameters *args, **kwargs
|
||||||
|
(parameters
|
||||||
|
(list_splat ; *args
|
||||||
|
(identifier) @parameter))
|
||||||
|
(parameters
|
||||||
|
(dictionary_splat ; **kwargs
|
||||||
|
(identifier) @parameter))
|
||||||
|
|
||||||
|
|
||||||
; Literals
|
; Literals
|
||||||
|
|
||||||
|
|
@ -68,6 +93,7 @@
|
||||||
; Tokens
|
; Tokens
|
||||||
|
|
||||||
"-" @operator
|
"-" @operator
|
||||||
|
"->" @operator
|
||||||
"-=" @operator
|
"-=" @operator
|
||||||
"!=" @operator
|
"!=" @operator
|
||||||
"*" @operator
|
"*" @operator
|
||||||
|
|
@ -145,6 +171,9 @@
|
||||||
|
|
||||||
(class_definition
|
(class_definition
|
||||||
name: (identifier) @type)
|
name: (identifier) @type)
|
||||||
|
(class_definition
|
||||||
|
superclasses: (argument_list
|
||||||
|
(identifier) @type))
|
||||||
|
|
||||||
(attribute
|
(attribute
|
||||||
attribute: (identifier) @field)
|
attribute: (identifier) @field)
|
||||||
|
|
@ -157,6 +186,10 @@
|
||||||
attribute: (identifier) @type)
|
attribute: (identifier) @type)
|
||||||
(match? @type "^[A-Z][a-z_]+"))
|
(match? @type "^[A-Z][a-z_]+"))
|
||||||
|
|
||||||
|
((attribute
|
||||||
|
object: (identifier) @type)
|
||||||
|
(match? @type "^[A-Z][a-z_]+"))
|
||||||
|
|
||||||
(class_definition
|
(class_definition
|
||||||
body: (block
|
body: (block
|
||||||
(expression_statement
|
(expression_statement
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue