aboutsummaryrefslogtreecommitdiff
path: root/queries/jai/indents.scm
blob: 82b0331ec392497e7fdcbb17c48cf4ef748fa9cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
; Some documentation I found in a random github issue
;   @indent.begin       ; indent children when matching this node
;   @indent.end         ; marks the end of indented block
;   @indent.align       ; behaves like python aligned/hanging indent
;   @indent.dedent      ; dedent children when matching this node
;   @indent.branch      ; dedent itself when matching this node
;   @indent.ignore      ; do not indent in this node
;   @indent.auto        ; behaves like 'autoindent' buffer option
;   @indent.zero        ; sets this node at position 0 (no indent)

; NOTE: these don't work well with Allman style.
; Also; I am really bad at this. There is almost no documentation available and I don't speak lisp or whichever of it's flavors this is.

; Incomplete

[
  (block)
  (enum_declaration "{")
  (struct_or_union_block "{")
  (struct_literal "{")
  (anonymous_enum_type "{")
  (asm_statement "{")
  (array_literal "[")
  (index_expression "[")
  (literal)
  (assignment_parameters "(")
] @indent.begin

((modify_block) @indent.end)
((place_directive) @indent.branch)

; only indent the first statement after an if
(if_statement_condition_and_consequence
  consequence: (_
    ";" @indent.end) @_consequence
  (#not-match? @_consequence "\\{")
) @indent.begin

(else_clause) @indent.branch

; This is a workaround. I can't get 'else if' indentation to work properly.
(else_clause
  consequence: (_) @_consequence
  (#match? @_consequence "if")
) @indent.auto

(if_case_statement) @indent.begin
(switch_case ";") @indent.branch

((identifier) . (ERROR "(" @indent.begin))

(block
  "}" @indent.end)

[
  ")"
  "]"
  "}"
] @indent.branch @indent.end

[
  (comment)
  (block_comment)
  (string)
  (ERROR)
] @indent.auto