@foo (#set! @foo kind "parameter"))
((node1) @left (node2) @right (#set! type "pair"))
((codeblock) @markup.raw.block (#set! priority 90))
<
`offset!` *treesitter-directive-offset!*
Takes the range of the captured node and applies an offset. This will
set a new range in the form of a list like { {start_row}, {start_col},
{end_row}, {end_col} } for the captured node with `capture_id` as
`metadata[capture_id].range`. Useful for |treesitter-language-injections|.
Parameters: ~
{capture_id}
{start_row}
{start_col}
{end_row}
{end_col}
Example: >query
((identifier) @constant (#offset! @constant 0 1 0 -1))
<
`gsub!` *treesitter-directive-gsub!*
Transforms the content of the node using a |lua-pattern|. This will set
a new `metadata[capture_id].text`.
Parameters: ~
{capture_id}
{pattern}
{replacement}
Example: >query
(#gsub! @_node ".*%.(.*)" "%1")
<
`trim!` *treesitter-directive-trim!*
Trims whitespace from the node. Sets a new
`metadata[capture_id].range`. Takes a capture ID and, optionally, four
integers to customize trimming behavior (`1` meaning trim, `0` meaning
don't trim). When only given a capture ID, trims blank lines (lines
that contain only whitespace, or are empty) from the end of the node
(for backwards compatibility). Can trim all whitespace from both sides
of the node if parameters are given.
Examples: >query
; only trim blank lines from the end of the node
; (equivalent to (#trim! @fold 0 0 1 0))
(#trim! @fold)
; trim blank lines from both sides of the node
(#trim! @fold 1 0 1 0)
; trim all whitespace around the node
(#trim! @fold 1 1 1 1)
<
Parameters: ~
{capture_id}
{trim_start_linewise}
{trim_start_charwise}
{trim_end_linewise} (default `1` if only given {capture_id})
{trim_end_charwise}
Further directives can be added via |vim.treesitter.query.add_directive()|.
Use |vim.treesitter.query.list_directives()| to list all available directives.
TREESITTER QUERY MODELINES *treesitter-query-modeline*
Nvim supports to customize the behavior of the queries using a set of
"modelines", that is comments in the queries starting with `;`. Here are the
currently supported modeline alternatives:
`inherits: {lang}...` *treesitter-query-modeline-inherits*
Specifies that this query should inherit the queries from {lang}.
This will recursively descend in the queries of {lang} unless wrapped
in parentheses: `({lang})`.
Note: This is meant to be used to include queries from another
language. If you want your query to extend the queries of the same
language, use `extends`.
`extends` *treesitter-query-modeline-extends*
Specifies that this query should be used as an extension for the
query, i.e. that it should be merged with the others.
Note: The order of the extensions, and the query that will be used as
a base depends on your 'runtimepath' value.
Note: These modeline comments must be at the top of the query, but can be
repeated, for example, the following two modeline blocks are both valid:
>query
;; inherits: typescript,jsx
;; extends
<
>query
;; extends
;;
;; inherits: css
<
==============================================================================
TREESITTER SYNTAX HIGHLIGHTING *treesitter-highlight*
Syntax highlighting is specified through queries named