-
Notifications
You must be signed in to change notification settings - Fork 11
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
Can't start lua debugger on init.lua #52
Comments
Thanks for raising this issue. This is not expected, but it's also a brand new feature with few feedback so it may break easily. What do you get when running with logging enabled ? I'm curious to see if it attaches well. Quickly skimming through the dotfiles I saw: {
"mfussenegger/nvim-dap",
event = "BufReadPost",
dependencies = {
{
"theHamsta/nvim-dap-virtual-text",
dependencies = { "nvim-treesitter/nvim-treesitter" },
config = true,
},
{
"LiadOz/nvim-dap-repl-highlights",
config = true,
},
"jbyuki/one-small-step-for-vimkind",
}, I'm not too familiar with It would be interesting to see if it's because of that so I can add it as a warning for future users. |
I've tested it some more. With my own configuration, I find it sometimes work as expected, and sometimes not. If I avoid the lazy loading, it seems to work more often (but not always). So, it feels like this may have something to do with the connection. I'll look into the log files now and I'll post it here if it seems relevant. |
Yes, that sounds like a race condition. Some better understanding on how
lazy.nvim loads its plugin could be useful. I will test if I can reproduce
it with lazy.nvim installed.
…On Wed, 14 Aug 2024, 12:22 am Karl Yngve Lervåg, ***@***.***> wrote:
I've tested it some more. With my own configuration, I find it *sometimes*
work as expected, and sometimes not. If I avoid the lazy loading, it
*seems* to work more often (but not always). So, it feels like this may
have something to do with the connection.
I'll look into the log files now and I'll post it here if it seems
relevant.
—
Reply to this email directly, view it on GitHub
<#52 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALJBOFMKWKENPE2PHB3RL4LZRKBL3AVCNFSM6AAAAABMOFCV2GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBXGI2DCNBXGI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Here's a minimal if vim.env.DEBUG then
vim.opt.runtimepath:prepend ".lazy/plugins/one-small-step-for-vimkind"
require "osv".launch { port = 8086, blocking = true }
end
vim.g.mapleader = " "
local root = vim.fn.fnamemodify("./.lazy", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)
require("lazy").setup({
{
"mfussenegger/nvim-dap",
config = function()
local dap = require "dap"
dap.set_log_level "INFO"
dap.listeners.before.attach.dapui_config = function()
require("dapui").open()
end
dap.listeners.before.launch.dapui_config = function()
require("dapui").open()
end
dap.listeners.before.event_exited.dapui_config = function(_, status)
require("dapui").close()
vim.notify("Process finished (exit code = " .. status.exitCode .. ")")
end
dap.listeners.before.disconnect.dapui_config = function()
require("dapui").close()
dap.repl.close()
end
dap.adapters.nlua = function(callback, config)
callback {
type = "server",
host = "127.0.0.1",
port = config.port,
}
end
dap.configurations.lua = {
{
type = "nlua",
request = "attach",
name = "Attach to running Neovim instance",
port = 8086
},
}
local mappings = {
["<leader>dd"] = dap.continue,
["<leader>dD"] = dap.run_last,
["<leader>dc"] = dap.run_to_cursor,
["<leader>dx"] = dap.terminate,
["<leader>dX"] = function()
require("dapui").close()
end,
["<leader>dn"] = dap.step_over,
["<leader>db"] = dap.toggle_breakpoint,
["<leader>d<c-b>"] = dap.clear_breakpoints,
}
for lhs, rhs in pairs(mappings) do
vim.keymap.set("n", lhs, rhs)
end
end,
},
{
"jbyuki/one-small-step-for-vimkind",
},
{
"rcarriga/nvim-dap-ui",
dependencies = {
"nvim-neotest/nvim-nio",
},
-- lazy = true,
opts = {
controls = { enabled = false },
icons = {
current_frame = "🡆",
},
layouts = {
{
elements = {
{ id = "stacks", size = 0.25 },
{ id = "scopes", size = 0.25 },
{ id = "breakpoints", size = 0.25 },
{ id = "watches", size = 0.25 },
},
size = 45,
position = "left",
},
{
elements = {
{ id = "repl", size = 1.0 },
},
size = 20,
position = "bottom",
},
},
},
},
}, {
root = root .. "/plugins",
}) If you save this as
I find the behaviour is very dependent on whether the lazy specs are lazy or not. If you use |
I cannot reproduce unfortunately, however I have seen that some breakpoints are skipped sometimes probably due to jit optimization so they are simply not executed, afterall it's not running in debug mode. I will put this onto that account for now but i'll leave it open in case something comes up. |
That's strange. Perhaps it's also a neovim version specific thing? I'm on the nightly builds:
On my end, with the example I provided, I observe the following behaviour:
Ok; considering that I can actually achieve the debugging I want I'm quite happy. But it's annoying with the nondeterministic behaviour, in particular that I don't understand why it is happening. |
Yes, for now it seems necessary to understand how "lazy" loading works and
how it interacts with `nvim-dap` and `osv`.
Out of the 20 times or so I tried, it worked every time and I'm running the
latest nightly on native windows. The tests were done by setting `nvim-dap-ui` to `lazy = true` and putting a breakpoint on the first line after the dap server launch line, where it's setting the mapleader.
I will try to test it on other setups if i get
the chance.
…On Thu, 22 Aug 2024, 8:11 pm Karl Yngve Lervåg, ***@***.***> wrote:
I cannot reproduce unfortunately,
That's strange. Perhaps it's also a neovim version specific thing? I'm on
the nightly builds:
:vers
NVIM v0.11.0-dev-632+g33464189bc
Build type: Release
LuaJIT 2.1.1720049189
On my end, with the example I provided, I observe the following behaviour:
- If I add breakpoints and start debugging as the example was
provided, it works about 50% of the times (i.e., it will stop on
breakpoints). That's still good enough to be useful already - thus, my
issue is half resolved.
- If I use lazy = true for nvim-dap-ui, the breakpoints will never
hit. It would be nice to understand why, but it is not a big problem and I
can just avoid to lazy load it!
however I have seen that some breakpoints are skipped sometimes probably
due to jit optimization so they are simply not executed, afterall it's not
running in debug mode. I will put this onto that account for now but i'll
leave it open in case something comes up.
Ok; considering that I can actually achieve the debugging I want I'm quite
happy. But it's annoying with the nondeterministic behaviour, in particular
that I don't understand why it is happening.
—
Reply to this email directly, view it on GitHub
<#52 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALJBOFMPD5J3C3KKY2VEW73ZSYSTNAVCNFSM6AAAAABMOFCV2GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBVGM2TKNJUHE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
This is closely related to #47. I've added the following snippet to the top of my
init.lua
file:Running
DO_DEBUG=1 nvim
in one terminal now blocks and waits for a connection. Cool.However, I now open my
init.lua
in another terminal. I add a breakpoint to thelocal x = 1
line. Then I connect to the debuggee. It does attach, as expected, but the breakpoint does not work. In fact, any breakpoint in myinit.lua
or from scripts sourced/required will not work directly.Breakpoints related to things happening after sourcing the
init.lua
scripts do work. E.g., given this snippet from my init scripts:Adding a breakpoint to the first line does not work. But if I add a breakpoint to the callback, it works as expected.
I am curious if this is the expected behaviour?
As far as I can see, I've configured things as suggested in the docs. My full config is here: https://github.com/lervag/dotnvim/.
The text was updated successfully, but these errors were encountered: