start_row
(`integer`) start_col
(`integer`) end_row
(`integer`) end_col
*vim.treesitter.get_node_text()*
get_node_text({node}, {source}, {opts})
Gets the text corresponding to a given node
Parameters: ~
• {node} (`TSNode`)
• {source} (`integer|string`) Buffer or string from which the {node} is
extracted
• {opts} (`table?`) Optional parameters.
• metadata (table) Metadata of a specific capture. This
would be set to `metadata[capture_id]` when using
|vim.treesitter.query.add_directive()|.
Return: ~
(`string`)
get_parser({bufnr}, {lang}, {opts}) *vim.treesitter.get_parser()*
Returns the parser for a specific buffer and attaches it to the buffer
If needed, this will create the parser.
If no parser can be created, an error is thrown. Set `opts.error = false`
to suppress this and return nil (and an error message) instead. WARNING:
This behavior will become default in Nvim 0.12 and the option will be
removed.
Parameters: ~
• {bufnr} (`integer?`) Buffer the parser should be tied to (default:
current buffer)
• {lang} (`string?`) Language of this parser (default: from buffer
filetype)
• {opts} (`table?`) Options to pass to the created language tree
Return (multiple): ~
(`vim.treesitter.LanguageTree?`) object to use for parsing
(`string?`) error message, if applicable
get_range({node}, {source}, {metadata}) *vim.treesitter.get_range()*
Get the range of a |TSNode|. Can also supply {source} and {metadata} to
get the range with directives applied.
Parameters: ~
• {node} (`TSNode`)
• {source} (`integer|string?`) Buffer or string from which the {node}
is extracted
• {metadata} (`vim.treesitter.query.TSMetadata?`)
Return: ~
(`table`) A table with the following fields:
• {[1]} (`integer`) start row
• {[2]} (`integer`) start column
• {[3]} (`integer`) start bytes
• {[4]} (`integer`) end row
• {[5]} (`integer`) end column
• {[6]} (`integer`) end bytes
*vim.treesitter.get_string_parser()*
get_string_parser({str}, {lang}, {opts})
Returns a string parser
Parameters: ~
• {str} (`string`) Text to parse
• {lang} (`string`) Language of this string
• {opts} (`table?`) Options to pass to the created language tree
Return: ~
(`vim.treesitter.LanguageTree`) object to use for parsing
inspect_tree({opts}) *vim.treesitter.inspect_tree()*
Open a window that displays a textual representation of the nodes in the
language tree.
While in the window, press "a" to toggle display of anonymous nodes, "I"
to toggle the display of the source language of each node, "o" to toggle
the query editor, and press <Enter> to jump to the node under the cursor
in the source buffer. Folding also works (try |zo|, |zc|, etc.).
Can also be shown with `:InspectTree`. *:InspectTree*
Attributes: ~
Since: 0.9.0
Parameters: ~
• {opts} (`table?`) Optional options table with the following possible
keys:
• lang (string|nil): The language of the source buffer. If
omitted, detect from the filetype of the source buffer.
• bufnr (integer|nil): Buffer to draw the tree into. If
omitted, a new buffer is created.
• winid (integer|nil): Window id to display the tree buffer
in. If omitted, a new window is created with {command}.
• command (string|nil): Vimscript command to create the
window. Default value is "60vnew". Only used