aboutsummaryrefslogtreecommitdiff
path: root/runtime/queries/python
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-05-24 19:18:11 +0000
committerJosh Rahm <joshuarahm@gmail.com>2024-05-24 19:18:11 +0000
commitff7ed8f586589d620a806c3758fac4a47a8e7e15 (patch)
tree729bbcb92231538fa61dab6c3d890b025484b7f5 /runtime/queries/python
parent376914f419eb08fdf4c1a63a77e1f035898a0f10 (diff)
parent28c04948a1c887a1cc0cb64de79fa32631700466 (diff)
downloadrneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.gz
rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.bz2
rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'runtime/queries/python')
-rw-r--r--runtime/queries/python/folds.scm5
-rw-r--r--runtime/queries/python/highlights.scm168
2 files changed, 99 insertions, 74 deletions
diff --git a/runtime/queries/python/folds.scm b/runtime/queries/python/folds.scm
index 7c547db38f..ecb9352d78 100644
--- a/runtime/queries/python/folds.scm
+++ b/runtime/queries/python/folds.scm
@@ -21,3 +21,8 @@
(dictionary)
(string)
] @fold
+
+[
+ (import_statement)
+ (import_from_statement)
+]+ @fold
diff --git a/runtime/queries/python/highlights.scm b/runtime/queries/python/highlights.scm
index 764521c7be..5e5a2a88de 100644
--- a/runtime/queries/python/highlights.scm
+++ b/runtime/queries/python/highlights.scm
@@ -17,11 +17,9 @@
(#lua-match? @constant.builtin "^__[a-zA-Z0-9_]*__$"))
((identifier) @constant.builtin
- ; format-ignore
- (#any-of? @constant.builtin
+ (#any-of? @constant.builtin
; https://docs.python.org/3/library/constants.html
- "NotImplemented" "Ellipsis"
- "quit" "exit" "copyright" "credits" "license"))
+ "NotImplemented" "Ellipsis" "quit" "exit" "copyright" "credits" "license"))
"_" @constant.builtin ; match wildcard
@@ -37,9 +35,8 @@
((assignment
left: (identifier) @type.definition
- right:
- (call
- function: (identifier) @_func))
+ right: (call
+ function: (identifier) @_func))
(#any-of? @_func "TypeVar" "NewType"))
; Function calls
@@ -47,18 +44,16 @@
function: (identifier) @function.call)
(call
- function:
- (attribute
- attribute: (identifier) @function.method.call))
+ function: (attribute
+ attribute: (identifier) @function.method.call))
((call
function: (identifier) @constructor)
(#lua-match? @constructor "^%u"))
((call
- function:
- (attribute
- attribute: (identifier) @constructor))
+ function: (attribute
+ attribute: (identifier) @constructor))
(#lua-match? @constructor "^%u"))
; Decorators
@@ -84,12 +79,19 @@
((decorator
(identifier) @attribute.builtin)
- (#any-of? @attribute.builtin "classmethod" "property"))
+ (#any-of? @attribute.builtin "classmethod" "property" "staticmethod"))
; Builtin functions
((call
function: (identifier) @function.builtin)
- (#any-of? @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__"))
+ (#any-of? @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
(function_definition
@@ -104,10 +106,9 @@
((call
function: (identifier) @_isinstance
- arguments:
- (argument_list
- (_)
- (identifier) @type))
+ arguments: (argument_list
+ (_)
+ (identifier) @type))
(#eq? @_isinstance "isinstance"))
; Normal parameters
@@ -187,7 +188,7 @@
((module
.
- (comment) @keyword.directive)
+ (comment) @keyword.directive @nospell)
(#lua-match? @keyword.directive "^#!/"))
(string) @string
@@ -200,22 +201,44 @@
; doc-strings
(module
.
+ (comment)*
+ .
(expression_statement
- (string) @string.documentation @spell))
+ (string) @string.documentation))
(class_definition
- body:
- (block
- .
- (expression_statement
- (string) @string.documentation @spell)))
+ body: (block
+ .
+ (expression_statement
+ (string) @string.documentation)))
(function_definition
- body:
- (block
- .
- (expression_statement
- (string) @string.documentation @spell)))
+ body: (block
+ .
+ (expression_statement
+ (string) @string.documentation)))
+
+(module
+ .
+ (comment)*
+ .
+ (expression_statement
+ (string
+ (string_content) @spell)))
+
+(class_definition
+ body: (block
+ .
+ (expression_statement
+ (string
+ (string_content) @spell))))
+
+(function_definition
+ body: (block
+ .
+ (expression_statement
+ (string
+ (string_content) @spell))))
; Tokens
[
@@ -277,7 +300,6 @@
[
"assert"
- "class"
"exec"
"global"
"nonlocal"
@@ -285,10 +307,14 @@
"print"
"with"
"as"
- "type"
] @keyword
[
+ "type"
+ "class"
+] @keyword.type
+
+[
"async"
"await"
] @keyword.coroutine
@@ -371,33 +397,28 @@
name: (identifier) @type)
(class_definition
- body:
- (block
- (function_definition
- name: (identifier) @function.method)))
+ body: (block
+ (function_definition
+ name: (identifier) @function.method)))
(class_definition
- superclasses:
- (argument_list
- (identifier) @type))
+ superclasses: (argument_list
+ (identifier) @type))
((class_definition
- body:
- (block
- (expression_statement
- (assignment
- left: (identifier) @variable.member))))
- (#lua-match? @variable.member "^%l.*$"))
+ body: (block
+ (expression_statement
+ (assignment
+ left: (identifier) @variable.member))))
+ (#lua-match? @variable.member "^[%l_].*$"))
((class_definition
- body:
- (block
- (expression_statement
- (assignment
- left:
- (_
- (identifier) @variable.member)))))
- (#lua-match? @variable.member "^%l.*$"))
+ body: (block
+ (expression_statement
+ (assignment
+ left: (_
+ (identifier) @variable.member)))))
+ (#lua-match? @variable.member "^[%l_].*$"))
((class_definition
(block
@@ -406,32 +427,31 @@
(#any-of? @constructor "__new__" "__init__"))
((identifier) @type.builtin
- ; format-ignore
(#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"
+ "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"))
+ "bool" "int" "float" "complex" "list" "tuple" "range" "str" "bytes" "bytearray" "memoryview"
+ "set" "frozenset" "dict" "type" "object"))
; Regex from the `re` module
(call
- function:
- (attribute
- object: (identifier) @_re)
- arguments:
- (argument_list
- .
- (string
- (string_content) @string.regexp))
+ function: (attribute
+ object: (identifier) @_re)
+ arguments: (argument_list
+ .
+ (string
+ (string_content) @string.regexp))
(#eq? @_re "re"))