aboutsummaryrefslogtreecommitdiff
path: root/helix-22.03-x86_64-windows/runtime/queries/python
diff options
context:
space:
mode:
Diffstat (limited to 'helix-22.03-x86_64-windows/runtime/queries/python')
-rw-r--r--helix-22.03-x86_64-windows/runtime/queries/python/highlights.scm121
-rw-r--r--helix-22.03-x86_64-windows/runtime/queries/python/indents.toml39
-rw-r--r--helix-22.03-x86_64-windows/runtime/queries/python/injections.scm2
-rw-r--r--helix-22.03-x86_64-windows/runtime/queries/python/tags.scm12
-rw-r--r--helix-22.03-x86_64-windows/runtime/queries/python/textobjects.scm18
5 files changed, 192 insertions, 0 deletions
diff --git a/helix-22.03-x86_64-windows/runtime/queries/python/highlights.scm b/helix-22.03-x86_64-windows/runtime/queries/python/highlights.scm
new file mode 100644
index 0000000..9131acc
--- /dev/null
+++ b/helix-22.03-x86_64-windows/runtime/queries/python/highlights.scm
@@ -0,0 +1,121 @@
+; Identifier naming conventions
+
+((identifier) @constructor
+ (#match? @constructor "^[A-Z]"))
+
+((identifier) @constant
+ (#match? @constant "^[A-Z][A-Z_]*$"))
+
+; Builtin functions
+
+((call
+ function: (identifier) @function.builtin)
+ (#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 calls
+
+(decorator) @function
+
+(call
+ function: (attribute attribute: (identifier) @function.method))
+(call
+ function: (identifier) @function)
+
+; Function definitions
+
+(function_definition
+ name: (identifier) @function)
+
+(identifier) @variable
+(attribute attribute: (identifier) @variable.other.member)
+(type (identifier) @type)
+
+; Literals
+
+[
+ (none)
+ (true)
+ (false)
+] @constant.builtin
+
+(integer) @constant.numeric.integer
+(float) @constant.numeric.float
+(comment) @comment
+(string) @string
+(escape_sequence) @constant.character.escape
+
+(interpolation
+ "{" @punctuation.special
+ "}" @punctuation.special) @embedded
+
+[
+ "-"
+ "-="
+ "!="
+ "*"
+ "**"
+ "**="
+ "*="
+ "/"
+ "//"
+ "//="
+ "/="
+ "&"
+ "%"
+ "%="
+ "^"
+ "+"
+ "->"
+ "+="
+ "<"
+ "<<"
+ "<="
+ "<>"
+ "="
+ ":="
+ "=="
+ ">"
+ ">="
+ ">>"
+ "|"
+ "~"
+ "and"
+ "in"
+ "is"
+ "not"
+ "or"
+] @operator
+
+[
+ "as"
+ "assert"
+ "async"
+ "await"
+ "break"
+ "class"
+ "continue"
+ "def"
+ "del"
+ "elif"
+ "else"
+ "except"
+ "exec"
+ "finally"
+ "for"
+ "from"
+ "global"
+ "if"
+ "import"
+ "lambda"
+ "nonlocal"
+ "pass"
+ "print"
+ "raise"
+ "return"
+ "try"
+ "while"
+ "with"
+ "yield"
+] @keyword
diff --git a/helix-22.03-x86_64-windows/runtime/queries/python/indents.toml b/helix-22.03-x86_64-windows/runtime/queries/python/indents.toml
new file mode 100644
index 0000000..6bc6848
--- /dev/null
+++ b/helix-22.03-x86_64-windows/runtime/queries/python/indents.toml
@@ -0,0 +1,39 @@
+indent = [
+ "list",
+ "tuple",
+ "dictionary",
+ "set",
+
+ "if_statement",
+ "for_statement",
+ "while_statement",
+ "with_statement",
+ "try_statement",
+ "import_from_statement",
+
+ "parenthesized_expression",
+ "generator_expression",
+ "list_comprehension",
+ "set_comprehension",
+ "dictionary_comprehension",
+
+ "tuple_pattern",
+ "list_pattern",
+ "argument_list",
+ "parameters",
+ "binary_operator",
+
+ "function_definition",
+ "class_definition",
+]
+
+outdent = [
+ ")",
+ "]",
+ "}",
+ "return_statement",
+ "pass_statement",
+ "raise_statement",
+]
+
+ignore = ["string"]
diff --git a/helix-22.03-x86_64-windows/runtime/queries/python/injections.scm b/helix-22.03-x86_64-windows/runtime/queries/python/injections.scm
new file mode 100644
index 0000000..321c90a
--- /dev/null
+++ b/helix-22.03-x86_64-windows/runtime/queries/python/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))
diff --git a/helix-22.03-x86_64-windows/runtime/queries/python/tags.scm b/helix-22.03-x86_64-windows/runtime/queries/python/tags.scm
new file mode 100644
index 0000000..c5ca827
--- /dev/null
+++ b/helix-22.03-x86_64-windows/runtime/queries/python/tags.scm
@@ -0,0 +1,12 @@
+(class_definition
+ name: (identifier) @name) @definition.class
+
+(function_definition
+ name: (identifier) @name) @definition.function
+
+(call
+ function: [
+ (identifier) @name
+ (attribute
+ attribute: (identifier) @name)
+ ]) @reference.call
diff --git a/helix-22.03-x86_64-windows/runtime/queries/python/textobjects.scm b/helix-22.03-x86_64-windows/runtime/queries/python/textobjects.scm
new file mode 100644
index 0000000..0ca2608
--- /dev/null
+++ b/helix-22.03-x86_64-windows/runtime/queries/python/textobjects.scm
@@ -0,0 +1,18 @@
+(function_definition
+ body: (block)? @function.inside) @function.around
+
+(class_definition
+ body: (block)? @class.inside) @class.around
+
+(parameters
+ (_) @parameter.inside)
+
+(lambda_parameters
+ (_) @parameter.inside)
+
+(argument_list
+ (_) @parameter.inside)
+
+(comment) @comment.inside
+
+(comment)+ @comment.around