aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/nvim-treesitter.txt105
1 files changed, 105 insertions, 0 deletions
diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt
index f05693676..5509dc8af 100644
--- a/doc/nvim-treesitter.txt
+++ b/doc/nvim-treesitter.txt
@@ -222,7 +222,112 @@ Supported options:
enable = true
},
}
+
+`@indent` *nvim-treesitter-indentation-queries*
+Queries can use the following captures: `@indent` and `@dedent`,
+`@branch`, `@indent_end` or `@aligned_indent`. An `@ignore` capture tells
+treesitter to ignore indentation and a `@zero_indent` capture sets
+the indentation to 0.
+
+`@indent` *nvim-treesitter-indentation-indent*
+The `@indent` specifies that the next line should be indented. Multiple
+indents on the same line get collapsed. Eg.
+
+>
+ (
+ (if_statement)
+ (ERROR "else") @indent
+ )
<
+Indent can also have `immediate_indent` set using a `#set!` directive, which
+permits the next line to indent even when the block intended to be indented
+has no content yet, improving interactive typing.
+
+eg for python:
+>
+ ((if_statement) @indent
+ (#set! "immediate_indent" 1))
+<
+
+Will allow:
+>
+ if True:<CR>
+ # Auto indent to here
+
+`@indent_end` *nvim-treesitter-indentation-indent_end*
+An `@indent_end` capture is used to specify that the indented region ends and
+any text subsequent to the capture should be dedented.
+
+`@branch` *nvim-treesitter-indentation-branch*
+An `@branch` capture is used to specify that a dedented region starts
+at the line including the captured nodes.
+
+`@dedent` *nvim-treesitter-indentation-dedent*
+A `@dedent` capture specifies dedenting starting on the next line.
+>
+`@aligned_indent` *nvim-treesitter-indentation-aligned_indent*
+Aligned indent blocks may be specified with the `@aligned_indent` capture.
+This permits
+
+>
+ foo(a,
+ b,
+ c)
+<
+As well as
+>
+ foo(
+ a,
+ b,
+ c)
+<
+and finally
+>
+ foo(
+ a,
+ b,
+ c
+ )
+<
+To specify the delimiters to use `open_delimiter` and `close_delimiter`
+should be used. Eg.
+>
+ ((argument_list) @aligned_indent
+ (#set! "open_delimiter" "(")
+ (#set! "close_delimiter" ")"))
+<
+
+For some languages the last line of an `aligned_indent` block must not be
+the same indent as the natural next line.
+
+For example in python:
+
+>
+ if (a > b and
+ c < d):
+ pass
+
+Is not correct, whereas
+>
+ if (a > b and
+ c < d):
+ pass
+
+Would be correctly indented. This behavior may be chosen using
+`avoid_last_matching_next`. Eg.
+
+>
+ (if_statement
+ condition: (parenthesized_expression) @aligned_indent
+ (#set! "open_delimiter" "(")
+ (#set! "close_delimiter" ")")
+ (#set! "avoid_last_matching_next" 1)
+ )
+<
+Could be used to specify that the last line of an `@aligned_indent` capture
+should be additionally indented to avoid clashing with the indent of the first
+line of the block inside an if.
+
==============================================================================
COMMANDS *nvim-treesitter-commands*