blob: ad33accc77b95414a25da4d7a7506bc5bf20144b (
plain) (
blame)
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
|
; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389:
; runtime/queries/java/indents.scm.
; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE,
; https://mozilla.org/MPL/2.0/).
[
(class_body)
(enum_body)
(interface_body)
(constructor_body)
(annotation_type_body)
(module_body)
(block)
(switch_block)
; statements after a `case`/`default` label (the group also holds the label,
; so the default tail scope indents only the body lines, not the label)
(switch_block_statement_group)
(array_initializer)
(argument_list)
(formal_parameters)
(annotation_argument_list)
(element_value_array_initializer)
] @indent
[
"}"
")"
"]"
] @outdent
; Single statement after if/while/for without braces. Capture the body child
; naturally; on a typed newline the engine descends into it.
(if_statement
consequence: (_) @indent
(#not-kind-eq? @indent "block")
(#set! "scope" "header"))
; Braceless `else` body (the body is the alternative field). Skip `else if`
; (alternative is an if_statement) and braced bodies.
(if_statement
alternative: (_) @indent
(#not-kind-eq? @indent "block")
(#not-kind-eq? @indent "if_statement")
(#set! "scope" "header"))
(while_statement
body: (_) @indent
(#not-kind-eq? @indent "block")
(#set! "scope" "header"))
(for_statement
body: (_) @indent
(#not-kind-eq? @indent "block")
(#set! "scope" "header"))
(string_literal) @opaque
|