summaryrefslogtreecommitdiff
path: root/vendor/queries/cpp
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/cpp
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/cpp')
-rw-r--r--vendor/queries/cpp/indents.scm63
1 files changed, 63 insertions, 0 deletions
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