Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need help: dap debug go err: virtual_text.lua:132: bad argument #1 to pairs table expected, got userdata #88

Closed
hellohake opened this issue Sep 18, 2024 · 4 comments · Fixed by #89

Comments

@hellohake
Copy link

hellohake commented Sep 18, 2024

image

nvim version:
image
lua version:
image

when i debug go program using dap-go, if with breakpoint the error happen, when without breakpoint error not occur

i use lazyvim manager my nvim plugins, the dap relative plugin config is below:

`local custom = {}

custom["leoluz/nvim-dap-go"] = {
"leoluz/nvim-dap-go",
dependencies = {
"mfussenegger/nvim-dap",
},
config = function()
require("dap-go").setup()
end,
}

custom["rcarriga/nvim-dap-ui"] = {
"rcarriga/nvim-dap-ui",
dependencies = {
"nvim-neotest/nvim-nio",
},
}

custom["theHamsta/nvim-dap-virtual-text"] = {
"theHamsta/nvim-dap-virtual-text",
dependencies = {
"mfussenegger/nvim-dap",
"nvim-treesitter/nvim-treesitter",
},
init = function()
require("nvim-dap-virtual-text").setup({
enabled = true,
enabled_commands = true,
highlight_changed_variables = true,
highlight_new_as_changed = true,
virt_text_pos = "eol",
commented = true,
})
end,
}
custom["nvim-telescope/telescope-dap.nvim"] = {
"nvim-telescope/telescope-dap.nvim",
dependencies = {
"mfussenegger/nvim-dap",
},
}

custom["mfussenegger/nvim-dap"] = {
"mfussenegger/nvim-dap",
dependencies = {
"rcarriga/nvim-dap-ui",
},
keys = {
{
"",
function()
require("telescope").extensions.dap.configurations()
end,
mode = { "n" },
desc = "debug",
},
{
"",
function()
require("dap").terminate()
end,
mode = { "n" },
desc = "debug",
},
{
"",
function()
require("dap").step_over()
end,
mode = { "n" },
desc = "debug",
},
{
"",
function()
require("dap").step_into()
end,
mode = { "n" },
desc = "debug",
},
{
"",
function()
require("dap").step_out()
end,
mode = { "n" },
desc = "debug",
},
{
"db",
function()
require("dap").toggle_breakpoint()
end,
mode = { "n" },
desc = "debug",
},
{
"dl",
function()
require("dap").run_last()
end,
mode = { "n" },
desc = "debug",
},
},
config = function()
local dap, dapui = require("dap"), require("dapui")
dapui.setup()
dap.listeners.before.attach.dapui_config = function()
dapui.open()
end
dap.listeners.before.launch.dapui_config = function()
dapui.open()
end
dap.listeners.before.event_terminated.dapui_config = function()
dapui.close()
end
dap.listeners.before.event_exited.dapui_config = function()
dapui.close()
end
end,
}

return custom
`

@fengwk
Copy link

fengwk commented Sep 18, 2024

I encountered the same problem and it can be solved by rolling back to 9578276

@hellohake
Copy link
Author

I encountered the same problem and it can be solved by rolling back to 9578276

it's useful for me

theHamsta added a commit that referenced this issue Sep 28, 2024
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
@theHamsta
Copy link
Owner

I think the problem is #87. Could you check whether #89 would help?

I knew that #87 would break compatibility for older nvim versions, but also wanted to follow Neovim's new API. Sorry that I did not have time to use this plugin for a longer time. Also above PR was not tested yet by me.

theHamsta added a commit that referenced this issue Oct 4, 2024
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
@theHamsta
Copy link
Owner

Verified that #89 fixes the issue. On master:

Error executing vim.schedule lua callback: ...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:130: bad argument #1 to 'pairs' (table expected, got userdata)
stack traceback:
        [C]: in function 'pairs'
        ...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:130: in function 'fn'
        ...4/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:345: in function 'for_each_tree'
        ...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:125: in function 'set_virtual_text'
        ...lazy/nvim-dap-virtual-text/lua/nvim-dap-virtual-text.lua:114: in function 'c'
        ...phan/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1027: in function <...phan/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1021>

and working as expected with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants