mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
highlights(python): fix captures
This commit is contained in:
parent
6725bef5ce
commit
14fa6e015e
1 changed files with 38 additions and 9 deletions
|
|
@ -44,17 +44,24 @@
|
|||
"ConnectionRefusedError" "ConnectionResetError" "FileExistsError" "FileNotFoundError" "InterruptedError"
|
||||
"IsADirectoryError" "NotADirectoryError" "PermissionError" "ProcessLookupError" "TimeoutError" "Warning"
|
||||
"UserWarning" "DeprecationWarning" "PendingDeprecationWarning" "SyntaxWarning" "RuntimeWarning"
|
||||
"FutureWarning" "ImportWarning" "UnicodeWarning" "BytesWarning" "ResourceWarning"))
|
||||
"FutureWarning" "ImportWarning" "UnicodeWarning" "BytesWarning" "ResourceWarning"
|
||||
;; https://docs.python.org/3/library/stdtypes.html
|
||||
"bool" "int" "float" "complex" "list" "tuple" "range" "str"
|
||||
"bytes" "bytearray" "memoryview" "set" "frozenset" "dict" "type"))
|
||||
|
||||
((assignment
|
||||
left: (identifier) @type.definition
|
||||
(type (identifier) @_annotation))
|
||||
(#eq? @_annotation "TypeAlias"))
|
||||
|
||||
((assignment
|
||||
left: (identifier) @type.definition
|
||||
right: (call
|
||||
function: (identifier) @_func))
|
||||
(#any-of? @_func "TypeVar" "NewType"))
|
||||
|
||||
; Function calls
|
||||
|
||||
(decorator) @function
|
||||
((decorator (attribute (identifier) @function))
|
||||
(#match? @function "^([A-Z])@!.*$"))
|
||||
(decorator) @function
|
||||
((decorator (identifier) @function)
|
||||
(#match? @function "^([A-Z])@!.*$"))
|
||||
|
||||
(call
|
||||
function: (identifier) @function.call)
|
||||
|
||||
|
|
@ -71,6 +78,26 @@
|
|||
attribute: (identifier) @constructor))
|
||||
(#lua-match? @constructor "^[A-Z]"))
|
||||
|
||||
;; Decorators
|
||||
|
||||
((decorator "@" @attribute)
|
||||
(#set! "priority" 101))
|
||||
|
||||
(decorator
|
||||
(identifier) @attribute)
|
||||
(decorator
|
||||
(attribute
|
||||
attribute: (identifier) @attribute))
|
||||
(decorator
|
||||
(call (identifier) @attribute))
|
||||
(decorator
|
||||
(call (attribute
|
||||
attribute: (identifier) @attribute)))
|
||||
|
||||
((decorator
|
||||
(identifier) @attribute.builtin)
|
||||
(#any-of? @attribute.builtin "classmethod" "property"))
|
||||
|
||||
;; Builtin functions
|
||||
|
||||
((call
|
||||
|
|
@ -233,7 +260,9 @@
|
|||
] @keyword.return
|
||||
(yield "from" @keyword.return)
|
||||
|
||||
(future_import_statement "from" @include "__future__" @constant.builtin)
|
||||
(future_import_statement
|
||||
"from" @include
|
||||
"__future__" @constant.builtin)
|
||||
(import_from_statement "from" @include)
|
||||
"import" @include
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue