Fix Odin DAP flow: schedule dap.run, raise adapter timeout, keep neo-tree width
This commit is contained in:
@@ -16,6 +16,7 @@ dap.adapters.lldb = {
|
||||
type = "executable",
|
||||
command = lldb_dap,
|
||||
name = "lldb",
|
||||
options = { initialize_timeout_sec = 20 },
|
||||
}
|
||||
|
||||
local function project_binary()
|
||||
@@ -38,19 +39,35 @@ dap.configurations.odin = {
|
||||
dapui.setup({})
|
||||
|
||||
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()
|
||||
if dap.session() then
|
||||
dap.continue()
|
||||
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)
|
||||
if obj.code ~= 0 then
|
||||
vim.notify("odin build failed (code " .. obj.code .. ")", vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
dap.run(dap.configurations.odin[1])
|
||||
vim.schedule(function()
|
||||
if obj.code ~= 0 then
|
||||
vim.notify("odin build failed (code " .. obj.code .. ")", vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
vim.api.nvim_echo({}, false, {})
|
||||
dap.run(dap.configurations.odin[1])
|
||||
end)
|
||||
end)
|
||||
else
|
||||
dap.continue()
|
||||
|
||||
Reference in New Issue
Block a user