function
documentation.
*vim.treesitter.language_version*
The latest parser ABI version that is supported by the bundled treesitter
library.
*vim.treesitter.minimum_language_version*
The earliest parser ABI version that is supported by the bundled treesitter
library.
==============================================================================
TREESITTER TREES *treesitter-tree* *TSTree*
A "treesitter tree" represents the parsed contents of a buffer, which can be
used to perform further analysis. It is a |userdata| reference to an object
held by the treesitter library.
An instance `TSTree` of a treesitter tree supports the following methods.
TSTree:copy() *TSTree:copy()*
Returns a copy of the `TSTree`.
Return: ~
(`TSTree`)
TSTree:root() *TSTree:root()*
Return the root node of this tree.
Return: ~
(`TSNode`)
==============================================================================
TREESITTER NODES *treesitter-node* *TSNode*
A "treesitter node" represents one specific element of the parsed contents of
a buffer, which can be captured by a |Query| for, e.g., highlighting. It is a
|userdata| reference to an object held by the treesitter library.
An instance `TSNode` of a treesitter node supports the following methods.
TSNode:byte_length() *TSNode:byte_length()*
Return the number of bytes spanned by this node.
Return: ~
(`integer`)
TSNode:child({index}) *TSNode:child()*
Get the node's child at the given {index}, where zero represents the first
child.
Parameters: ~
• {index} (`integer`)
Return: ~
(`TSNode?`)
TSNode:child_count() *TSNode:child_count()*
Get the node's number of children.
Return: ~
(`integer`)
*TSNode:child_with_descendant()*
TSNode:child_with_descendant({descendant})
Get the node's child that contains {descendant} (includes {descendant}).
For example, with the following node hierarchy: >
a -> b -> c
a:child_with_descendant(c) == b
a:child_with_descendant(b) == b
a:child_with_descendant(a) == nil
<
Parameters: ~
• {descendant} (`TSNode`)
Return: ~
(`TSNode?`)
*TSNode:descendant_for_range()*
TSNode:descendant_for_range({start_row}, {start_col}, {end_row}, {end_col})
Get the smallest node within this node that spans the given range of (row,
column) positions
Parameters: ~
• {start_row} (`integer`)
• {start_col} (`integer`)
• {end_row} (`integer`)
• {end_col} (`integer`)
Return: ~
(`TSNode?`)
TSNode:end_() *TSNode:end_()*
Get the node's end position. Return three values: the row, column and
total byte count (all zero-based).
Return (multiple): ~
(`integer`)
(`integer`)
(`integer`)
TSNode:equal({node}) *TSNode:equal()*
Check if {node} refers to the same node within the same tree.
Parameters: ~
• {node} (`TSNode`)
Return: ~
(`boolean`)
TSNode:extra() *TSNode:extra()*
Check if the node is extra. Extra nodes represent things like comments,
which are not required by the grammar but can appear anywhere.
Return: ~
(`boolean`)
TSNode:field({name}) *TSNode:field()*
Returns a list of all the node's children that have the given field name.
Parameters: ~
• {name} (`string`)