Skip to content

Commit

Permalink
fix: Restore compatibilty with nvim<=0.9
Browse files Browse the repository at this point in the history
After #87, this plugin became incompatible with nvim versions <= 0.9 by
using the newly table parameter of iter_matches. This PR tries to avoid
the parameter and tries to account that iter_matches might return either
nodes or tables of nodes by coercing non-table values to singleton
tables.

Fixes #88
  • Loading branch information
theHamsta committed Sep 28, 2024
1 parent 3497eb3 commit c200706
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lua/nvim-dap-virtual-text/virtual_text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,12 @@ function M.set_virtual_text(stackframe, options)
parser:for_each_tree(function(tree, ltree)
local query = get_query(ltree:lang(), 'locals')
if query then
for _, match, _ in query:iter_matches(tree:root(), buf, 0, -1, { all = true }) do
for _, match, _ in query:iter_matches(tree:root(), buf, 0, -1) do
for id, nodes in pairs(match) do
for _, node in pairs(nodes) do
if type(nodes) ~= 'table' then
nodes = { nodes }
end
for _, node in ipairs(nodes) do
local cap_id = query.captures[id]
if cap_id:find('scope', 1, true) then
table.insert(scope_nodes, node)
Expand Down

0 comments on commit c200706

Please sign in to comment.