From 2244a5d40c83d477839f91cb6d6a4aeb02446a97 Mon Sep 17 00:00:00 2001 From: omentic Date: Wed, 1 May 2024 23:29:52 +0000 Subject: deploy: 12eec890240a05d1e090114f7f4fdd7c1ee8ff88 --- guides/indent.html | 37 +++++++++++++++++++++++++------------ guides/injection.html | 6 +++++- guides/rainbow_bracket_queries.html | 6 +++--- guides/textobject.html | 2 +- 4 files changed, 34 insertions(+), 17 deletions(-) (limited to 'guides') diff --git a/guides/indent.html b/guides/indent.html index a968f7bb..25be199a 100644 --- a/guides/indent.html +++ b/guides/indent.html @@ -189,6 +189,14 @@ the capture.

Note that it matters where these added indents begin. For example, multiple indent level increases that start on the same line only increase the total indent level by 1. See Capture types.

+

By default, Helix uses the hybrid indentation heuristic. This means that +indent queries are not used to compute the expected absolute indentation of a +line but rather the expected difference in indentation between the new and an +already existing line. This difference is then added to the actual indentation +of the already existing line. Since this makes errors in the indent queries +harder to find, it is recommended to disable it when testing via +:set indent-heuristic tree-sitter. The rest of this guide assumes that +the tree-sitter heuristic is used.

Indent queries

When Helix is inserting a new line through o, O, or <ret>, to determine the indent level for the new line, the query in indents.scm is run on the @@ -283,7 +291,7 @@ actually have been extended). // 3x @outdent }

((block) @indent)
-["}" ")"] @outdent
+["}" ")"] @outdent
 

Note how on the second line, we have two blocks begin on the same line. In this case, since both captures occur on the same line, they are combined and only @@ -323,7 +331,7 @@ whitespace-sensitive.

the cursor on a line feed ends up being the entire inside of the class. Because of this, it will miss the entire function node and its indent capture, leading to an indent level one too small.

-

To address this case, @extend tells helix to "extend" the captured node's span +

To address this case, @extend tells helix to "extend" the captured node's span to the line feed and every consecutive line that has a greater indent level than the line of the node.

(parenthesized_expression) @indent
@@ -431,7 +439,7 @@ similar to how #set! declarations work:

)

The number of arguments depends on the predicate that's used. -Each argument is either a capture (@name) or a string ("some string"). +Each argument is either a capture (@name) or a string ("some string"). The following predicates are supported by tree-sitter:

Additionally, we support some custom predicates for indent queries: