diff options
-rw-r--r-- | runtime/doc/treesitter.txt | 6 | ||||
-rw-r--r-- | runtime/lua/vim/treesitter.lua | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index e19fda8fd1..c65c9c22ba 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -599,6 +599,12 @@ get_captures_at_pos({bufnr}, {row}, {col}) get_node({opts}) *vim.treesitter.get_node()* Returns the smallest named node at the given position + NOTE: Calling this on an unparsed tree can yield an invalid node. If the + tree is not known to be parsed by, e.g., an active highlighter, parse the + tree first via >lua + vim.treesitter.get_parser(bufnr):parse(range) +< + Parameters: ~ • {opts} (table|nil) Optional keyword arguments: • bufnr integer|nil Buffer number (nil or 0 for current diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua index f863942d3b..e7a66c00b2 100644 --- a/runtime/lua/vim/treesitter.lua +++ b/runtime/lua/vim/treesitter.lua @@ -350,6 +350,14 @@ end --- Returns the smallest named node at the given position --- +--- NOTE: Calling this on an unparsed tree can yield an invalid node. +--- If the tree is not known to be parsed by, e.g., an active highlighter, +--- parse the tree first via +--- +--- ```lua +--- vim.treesitter.get_parser(bufnr):parse(range) +--- ``` +--- ---@param opts table|nil Optional keyword arguments: --- - bufnr integer|nil Buffer number (nil or 0 for current buffer) --- - pos table|nil 0-indexed (row, col) tuple. Defaults to cursor position in the |