aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/treesitter.lua
diff options
context:
space:
mode:
authorJongwook Choi <wookayin@gmail.com>2023-12-04 04:00:49 -0500
committerGitHub <noreply@github.com>2023-12-04 10:00:49 +0100
commitcf612c64b0fc87c399bc5c72735335c5e73d6de1 (patch)
tree8bfd68e4dac5145cce42126f572ecc7ac9d85c50 /runtime/lua/vim/treesitter.lua
parent589f4761ee896cea5c8d1b1dad6655bd0b78fc2d (diff)
downloadrneovim-cf612c64b0fc87c399bc5c72735335c5e73d6de1.tar.gz
rneovim-cf612c64b0fc87c399bc5c72735335c5e73d6de1.tar.bz2
rneovim-cf612c64b0fc87c399bc5c72735335c5e73d6de1.zip
fix(treesitter): allow passing lang to vim.treesitter.get_node() now correctly takes opts.lang (#26360)
PROBLEM: `vim.treesitter.get_node()` does not recognize the `lang` in the option table. This option was used in somewhere else, for instance, `vim.treesitter.dev` (for `inspect_tree`) but was never implemented. SOLUTION: Make `get_node()` correctly use `opts.lang` when getting a treesitter parser.
Diffstat (limited to 'runtime/lua/vim/treesitter.lua')
-rw-r--r--runtime/lua/vim/treesitter.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua
index e7a66c00b2..7b795380fe 100644
--- a/runtime/lua/vim/treesitter.lua
+++ b/runtime/lua/vim/treesitter.lua
@@ -362,6 +362,7 @@ end
--- - 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
--- current window. Required if {bufnr} is not the current buffer
+--- - lang string|nil Parser language. (default: from buffer filetype)
--- - ignore_injections boolean Ignore injected languages (default true)
---
---@return TSNode | nil Node at the given position
@@ -392,7 +393,7 @@ function M.get_node(opts)
local ts_range = { row, col, row, col }
- local root_lang_tree = M.get_parser(bufnr)
+ local root_lang_tree = M.get_parser(bufnr, opts.lang)
if not root_lang_tree then
return
end