Debian Codegraph @

runtime/queries/sway/indents.scm

raw symbols SCIP
1 [
2 (use_list)
3 (block)
4 (match_block)
5 (arguments)
6 (parameters)
7 (declaration_list)
8 (field_declaration_list)
9 (field_initializer_list)
10 (struct_pattern)
11 (tuple_pattern)
12 (unit_expression)
13 (enum_variant_list)
14 (call_expression)
15 (binary_expression)
16 (field_expression)
17 (tuple_expression)
18 (array_expression)
19 (where_clause)
20
21 (token_tree)
22 ] @indent
23
24 [
25 "}"
26 "]"
27 ")"
28 ] @outdent
29
30 ; Indent the right side of assignments.
31 ; The #not-same-line? predicate is required to prevent an extra indent for e.g.
32 ; an else-clause where the previous if-clause starts on the same line as the assignment.
33 (assignment_expression
34 .
35 (_) @expr-start
36 right: (_) @indent
37 (#not-same-line? @indent @expr-start)
38
39 )
40 (compound_assignment_expr
41 .
42 (_) @expr-start
43 right: (_) @indent
44 (#not-same-line? @indent @expr-start)
45
46 )
47 (let_declaration
48 .
49 (_) @expr-start
50 value: (_) @indent
51 alternative: (_)? @indent
52 (#not-same-line? @indent @expr-start)
53
54 )
55 (if_expression
56 .
57 (_) @expr-start
58 condition: (_) @indent
59 (#not-same-line? @indent @expr-start)
60
61 )
62
63 ; Some field expressions where the left part is a multiline expression are not
64 ; indented by cargo fmt.
65 ; Because this multiline expression might be nested in an arbitrary number of
66 ; field expressions, this can only be matched using a Regex.
67 (field_expression
68 value: (_) @val
69 "." @outdent
70 (#match? @val "(\\A[^\\n\\r]+\\([\\t ]*(\\n|\\r).*)|(\\A[^\\n\\r]*\\{[\\t ]*(\\n|\\r))")
71 )