summaryrefslogtreecommitdiff
path: root/vendor/queries/javascript
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 03:35:02 -0300
committerGabriel Schneider <[email protected]>2026-11-10 04:08:16 -0300
commite398c24ba19948727affdc6a29254ac69a6b7699 (patch)
tree0770792049a135447b54be2a52367233e786c654 /vendor/queries/javascript
parent22b981446238977d9c3f85eb4856324a9daa9753 (diff)
downloadpardes-e398c24ba19948727affdc6a29254ac69a6b7699.tar.gz
pardes-e398c24ba19948727affdc6a29254ac69a6b7699.zip
syntax: helix's indents.scm vendored beside each grammar's textobjects.scm and embedded the same way (zig's adapted to this grammar's node names, rust's \A regexes written with ^, erlang's left out as it does not compile here), compiled when first asked for as a Lazy beside the textobjects, so a new line can take its indent from the tree
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'vendor/queries/javascript')
-rw-r--r--vendor/queries/javascript/indents.scm72
1 files changed, 72 insertions, 0 deletions
diff --git a/vendor/queries/javascript/indents.scm b/vendor/queries/javascript/indents.scm
new file mode 100644
index 00000000..ec0512ca
--- /dev/null
+++ b/vendor/queries/javascript/indents.scm
@@ -0,0 +1,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