Fix Odin DAP flow: schedule dap.run, raise adapter timeout, keep neo-tree width

This commit is contained in:
2026-08-03 20:25:15 -04:00
parent 517140ad1f
commit e2dcd33fcc
2 changed files with 28 additions and 7 deletions
+24 -7
View File
@@ -16,6 +16,7 @@ dap.adapters.lldb = {
type = "executable", type = "executable",
command = lldb_dap, command = lldb_dap,
name = "lldb", name = "lldb",
options = { initialize_timeout_sec = 20 },
} }
local function project_binary() local function project_binary()
@@ -38,19 +39,35 @@ dap.configurations.odin = {
dapui.setup({}) dapui.setup({})
dap.listeners.after.event_initialized["dapui"] = dapui.open dap.listeners.after.event_initialized["dapui"] = dapui.open
dap.listeners.before.event_terminated["dapui"] = dapui.close
dap.listeners.before.event_exited["dapui"] = dapui.close local neotree_width = 30
local function close_dapui()
dapui.close()
for _, win in ipairs(vim.api.nvim_list_wins()) do
if vim.bo[vim.api.nvim_win_get_buf(win)].filetype == "neo-tree" then
vim.api.nvim_win_set_width(win, neotree_width)
end
end
end
dap.listeners.before.event_terminated["dapui_restore"] = close_dapui
dap.listeners.before.event_exited["dapui_restore"] = close_dapui
local function run_or_continue() local function run_or_continue()
if dap.session() then if dap.session() then
dap.continue() dap.continue()
elseif vim.bo.filetype == "odin" then elseif vim.bo.filetype == "odin" then
vim.notify("odin: building...", vim.log.levels.INFO)
vim.system({ "odin", "build", ".", "-debug" }, { cwd = vim.fn.getcwd() }, function(obj) vim.system({ "odin", "build", ".", "-debug" }, { cwd = vim.fn.getcwd() }, function(obj)
if obj.code ~= 0 then vim.schedule(function()
vim.notify("odin build failed (code " .. obj.code .. ")", vim.log.levels.ERROR) if obj.code ~= 0 then
return vim.notify("odin build failed (code " .. obj.code .. ")", vim.log.levels.ERROR)
end return
dap.run(dap.configurations.odin[1]) end
vim.api.nvim_echo({}, false, {})
dap.run(dap.configurations.odin[1])
end)
end) end)
else else
dap.continue() dap.continue()
+4
View File
@@ -4,3 +4,7 @@ vim.pack.add({
{ src = "https://github.com/MunifTanjim/nui.nvim" }, { src = "https://github.com/MunifTanjim/nui.nvim" },
{ src = "https://github.com/nvim-tree/nvim-web-devicons" }, { src = "https://github.com/nvim-tree/nvim-web-devicons" },
}) })
require("neo-tree").setup({
window = { width = 30 },
})