aboutsummaryrefslogtreecommitdiffstats
path: root/queries/python
diff options
context:
space:
mode:
Diffstat (limited to 'queries/python')
-rw-r--r--queries/python/highlights.scm49
1 files changed, 25 insertions, 24 deletions
diff --git a/queries/python/highlights.scm b/queries/python/highlights.scm
index 77edc7960..d0759e26b 100644
--- a/queries/python/highlights.scm
+++ b/queries/python/highlights.scm
@@ -23,10 +23,6 @@
"_" @character.special ; match wildcard
-((attribute
- attribute: (identifier) @variable.member)
- (#lua-match? @variable.member "^[%l_].*$"))
-
((assignment
left: (identifier) @type.definition
(type
@@ -395,6 +391,31 @@
(ellipsis)
] @punctuation.delimiter
+((identifier) @type.builtin
+ (#any-of? @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"
+ ; https://docs.python.org/3/library/stdtypes.html
+ "bool" "int" "float" "complex" "list" "tuple" "range" "str" "bytes" "bytearray" "memoryview"
+ "set" "frozenset" "dict" "type" "object"))
+
+; After @type.builtin bacause builtins (such as `type`) are valid as attribute name
+((attribute
+ attribute: (identifier) @variable.member)
+ (#lua-match? @variable.member "^[%l_].*$"))
+
; Class definitions
(class_definition
name: (identifier) @type)
@@ -429,26 +450,6 @@
name: (identifier) @constructor)))
(#any-of? @constructor "__new__" "__init__"))
-((identifier) @type.builtin
- (#any-of? @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"
- ; https://docs.python.org/3/library/stdtypes.html
- "bool" "int" "float" "complex" "list" "tuple" "range" "str" "bytes" "bytearray" "memoryview"
- "set" "frozenset" "dict" "type" "object"))
-
; Regex from the `re` module
(call
function: (attribute