aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/rust/indents.scm
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/queries/rust/indents.scm')
-rw-r--r--runtime/queries/rust/indents.scm132
1 files changed, 132 insertions, 0 deletions
diff --git a/runtime/queries/rust/indents.scm b/runtime/queries/rust/indents.scm
new file mode 100644
index 000000000..9fe337d5c
--- /dev/null
+++ b/runtime/queries/rust/indents.scm
@@ -0,0 +1,132 @@
+[
+ (mod_item)
+ (struct_item)
+ (enum_item)
+ (impl_item)
+ (struct_expression)
+ (struct_pattern)
+ (tuple_struct_pattern)
+ (tuple_expression)
+ (tuple_type)
+ (tuple_pattern)
+ (match_block)
+ (call_expression)
+ (assignment_expression)
+ (arguments)
+ (block)
+ (where_clause)
+ (use_list)
+ (array_expression)
+ (ordered_field_declaration_list)
+ (field_declaration_list)
+ (enum_variant_list)
+ (parameters)
+ (token_tree)
+ (token_repetition)
+ (macro_definition)
+] @indent.begin
+
+(trait_item
+ body: (_) @indent.begin)
+
+(string_literal
+ (escape_sequence)) @indent.begin
+
+; Typing in "(" inside macro definitions breaks the tree entirely
+; Making macro_definition becoming errors
+; Offset this by adding back one indent for start of macro rules
+(ERROR
+ .
+ "macro_rules!"
+ [
+ "("
+ "{"
+ "["
+ ] @indent.begin
+ (#set! indent.immediate)
+ (#set! indent.start_at_same_line))
+
+(macro_definition
+ [
+ ")"
+ "}"
+ "]"
+ ] @indent.end)
+
+(trait_item
+ body: (_) @indent.begin)
+
+(string_literal
+ (escape_sequence)) @indent.begin
+
+(block
+ "}" @indent.end)
+
+(enum_item
+ body: (enum_variant_list
+ "}" @indent.end))
+
+(impl_item
+ body: (declaration_list
+ "}" @indent.end))
+
+(match_expression
+ body: (match_block
+ "}" @indent.end))
+
+(mod_item
+ body: (declaration_list
+ "}" @indent.end))
+
+(struct_item
+ body: (field_declaration_list
+ "}" @indent.end))
+
+(struct_expression
+ body: (field_initializer_list
+ "}" @indent.end))
+
+(struct_pattern
+ "}" @indent.end)
+
+(tuple_struct_pattern
+ ")" @indent.end)
+; Typing in "(" inside macro definitions breaks the tree entirely
+; Making macro_definition becoming errors
+; Offset this by adding back one indent for start of macro rules
+(ERROR
+ .
+ "macro_rules!"
+ "(" @indent.begin
+ (#set! indent.immediate)
+ (#set! indent.start_at_same_line))
+
+(tuple_type
+ ")" @indent.end)
+
+(tuple_pattern
+ ")" @indent.end)
+
+(trait_item
+ body: (declaration_list
+ "}" @indent.end))
+
+(impl_item
+ (where_clause) @indent.dedent)
+
+[
+ "where"
+ ")"
+ "]"
+ "}"
+] @indent.branch
+
+(impl_item
+ (declaration_list) @indent.branch)
+
+[
+ (line_comment)
+ (string_literal)
+] @indent.ignore
+
+(raw_string_literal) @indent.auto