From e398c24ba19948727affdc6a29254ac69a6b7699 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 03:35:02 -0300 Subject: 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 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- vendor/queries/javascript/indents.scm | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 vendor/queries/javascript/indents.scm (limited to 'vendor/queries/javascript') 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 -- cgit v1.3