Debian Codegraph @

runtime/queries/c/indents.scm

raw symbols SCIP
1 [
2 (compound_statement)
3 (declaration_list)
4 (field_declaration_list)
5 (enumerator_list)
6 (parameter_list)
7 (init_declarator)
8 (expression_statement)
9 ] @indent
10
11 [
12 "case"
13 "default"
14 "}"
15 "]"
16 ")"
17 ] @outdent
18
19 ; Single statement after if/while/for/do without braces. Capture the body child
20 ; naturally; on a typed newline the engine descends into it (no wrapper trick).
21 (if_statement
22 consequence: (_) @indent
23 (#not-kind-eq? @indent "compound_statement")
24 (#set! "scope" "header"))
25 (while_statement
26 body: (_) @indent
27 (#not-kind-eq? @indent "compound_statement")
28 (#set! "scope" "header"))
29 (do_statement
30 body: (_) @indent
31 (#not-kind-eq? @indent "compound_statement")
32 (#set! "scope" "header"))
33 (for_statement
34 body: (_) @indent
35 (#not-kind-eq? @indent "compound_statement")
36 (#set! "scope" "header"))
37
38 (parameter_list
39 . (parameter_declaration) @anchor
40 ) @align
41 (argument_list
42 . (_) @anchor
43 ) @align
44 ; These are a bit opinionated since some people just indent binary/ternary expressions spanning multiple lines.
45 ; Since they are only triggered when a newline is inserted into an already complete binary/ternary expression,
46 ; this should happen rarely, so it is not a big deal either way.
47 ; Additionally, adding these queries has the advantage of preventing such continuation lines from being used
48 ; as the baseline when the `hybrid` indent heuristic is used (which is desirable since their indentation is so inconsistent).
49 (binary_expression
50 ) @anchor @align
51 (conditional_expression
52 "?" @anchor
53 ) @align