diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 03:35:02 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 04:08:16 -0300 |
| commit | e398c24ba19948727affdc6a29254ac69a6b7699 (patch) | |
| tree | 0770792049a135447b54be2a52367233e786c654 /vendor | |
| parent | 22b981446238977d9c3f85eb4856324a9daa9753 (diff) | |
| download | pardes-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')
| -rw-r--r-- | vendor/queries/README.md | 15 | ||||
| -rw-r--r-- | vendor/queries/bash/indents.scm | 23 | ||||
| -rw-r--r-- | vendor/queries/c/indents.scm | 58 | ||||
| -rw-r--r-- | vendor/queries/c_sharp/indents.scm | 20 | ||||
| -rw-r--r-- | vendor/queries/clojure/indents.scm | 65 | ||||
| -rw-r--r-- | vendor/queries/cpp/indents.scm | 63 | ||||
| -rw-r--r-- | vendor/queries/css/indents.scm | 12 | ||||
| -rw-r--r-- | vendor/queries/elixir/indents.scm | 27 | ||||
| -rw-r--r-- | vendor/queries/fortran/indents.scm | 36 | ||||
| -rw-r--r-- | vendor/queries/go/indents.scm | 55 | ||||
| -rw-r--r-- | vendor/queries/html/indents.scm | 20 | ||||
| -rw-r--r-- | vendor/queries/java/indents.scm | 53 | ||||
| -rw-r--r-- | vendor/queries/javascript/indents.scm | 72 | ||||
| -rw-r--r-- | vendor/queries/json/indents.scm | 14 | ||||
| -rw-r--r-- | vendor/queries/kotlin/indents.scm | 51 | ||||
| -rw-r--r-- | vendor/queries/ocaml/indents.scm | 27 | ||||
| -rw-r--r-- | vendor/queries/php/indents.scm | 34 | ||||
| -rw-r--r-- | vendor/queries/python/indents.scm | 98 | ||||
| -rw-r--r-- | vendor/queries/ruby/indents.scm | 32 | ||||
| -rw-r--r-- | vendor/queries/rust/indents.scm | 166 | ||||
| -rw-r--r-- | vendor/queries/scala/indents.scm | 29 | ||||
| -rw-r--r-- | vendor/queries/zig/indents.scm | 22 |
22 files changed, 991 insertions, 1 deletions
diff --git a/vendor/queries/README.md b/vendor/queries/README.md index 082f4e6b..2977e1cc 100644 --- a/vendor/queries/README.md +++ b/vendor/queries/README.md @@ -1,4 +1,4 @@ -# Textobject queries +# Textobject and indent queries `<grammar>/textobjects.scm` is helix's own query for that grammar, vendored from helix (https://github.com/helix-editor/helix) at 278b24389, the @@ -16,3 +16,16 @@ them), and erlang, whose helix query does not compile against the grammar version pardes builds. Those grammars have no textobjects, and the keys do nothing there, as in helix without a query. + +`<grammar>/indents.scm` is helix's indent query for that grammar, vendored +the same way from the same commit, for src/indent.zig: the indent a new line +takes on Enter, `o` and `O`. Vendored for bash, c, c_sharp, clojure, cpp +(with c's inlined), css, elixir, fortran, go, html, java, javascript (ecma's +inlined), json, kotlin, ocaml, php, python, ruby, rust, scala and zig. +`zig/indents.scm` is MODIFIED for this zig grammar's node names, and +`rust/indents.scm` writes its three `#match?` regexes with `^` where helix's +open with `\A`, which mvzr does not know; their headers say so. Not vendored: +ada, haskell, markdown, pascal, powershell and typst (helix has no indent +query for them), and erlang, whose query does not compile against the +grammar version pardes builds. A file of those keeps acme's autoindent, the +line's own indent as it is. diff --git a/vendor/queries/bash/indents.scm b/vendor/queries/bash/indents.scm new file mode 100644 index 00000000..5ca59a57 --- /dev/null +++ b/vendor/queries/bash/indents.scm @@ -0,0 +1,23 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/bash/indents.scm. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (function_definition) + (if_statement) + (for_statement) + (while_statement) + (case_statement) + (case_item) + (pipeline) +] @indent + +[ + "}" + "fi" + "elif" + "else" + "done" + "esac" +] @outdent diff --git a/vendor/queries/c/indents.scm b/vendor/queries/c/indents.scm new file mode 100644 index 00000000..0ed0b66d --- /dev/null +++ b/vendor/queries/c/indents.scm @@ -0,0 +1,58 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/c/indents.scm. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (compound_statement) + (declaration_list) + (field_declaration_list) + (enumerator_list) + (parameter_list) + (init_declarator) + (expression_statement) +] @indent + +[ + "case" + "default" + "}" + "]" + ")" +] @outdent + +; Single statement after if/while/for/do without braces. Capture the body child +; naturally; on a typed newline the engine descends into it (no wrapper trick). +(if_statement + consequence: (_) @indent + (#not-kind-eq? @indent "compound_statement") + (#set! "scope" "header")) +(while_statement + body: (_) @indent + (#not-kind-eq? @indent "compound_statement") + (#set! "scope" "header")) +(do_statement + body: (_) @indent + (#not-kind-eq? @indent "compound_statement") + (#set! "scope" "header")) +(for_statement + body: (_) @indent + (#not-kind-eq? @indent "compound_statement") + (#set! "scope" "header")) + +(parameter_list + . (parameter_declaration) @anchor + ) @align +(argument_list + . (_) @anchor + ) @align +; These are a bit opinionated since some people just indent binary/ternary expressions spanning multiple lines. +; Since they are only triggered when a newline is inserted into an already complete binary/ternary expression, +; this should happen rarely, so it is not a big deal either way. +; Additionally, adding these queries has the advantage of preventing such continuation lines from being used +; as the baseline when the `hybrid` indent heuristic is used (which is desirable since their indentation is so inconsistent). +(binary_expression + ) @anchor @align +(conditional_expression + "?" @anchor + ) @align diff --git a/vendor/queries/c_sharp/indents.scm b/vendor/queries/c_sharp/indents.scm new file mode 100644 index 00000000..bf875d4b --- /dev/null +++ b/vendor/queries/c_sharp/indents.scm @@ -0,0 +1,20 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/c-sharp/indents.scm. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (declaration_list) + (block) + (enum_member_declaration_list) + (accessor_list) + (switch_body) + (switch_section) + (initializer_expression) +] @indent + +[ + "}" + ")" + "]" +] @outdent diff --git a/vendor/queries/clojure/indents.scm b/vendor/queries/clojure/indents.scm new file mode 100644 index 00000000..5c232fc9 --- /dev/null +++ b/vendor/queries/clojure/indents.scm @@ -0,0 +1,65 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/clojure/indents.scm. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +; If a list has 2 elements on the first line, align to the second element. +; Exclude literals and special keywords that have different indentation rules. +(list_lit . (_) @first . (_) @anchor + (#same-line? @first @anchor) + + (#not-kind-eq? @first "bool_lit") + (#not-kind-eq? @first "nil_lit") + (#not-kind-eq? @first "str_lit") + (#not-kind-eq? @first "num_lit") + (#not-kind-eq? @first "kwd_lit") + (#not-match? @first "^(def|defn|defn-|defmacro|defmethod|defmulti|defonce|defprotocol|deftype|defrecord|defstruct|definline|definterface|deftest|ns|let|letfn|binding|loop|for|doseq|dotimes|when-let|if-let|when-some|if-some|with-.*|fn)$")) @align + +; If the first element in a list is also a list and on a line by itself, +; the outer list is aligned to it +(list_lit . (list_lit) @anchor . + ) @align + +(list_lit . (list_lit) @anchor . (_) @second + (#not-same-line? @anchor @second) + ) @align + +; If the first element in a list is not a list and on a line by itself, +; indent the list body by one level +(list_lit . (_) @first . + (#not-kind-eq? @first "bool_lit") + (#not-kind-eq? @first "nil_lit") + (#not-kind-eq? @first "str_lit") + (#not-kind-eq? @first "num_lit") + (#not-kind-eq? @first "kwd_lit") + (#not-match? @first "^(def|defn|defn-|defmacro|defmethod|defmulti|defonce|defprotocol|deftype|defrecord|defstruct|definline|definterface|deftest|ns|let|letfn|binding|loop|for|doseq|dotimes|when-let|if-let|when-some|if-some|with-.*|fn)$")) @indent + +(list_lit . (_) @first . (_) @second + (#not-same-line? @first @second) + (#not-kind-eq? @first "bool_lit") + (#not-kind-eq? @first "nil_lit") + (#not-kind-eq? @first "str_lit") + (#not-kind-eq? @first "num_lit") + (#not-kind-eq? @first "kwd_lit") + (#not-match? @first "^(def|defn|defn-|defmacro|defmethod|defmulti|defonce|defprotocol|deftype|defrecord|defstruct|definline|definterface|deftest|ns|let|letfn|binding|loop|for|doseq|dotimes|when-let|if-let|when-some|if-some|with-.*|fn)$")) @indent + +; If the first element is a literal, align the list to it +(list_lit . [(bool_lit) (nil_lit) (str_lit) (num_lit) (kwd_lit)] @anchor + ) @align + +; Special indentation for def-like forms, let bindings, and other special forms +; These forms typically have the body indented by one level after the name/bindings +(list_lit . (sym_lit) @first + (#match? @first "^(def|defn|defn-|defmacro|defmethod|defmulti|defonce|defprotocol|deftype|defrecord|defstruct|definline|definterface|deftest|ns|let|letfn|binding|loop|for|doseq|dotimes|when-let|if-let|when-some|if-some|with-.*|fn)$")) @indent + +; Align vector/map elements when first two are on same line (e.g., let bindings) +(vec_lit . (_) @anchor . (_) @second + (#same-line? @anchor @second) + ) @align + +(map_lit . (_) @anchor . (_) @second + (#same-line? @anchor @second) + ) @align + +; Indent vectors, maps, and sets +[(vec_lit) (map_lit) (set_lit)] @indent diff --git a/vendor/queries/cpp/indents.scm b/vendor/queries/cpp/indents.scm new file mode 100644 index 00000000..ea91ba4b --- /dev/null +++ b/vendor/queries/cpp/indents.scm @@ -0,0 +1,63 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/cpp/indents.scm, with what it inherits from c inlined. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (compound_statement) + (declaration_list) + (field_declaration_list) + (enumerator_list) + (parameter_list) + (init_declarator) + (expression_statement) +] @indent + +[ + "case" + "default" + "}" + "]" + ")" +] @outdent + +; Single statement after if/while/for/do without braces. Capture the body child +; naturally; on a typed newline the engine descends into it (no wrapper trick). +(if_statement + consequence: (_) @indent + (#not-kind-eq? @indent "compound_statement") + (#set! "scope" "header")) +(while_statement + body: (_) @indent + (#not-kind-eq? @indent "compound_statement") + (#set! "scope" "header")) +(do_statement + body: (_) @indent + (#not-kind-eq? @indent "compound_statement") + (#set! "scope" "header")) +(for_statement + body: (_) @indent + (#not-kind-eq? @indent "compound_statement") + (#set! "scope" "header")) + +(parameter_list + . (parameter_declaration) @anchor + ) @align +(argument_list + . (_) @anchor + ) @align +; These are a bit opinionated since some people just indent binary/ternary expressions spanning multiple lines. +; Since they are only triggered when a newline is inserted into an already complete binary/ternary expression, +; this should happen rarely, so it is not a big deal either way. +; Additionally, adding these queries has the advantage of preventing such continuation lines from being used +; as the baseline when the `hybrid` indent heuristic is used (which is desirable since their indentation is so inconsistent). +(binary_expression + ) @anchor @align +(conditional_expression + "?" @anchor + ) @align + + +(access_specifier) @outdent + +(raw_string_literal) @opaque diff --git a/vendor/queries/css/indents.scm b/vendor/queries/css/indents.scm new file mode 100644 index 00000000..e42c3be0 --- /dev/null +++ b/vendor/queries/css/indents.scm @@ -0,0 +1,12 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/css/indents.scm. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (block) +] @indent + +[ + "}" +] @outdent diff --git a/vendor/queries/elixir/indents.scm b/vendor/queries/elixir/indents.scm new file mode 100644 index 00000000..cc535930 --- /dev/null +++ b/vendor/queries/elixir/indents.scm @@ -0,0 +1,27 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/elixir/indents.scm. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (anonymous_function) + (do_block) + (stab_clause) + (map) + (list) + (tuple) +] @indent + +; The else/rescue/catch/after clause blocks nest *inside* the do_block, which +; already provides the body's one level of indent; the keyword itself outdents +; back to the construct's level. +[ + "end" + "else" + "rescue" + "catch" + "after" + "]" + "}" + ")" +] @outdent diff --git a/vendor/queries/fortran/indents.scm b/vendor/queries/fortran/indents.scm new file mode 100644 index 00000000..073d4f32 --- /dev/null +++ b/vendor/queries/fortran/indents.scm @@ -0,0 +1,36 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/fortran/indents.scm. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (module) + (submodule) + (program) + (subroutine) + (module_procedure) + (function) + ; (interface) + (if_statement) + (do_loop) + (where_statement) + (derived_type_definition) + (enum) +] @indent + +[ + (end_module_statement) + (end_submodule_statement) + (end_program_statement) + (end_subroutine_statement) + (end_module_procedure_statement) + (end_function_statement) + ; (end_interface_statement) + (end_if_statement) + (end_do_loop_statement) + (else_clause) + (elseif_clause) + (end_type_statement) + (end_enum_statement) + (end_where_statement) +] @outdent diff --git a/vendor/queries/go/indents.scm b/vendor/queries/go/indents.scm new file mode 100644 index 00000000..3734f458 --- /dev/null +++ b/vendor/queries/go/indents.scm @@ -0,0 +1,55 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/go/indents.scm. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (import_declaration) + (const_declaration) + (type_declaration) + (type_spec) + (func_literal) + (literal_value) + (literal_element) + (keyed_element) + (expression_case) + (default_case) + (type_case) + (communication_case) + (argument_list) + (parameter_list) + (field_declaration_list) + (block) + (var_declaration) + (selector_expression) + (binary_expression) +] @indent + +[ + "]" + ")" +] @outdent + +; Switches and selects aren't indented, only their case bodies are. +; Outdent all closing braces except those closing switches or selects. +( + (_ "}" @outdent) @outer + (#not-kind-eq? @outer "select_statement") + (#not-kind-eq? @outer "type_switch_statement") + (#not-kind-eq? @outer "expression_switch_statement") +) + +; Handle ERROR nodes for when auto-pairs is disabled. +; Typing an opening delimiter without a closing one produces an ERROR node. +(ERROR "{") @indent @extend +(ERROR "(") @indent +(ERROR "[") @indent + +; Labels (`Loop:`, `done:`) are de-indented one level by gofmt. +; Capturing the label_name (a child, not an ancestor of the labeled body) +; outdents only the label line. +(labeled_statement + (label_name) @outdent) + +; Raw string literals (backticks) span lines and are literal content. +(raw_string_literal) @opaque diff --git a/vendor/queries/html/indents.scm b/vendor/queries/html/indents.scm new file mode 100644 index 00000000..ea83fddd --- /dev/null +++ b/vendor/queries/html/indents.scm @@ -0,0 +1,20 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/html/indents.scm. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +; Indent the contents of an element; pull the end tag — and the close of a +; multi-line start/self-closing tag — back to the element's column. Mirrors the +; jsx rules. Void elements (`<br>`, `<img …>`) are single-line `element`s, so the +; tail-scoped indent is a no-op for them. +[ + (element) + (script_element) + (style_element) +] @indent +(end_tag) @outdent +(start_tag ">" @outdent) +(self_closing_tag "/>" @outdent) + +; <script>/<style> bodies are embedded JS/CSS, handled by injection-aware indent +; (the engine indents them with the JS/CSS query). No @opaque needed. diff --git a/vendor/queries/java/indents.scm b/vendor/queries/java/indents.scm new file mode 100644 index 00000000..ad33accc --- /dev/null +++ b/vendor/queries/java/indents.scm @@ -0,0 +1,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 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 diff --git a/vendor/queries/json/indents.scm b/vendor/queries/json/indents.scm new file mode 100644 index 00000000..3fb740c4 --- /dev/null +++ b/vendor/queries/json/indents.scm @@ -0,0 +1,14 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/json/indents.scm. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (object) + (array) +] @indent + +[ + "]" + "}" +] @outdent diff --git a/vendor/queries/kotlin/indents.scm b/vendor/queries/kotlin/indents.scm new file mode 100644 index 00000000..264258c2 --- /dev/null +++ b/vendor/queries/kotlin/indents.scm @@ -0,0 +1,51 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/kotlin/indents.scm. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (class_body) + (enum_class_body) + (lambda_literal) + + ; _block is hidden in the grammar, so list all public wrappers explicitly. + (function_body) + (anonymous_initializer) + (control_structure_body) + (secondary_constructor) + (try_expression) + (catch_block) + (finally_block) + + (property_declaration) + (assignment) + + (when_expression) + (call_expression) + (if_expression) + + ; Binary expressions + (multiplicative_expression) + (additive_expression) + (range_expression) + (infix_expression) + (elvis_expression) + (check_expression) + (comparison_expression) + (equality_expression) + (comparison_expression) + (equality_expression) + (conjunction_expression) + (disjunction_expression) + + (call_suffix) + (function_value_parameters) +] @indent + +[ + "}" + ")" + "]" +] @outdent + +(string_literal) @opaque diff --git a/vendor/queries/ocaml/indents.scm b/vendor/queries/ocaml/indents.scm new file mode 100644 index 00000000..6f4a13d9 --- /dev/null +++ b/vendor/queries/ocaml/indents.scm @@ -0,0 +1,27 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/ocaml/indents.scm. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (let_binding) + (type_binding) + (structure) + (signature) + (record_declaration) + (function_expression) + (fun_expression) + (match_case) + (then_clause) + (else_clause) +] @indent + +; `else if` chains nest else_clause -> if_expression -> else_clause, which would +; double-indent the trailing branch; `try`/`with` and explicit module `end` +; alignment are likewise left to the writer — see tests/indent/ocaml.ml. +[ + "}" + ")" + "]" + "end" +] @outdent diff --git a/vendor/queries/php/indents.scm b/vendor/queries/php/indents.scm new file mode 100644 index 00000000..48a28973 --- /dev/null +++ b/vendor/queries/php/indents.scm @@ -0,0 +1,34 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/php/indents.scm. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (array_creation_expression) + (arguments) + (formal_parameters) + (compound_statement) + (declaration_list) + (binary_expression) + (return_statement) + (expression_statement) + (switch_block) + ; statements after a `case`/`default` label (the node also holds the label, + ; so the default tail scope indents only the body lines, not the label) + (case_statement) + (default_statement) + (anonymous_function_use_clause) + (property_hook_list) +] @indent + +[ + "}" + ")" + "]" +] @outdent + +; Heredoc / nowdoc bodies are literal content. +[ + (heredoc) + (nowdoc) +] @opaque diff --git a/vendor/queries/python/indents.scm b/vendor/queries/python/indents.scm new file mode 100644 index 00000000..6e49c2fd --- /dev/null +++ b/vendor/queries/python/indents.scm @@ -0,0 +1,98 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/python/indents.scm. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (list) + (tuple) + (dictionary) + (set) + + (if_statement) + (for_statement) + (while_statement) + (with_statement) + (try_statement) + (match_statement) + (case_clause) + (import_from_statement) + + (parenthesized_expression) + (generator_expression) + (list_comprehension) + (set_comprehension) + (dictionary_comprehension) + + (tuple_pattern) + (list_pattern) + (argument_list) + (parameters) + (binary_operator) + + (function_definition) + (class_definition) +] @indent + +; Workaround for the tree-sitter grammar creating large errors when a +; try_statement is missing the except/finally clause +(ERROR + "try" + . + ":" @indent @extend) +(ERROR + . + "def") @indent @extend +(ERROR + (block) @indent @extend + ) + +[ + (if_statement) + (for_statement) + (while_statement) + (with_statement) + (try_statement) + (match_statement) + (case_clause) + + (function_definition) + (class_definition) + + (except_clause) + (finally_clause) +] @extend + +[ + (return_statement) + (break_statement) + (continue_statement) + (raise_statement) + (pass_statement) +] @extend.prevent-once + +[ + ")" + "]" + "}" +] @outdent +(elif_clause + "elif" @outdent) +(else_clause + "else" @outdent) +(except_clause + "except" @outdent) +(finally_clause + "finally" @outdent) + +(parameters + . + (identifier) @anchor + ) @align +(argument_list + . + (_) @anchor + ) @align + +; String bodies (triple-quoted strings span lines) are literal content. +(string) @opaque diff --git a/vendor/queries/ruby/indents.scm b/vendor/queries/ruby/indents.scm new file mode 100644 index 00000000..1100aef9 --- /dev/null +++ b/vendor/queries/ruby/indents.scm @@ -0,0 +1,32 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/ruby/indents.scm. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (argument_list) + (array) + (begin) + (block) + (call) + (class) + (case) + (if) + (hash) + (method) + (module) + (singleton_class) + (singleton_method) +] @indent + +[ + ")" + "}" + "]" + "end" + "when" + "else" + "elsif" + "rescue" + "ensure" +] @outdent diff --git a/vendor/queries/rust/indents.scm b/vendor/queries/rust/indents.scm new file mode 100644 index 00000000..0d63f197 --- /dev/null +++ b/vendor/queries/rust/indents.scm @@ -0,0 +1,166 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/rust/indents.scm, MODIFIED: its three #match? patterns +; open with \A, which mvzr (src/regexp.zig) reads as a letter A; written +; with ^, which a predicate here matches at the node's start alone. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (use_list) + (block) + (match_block) + (arguments) + (parameters) + (declaration_list) + (field_declaration_list) + (field_initializer_list) + (struct_pattern) + (tuple_pattern) + (unit_expression) + (enum_variant_list) + (call_expression) + (binary_expression) + (field_expression) + (await_expression) + (tuple_expression) + (array_expression) + (where_clause) + (type_cast_expression) + + (token_tree) + (macro_definition) + (token_tree_pattern) + (token_repetition) +] @indent + +[ + "}" + "]" + ")" +] @outdent + +; Indent the right side of assignments. +; The #not-same-line? predicate is required to prevent an extra indent for e.g. +; an else-clause where the previous if-clause starts on the same line as the assignment. +(assignment_expression + . + (_) @expr-start + right: (_) @indent + (#not-same-line? @indent @expr-start) + +) +(compound_assignment_expr + . + (_) @expr-start + right: (_) @indent + (#not-same-line? @indent @expr-start) + +) +(let_declaration + "let" @expr-start + value: (_) @indent + alternative: (_)? @indent + (#not-same-line? @indent @expr-start) + +) +(let_condition + . + (_) @expr-start + value: (_) @indent + (#not-same-line? @indent @expr-start) + +) +(if_expression + . + (_) @expr-start + condition: (_) @indent + (#not-same-line? @indent @expr-start) + +) +(static_item + . + (_) @expr-start + value: (_) @indent + (#not-same-line? @indent @expr-start) + +) +(field_pattern + . + (_) @expr-start + pattern: (_) @indent + (#not-same-line? @indent @expr-start) + +) +; Indent type aliases that span multiple lines, similar to +; regular assignment expressions +(type_item + . + (_) @expr-start + type: (_) @indent + (#not-same-line? @indent @expr-start) + +) + +; Some field expressions where the left part is a multiline expression are not +; indented by cargo fmt. +; Because this multiline expression might be nested in an arbitrary number of +; field expressions, this can only be matched using a Regex. +(field_expression + value: (_) @val + "." @outdent + ; Check whether the first line ends with `(`, `{` or `[` (up to whitespace). + (#match? @val "^[^\\n\\r]+(\\(|\\{|\\[)[\\t ]*(\\n|\\r)") +) +; Same as above, but with an additional `call_expression`. This is required since otherwise +; the arguments of the function call won't be outdented. +(call_expression + function: (field_expression + value: (_) @val + "." @outdent + (#match? @val "^[^\\n\\r]+(\\(|\\{|\\[)[\\t ]*(\\n|\\r)") + ) + arguments: (_) @outdent +) +; Same again for `.await` off a multiline receiver, so it lines up with the +; other links in the chain instead of indenting a level deeper. +(await_expression + (_) @val + "." @outdent + (#match? @val "^[^\\n\\r]+(\\(|\\{|\\[)[\\t ]*(\\n|\\r)") +) + +; Indent if guards in patterns. +; Since the tree-sitter grammar doesn't create a node for the if expression, +; it's not possible to do this correctly in all cases. Indenting the tail of the +; whole pattern whenever it contains an `if` only fails if the `if` appears after +; the second line of the pattern (which should only rarely be the case) +(match_pattern + . + (_) @expr-start + "if" @pattern-guard + (#not-same-line? @expr-start @pattern-guard) +) @indent + +; Align closure parameters if they span more than one line +(closure_parameters + "|" + . + (_) @anchor + (_) @expr-end + . + (#not-same-line? @anchor @expr-end) +) @align + +(for_expression + "in" @in + . + (_) @indent + (#not-same-line? @in @indent) + +) + +; Multi-line string / raw-string bodies are literal content: preserve them. +[ + (string_literal) + (raw_string_literal) +] @opaque diff --git a/vendor/queries/scala/indents.scm b/vendor/queries/scala/indents.scm new file mode 100644 index 00000000..0583c186 --- /dev/null +++ b/vendor/queries/scala/indents.scm @@ -0,0 +1,29 @@ +; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/scala/indents.scm. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (block) + (arguments) + (parameter) + (class_definition) + (trait_definition) + (object_definition) + (function_definition) + (val_definition) + (import_declaration) + (while_expression) + (do_while_expression) + (for_expression) + (try_expression) + (match_expression) +] @indent + +(ERROR "for") @indent + +[ + "}" + "]" + ")" +] @outdent diff --git a/vendor/queries/zig/indents.scm b/vendor/queries/zig/indents.scm new file mode 100644 index 00000000..2173e029 --- /dev/null +++ b/vendor/queries/zig/indents.scm @@ -0,0 +1,22 @@ +; Adapted from helix (https://github.com/helix-editor/helix) at 278b24389: +; runtime/queries/zig/indents.scm, MODIFIED for the zig grammar pardes +; builds (maxxnino/tree-sitter-zig), whose node names differ from the +; tree-sitter-grammars one helix uses: block is Block, switch_expression +; SwitchExpr, initializer_list InitList, error_set_declaration ErrorSetDecl, +; and struct/enum/union_declaration are one ContainerDecl. +; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE, +; https://mozilla.org/MPL/2.0/). + +[ + (Block) + (SwitchExpr) + (InitList) + (ContainerDecl) + (ErrorSetDecl) +] @indent + +[ + "}" + "]" + ")" +] @outdent |
