blob: ec0512ca5dc77d8b33ba94a9c851c6fc444fd9ce (
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389:
; runtime/queries/javascript/indents.scm, with what it inherits from ecma inlined (_javascript has none).
; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE,
; https://mozilla.org/MPL/2.0/).
[
(array)
(object)
(arguments)
(formal_parameters)
(statement_block)
(switch_statement)
(object_pattern)
(class_body)
(named_imports)
(binary_expression)
(return_statement)
(template_substitution)
(export_clause)
(member_expression)
(call_expression)
] @indent
[
(switch_case)
(switch_default)
] @indent
[
"}"
"]"
")"
] @outdent
; Single-statement bodies without braces (if/else/while/for/do). Indent the
; statement node so a newline typed after the header indents — capturing the
; body child alone only reindents existing lines, since the typing-direction
; walk reaches the statement, not its body child. The else-bearing if keeps the
; consequence-child form (scope all) so the `else` line itself isn't indented;
; a braceless else/do body is handled via its own node for the same reason.
(if_statement
consequence: (_) @_body
(#not-kind-eq? @_body "statement_block")
!alternative) @indent
(if_statement
consequence: (_) @indent
(#not-kind-eq? @indent "statement_block")
alternative: (_)
(#set! "scope" "header"))
(else_clause
(_) @_body
(#not-kind-eq? @_body "statement_block")
(#not-kind-eq? @_body "if_statement")) @indent
(while_statement
body: (_) @_body
(#not-kind-eq? @_body "statement_block")) @indent
(for_statement
body: (_) @_body
(#not-kind-eq? @_body "statement_block")) @indent
(for_in_statement
body: (_) @_body
(#not-kind-eq? @_body "statement_block")) @indent
(do_statement
body: (_) @indent
(#not-kind-eq? @indent "statement_block")
(#set! "scope" "header"))
; Template-literal bodies are literal content (between interpolations).
(template_string) @opaque
|