diff options
| author | Santos Gallegos <stsewd@protonmail.com> | 2020-08-16 19:25:06 -0500 |
|---|---|---|
| committer | Stephan Seitz <stephan.lauf@yahoo.de> | 2020-08-17 22:23:46 +0200 |
| commit | 6effdfbdc420f1974b091ff9912ca4369ddff20f (patch) | |
| tree | f0f81734412c5f941078f997f96d2672d51c2dbb /queries/python/highlights.scm | |
| parent | Merge pull request #319 from kyazdani42/feat/add-jsx-fragment-and-self-closing (diff) | |
| download | nvim-treesitter-6effdfbdc420f1974b091ff9912ca4369ddff20f.tar nvim-treesitter-6effdfbdc420f1974b091ff9912ca4369ddff20f.tar.gz nvim-treesitter-6effdfbdc420f1974b091ff9912ca4369ddff20f.tar.bz2 nvim-treesitter-6effdfbdc420f1974b091ff9912ca4369ddff20f.tar.lz nvim-treesitter-6effdfbdc420f1974b091ff9912ca4369ddff20f.tar.xz nvim-treesitter-6effdfbdc420f1974b091ff9912ca4369ddff20f.tar.zst nvim-treesitter-6effdfbdc420f1974b091ff9912ca4369ddff20f.zip | |
Python: update highlights
- Fix "as" outside imports
- Add builtin classes and constants
Diffstat (limited to 'queries/python/highlights.scm')
| -rw-r--r-- | queries/python/highlights.scm | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/queries/python/highlights.scm b/queries/python/highlights.scm index f7ad8ea44..93489a446 100644 --- a/queries/python/highlights.scm +++ b/queries/python/highlights.scm @@ -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 |
