edited, the
same tree will be returned again without extra work. If the buffer was parsed
before, incremental parsing will be done of the changed parts.
Note: To use the parser directly inside a |nvim_buf_attach()| Lua callback,
you must call |vim.treesitter.get_parser()| before you register your callback.
But preferably parsing shouldn't be done directly in the change callback
anyway as they will be very frequent. Rather a plugin that does any kind of
analysis on a tree should use a timer to throttle too frequent updates.
LanguageTree:children() *LanguageTree:children()*
Returns a map of language to child tree.
Return: ~
(`table<string,vim.treesitter.LanguageTree>`)
LanguageTree:contains({range}) *LanguageTree:contains()*
Determines whether {range} is contained in the |LanguageTree|.
Parameters: ~
• {range} (`table`) A table with the following fields:
• {[1]} (`integer`) start row
• {[2]} (`integer`) start column
• {[3]} (`integer`) end row
• {[4]} (`integer`) end column
Return: ~
(`boolean`)
LanguageTree:destroy() *LanguageTree:destroy()*
Destroys this |LanguageTree| and all its children.
Any cleanup logic should be performed here.
Note: This DOES NOT remove this tree from a parent. Instead,
`remove_child` must be called on the parent to remove it.
LanguageTree:for_each_tree({fn}) *LanguageTree:for_each_tree()*
Invokes the callback for each |LanguageTree| recursively.
Note: This includes the invoking tree's child trees as well.
Parameters: ~
• {fn} (`fun(tree: TSTree, ltree: vim.treesitter.LanguageTree)`)
LanguageTree:included_regions() *LanguageTree:included_regions()*
Gets the set of included regions managed by this LanguageTree. This can be
different from the regions set by injection query, because a partial
|LanguageTree:parse()| drops the regions outside the requested range. Each
list represents a range in the form of { {start_row}, {start_col},
{start_bytes}, {end_row}, {end_col}, {end_bytes} }.
Return: ~
(`table<integer, Range6[]>`)
LanguageTree:invalidate({reload}) *LanguageTree:invalidate()*
Invalidates this parser and its children.
Should only be called when the tracked state of the LanguageTree is not
valid against the parse tree in treesitter. Doesn't clear filesystem
cache. Called often, so needs to be fast.
Parameters: ~
• {reload} (`boolean?`)
*LanguageTree:is_valid()*
LanguageTree:is_valid({exclude_children}, {range})
Returns whether this LanguageTree is valid, i.e., |LanguageTree:trees()|
reflects the latest state of the source. If invalid, user should call
|LanguageTree:parse()|.
Parameters: ~
• {exclude_children} (`boolean?`) whether to ignore the validity of
children (default `false`)
• {range} (`Range?`) range to check for validity
Return: ~
(`boolean`)
LanguageTree:lang() *LanguageTree:lang()*
Gets the language of this tree node.
Return: ~
(`string`)
*LanguageTree:language_for_range()*
LanguageTree:language_for_range({range})
Gets the appropriate language that contains {range}.
Parameters: ~
• {range} (`table`) A table with the following fields:
• {[1]} (`integer`) start row
• {[2]} (`integer`) start column
• {[3]} (`integer`) end row
• {[4]} (`integer`) end column
Return: ~
(`vim.treesitter.LanguageTree`) tree Managing {range}
*LanguageTree:named_node_for_range()*
LanguageTree:named_node_for_range({range},