mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
Python: update highlights
- Fix "as" outside imports - Add builtin classes and constants
This commit is contained in:
parent
54b485ba7b
commit
6effdfbdc4
1 changed files with 15 additions and 4 deletions
|
|
@ -13,10 +13,20 @@
|
|||
((identifier) @constant.builtin
|
||||
(#match? @constant.builtin "^__[a-zA-Z0-9_]*__$"))
|
||||
|
||||
((identifier) @constant.builtin
|
||||
(#vim-match? @constant.builtin
|
||||
;; https://docs.python.org/3/library/constants.html
|
||||
"^(NotImplemented|Ellipsis|quit|exit|copyright|credits|license)$"))
|
||||
|
||||
((attribute
|
||||
attribute: (identifier) @field)
|
||||
(#match? @field "^([A-Z])@!.*$"))
|
||||
|
||||
((identifier) @type.builtin
|
||||
(#vim-match? @type.builtin
|
||||
;; https://docs.python.org/3/library/exceptions.html
|
||||
"^(BaseException|Exception|ArithmeticError|BufferError|LookupError|AssertionError|AttributeError|EOFError|FloatingPointError|GeneratorExit|ImportError|ModuleNotFoundError|IndexError|KeyError|KeyboardInterrupt|MemoryError|NameError|NotImplementedError|OSError|OverflowError|RecursionError|ReferenceError|RuntimeError|StopIteration|StopAsyncIteration|SyntaxError|IndentationError|TabError|SystemError|SystemExit|TypeError|UnboundLocalError|UnicodeError|UnicodeEncodeError|UnicodeDecodeError|UnicodeTranslateError|ValueError|ZeroDivisionError|EnvironmentError|IOError|WindowsError|BlockingIOError|ChildProcessError|ConnectionError|BrokenPipeError|ConnectionAbortedError|ConnectionRefusedError|ConnectionResetError|FileExistsError|FileNotFoundError|InterruptedError|IsADirectoryError|NotADirectoryError|PermissionError|ProcessLookupError|TimeoutError|Warning|UserWarning|DeprecationWarning|PendingDeprecationWarning|SyntaxWarning|RuntimeWarning|FutureWarning|ImportWarning|UnicodeWarning|BytesWarning|ResourceWarning)$"))
|
||||
|
||||
; Function calls
|
||||
|
||||
(decorator) @function
|
||||
|
|
@ -43,9 +53,8 @@
|
|||
|
||||
((call
|
||||
function: (identifier) @function.builtin)
|
||||
(vim-match?
|
||||
@function.builtin
|
||||
"^(abs|all|any|ascii|bin|bool|breakpoint|bytearray|bytes|callable|chr|classmethod|compile|complex|delattr|dict|dir|divmod|enumerate|eval|exec|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|isinstance|issubclass|iter|len|list|locals|map|max|memoryview|min|next|object|oct|open|ord|pow|print|property|range|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|vars|zip|__import__)$"))
|
||||
(vim-match? @function.builtin
|
||||
"^(abs|all|any|ascii|bin|bool|breakpoint|bytearray|bytes|callable|chr|classmethod|compile|complex|delattr|dict|dir|divmod|enumerate|eval|exec|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|isinstance|issubclass|iter|len|list|locals|map|max|memoryview|min|next|object|oct|open|ord|pow|print|property|range|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|vars|zip|__import__)$"))
|
||||
|
||||
;; Function definitions
|
||||
|
||||
|
|
@ -168,9 +177,11 @@
|
|||
"try"
|
||||
"with"
|
||||
"yield"
|
||||
"as"
|
||||
] @keyword
|
||||
|
||||
["as" "from" "import"] @include
|
||||
["from" "import"] @include
|
||||
(aliased_import "as" @include)
|
||||
|
||||
["if" "elif" "else"] @conditional
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue