on master help sign in
Add alignment indent queries for binary & ternary expressions in C.
commit33d85606cf36da074d91db498d12233ab4978509 authorDaniel Ebert <daniel.ebert@protonmail.com> dateSun 3 Dec 2023, 19:47 (3 years ago) parent723a132
1 file changed+10
runtime/queries/c/indents.scm+10
runtime/queries/c/indents.scm+10
@@ -39,3 +39,13 @@
3939(argument_list
4040 . (_) @anchor
4141 (#set! "scope" "tail")) @align
42+; These are a bit opinionated since some people just indent binary/ternary expressions spanning multiple lines.
43+; Since they are only triggered when a newline is inserted into an already complete binary/ternary expression,
44+; this should happen rarely, so it is not a big deal either way.
45+; Additionally, adding these queries has the advantage of preventing such continuation lines from being used
46+; as the baseline when the `hybrid` indent heuristic is used (which is desirable since their indentation is so inconsistent).
47+(binary_expression
48+ (#set! "scope" "tail")) @anchor @align
49+(conditional_expression
50+ "?" @anchor
51+ (#set! "scope" "tail")) @align