improve nvim debugging experience

This commit is contained in:
Gabriel Augendre 2024-02-18 01:14:11 +01:00
parent 3bd295933f
commit 500fbc0cef
3 changed files with 63 additions and 6 deletions

View file

@ -0,0 +1,14 @@
local dap, dapui = require("dap"), require("dapui")
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

View file

@ -7,13 +7,34 @@ M.dap = {
"<cmd> DapToggleBreakpoint <CR>", "<cmd> DapToggleBreakpoint <CR>",
"Add breakpoint at line" "Add breakpoint at line"
}, },
["<leader>dc"] = {
"<cmd> DapContinue <CR>",
"Debug - continue"
},
["<leader>dsi"] = {
"<cmd> DapStepInto <CR>",
"Debug - step into"
},
["<leader>dn"] = {
"<cmd> DapStepOver <CR>",
"Debug - step over (next)"
},
["<leader>dso"] = {
"<cmd> DapStepOut <CR>",
"Debug - step out"
},
["<leader>dt"] = {
"<cmd> DapTerminate <CR>",
"Debug - terminate"
},
["<leader>dus"] = { ["<leader>dus"] = {
function () function ()
local widgets = require('dap.ui.widgets'); require("dapui").toggle();
local sidebar = widgets.sidebar(widgets.scopes); -- local widgets = require('dap.ui.widgets');
sidebar.open(); -- local sidebar = widgets.sidebar(widgets.scopes);
-- sidebar.open();
end, end,
"Open debugging sidebar" "Toggle debugging interface"
} }
} }
} }
@ -29,13 +50,25 @@ M.dap_go = {
}, },
["<leader>dgl"] = { ["<leader>dgl"] = {
function() function()
require("dap-go").debug_last() require("dap-go").debug_last_test()
end, end,
"Debug last go test" "Debug last go test"
}, },
} }
} }
M.dap_ui = {
plugin = true,
n = {
["È"] = { -- alt+k
function()
require("dapui").eval()
end,
"Debug - eval expression"
}
}
}
M.terminal = { M.terminal = {
t = { t = {
["<Esc>"] = {"<C-\\><C-n>"} ["<Esc>"] = {"<C-\\><C-n>"}

View file

@ -22,6 +22,16 @@ local plugins = {
require("core.utils").load_mappings("dap_go") require("core.utils").load_mappings("dap_go")
end, end,
}, },
{
"rcarriga/nvim-dap-ui", -- UI for the DAP debugger
ft = "go",
dependencies = "mfussenegger/nvim-dap",
config = function()
require("dapui").setup()
require "custom.configs.nvim-dap-ui"
require("core.utils").load_mappings("dap_ui")
end,
},
{ {
"neovim/nvim-lspconfig", -- load custom lsp config "neovim/nvim-lspconfig", -- load custom lsp config
config = function() config = function()
@ -45,6 +55,6 @@ local plugins = {
build = function() build = function()
vim.cmd [[silent! GoInstallDeps]] vim.cmd [[silent! GoInstallDeps]]
end, end,
} },
} }
return plugins return plugins