Skip to content

Commit

Permalink
update nvim 0.7 treesitter api
Browse files Browse the repository at this point in the history
Signed-off-by: Micah Halter <[email protected]>
  • Loading branch information
mehalter committed Apr 18, 2022
1 parent 7fd8806 commit af89420
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lua/treesitter-matchup/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ function M.containing_scope(node, bufnr, key)
return nil
end

local function _node_text(node, bufnr)
local text = vim.treesitter.query.get_node_text(node, bufnr)
if type(text) == "table" then
text = text[1]
end
return text
end

--- Fill in a match result based on a seed node
function M.do_node_result(initial_node, bufnr, opts, side, key)
if not side or not key then
Expand All @@ -148,7 +156,7 @@ function M.do_node_result(initial_node, bufnr, opts, side, key)

local result = {
type = 'delim_py',
match = ts_utils.get_node_text(initial_node, bufnr)[1],
match = _node_text(initial_node, bufnr),
side = side,
lnum = row + 1,
cnum = col + 1,
Expand Down Expand Up @@ -285,7 +293,7 @@ function M.get_matching(delim, down, bufnr)

local target_scope = M.containing_scope(node, bufnr, info.key)
if info.scope == target_scope then
local text = ts_utils.get_node_text(node, bufnr)[1]
local text = _node_text(node, bufnr)
table.insert(matches, {text, row + 1, col + 1})

if side == 'close' then
Expand Down

0 comments on commit af89420

Please sign in to comment.