summaryrefslogtreecommitdiff
path: root/vendor/queries/python/indents.scm
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/queries/python/indents.scm')
-rw-r--r--vendor/queries/python/indents.scm98
1 files changed, 98 insertions, 0 deletions
diff --git a/vendor/queries/python/indents.scm b/vendor/queries/python/indents.scm
new file mode 100644
index 00000000..6e49c2fd
--- /dev/null
+++ b/vendor/queries/python/indents.scm
@@ -0,0 +1,98 @@
+; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389:
+; runtime/queries/python/indents.scm.
+; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE,
+; https://mozilla.org/MPL/2.0/).
+
+[
+ (list)
+ (tuple)
+ (dictionary)
+ (set)
+
+ (if_statement)
+ (for_statement)
+ (while_statement)
+ (with_statement)
+ (try_statement)
+ (match_statement)
+ (case_clause)
+ (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)
+] @indent
+
+; Workaround for the tree-sitter grammar creating large errors when a
+; try_statement is missing the except/finally clause
+(ERROR
+ "try"
+ .
+ ":" @indent @extend)
+(ERROR
+ .
+ "def") @indent @extend
+(ERROR
+ (block) @indent @extend
+ )
+
+[
+ (if_statement)
+ (for_statement)
+ (while_statement)
+ (with_statement)
+ (try_statement)
+ (match_statement)
+ (case_clause)
+
+ (function_definition)
+ (class_definition)
+
+ (except_clause)
+ (finally_clause)
+] @extend
+
+[
+ (return_statement)
+ (break_statement)
+ (continue_statement)
+ (raise_statement)
+ (pass_statement)
+] @extend.prevent-once
+
+[
+ ")"
+ "]"
+ "}"
+] @outdent
+(elif_clause
+ "elif" @outdent)
+(else_clause
+ "else" @outdent)
+(except_clause
+ "except" @outdent)
+(finally_clause
+ "finally" @outdent)
+
+(parameters
+ .
+ (identifier) @anchor
+ ) @align
+(argument_list
+ .
+ (_) @anchor
+ ) @align
+
+; String bodies (triple-quoted strings span lines) are literal content.
+(string) @opaque