diff --git a/dot_config/nvim/lua/custom/configs/nvim-dap-ui.lua b/dot_config/nvim/lua/custom/configs/nvim-dap-ui.lua new file mode 100644 index 0000000..0b66ee8 --- /dev/null +++ b/dot_config/nvim/lua/custom/configs/nvim-dap-ui.lua @@ -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 + diff --git a/dot_config/nvim/lua/custom/mappings.lua b/dot_config/nvim/lua/custom/mappings.lua index 73a9dc8..83cf9a5 100644 --- a/dot_config/nvim/lua/custom/mappings.lua +++ b/dot_config/nvim/lua/custom/mappings.lua @@ -7,13 +7,34 @@ M.dap = { " DapToggleBreakpoint ", "Add breakpoint at line" }, + ["dc"] = { + " DapContinue ", + "Debug - continue" + }, + ["dsi"] = { + " DapStepInto ", + "Debug - step into" + }, + ["dn"] = { + " DapStepOver ", + "Debug - step over (next)" + }, + ["dso"] = { + " DapStepOut ", + "Debug - step out" + }, + ["dt"] = { + " DapTerminate ", + "Debug - terminate" + }, ["dus"] = { function () - local widgets = require('dap.ui.widgets'); - local sidebar = widgets.sidebar(widgets.scopes); - sidebar.open(); + require("dapui").toggle(); + -- local widgets = require('dap.ui.widgets'); + -- local sidebar = widgets.sidebar(widgets.scopes); + -- sidebar.open(); end, - "Open debugging sidebar" + "Toggle debugging interface" } } } @@ -29,13 +50,25 @@ M.dap_go = { }, ["dgl"] = { function() - require("dap-go").debug_last() + require("dap-go").debug_last_test() end, "Debug last go test" }, } } +M.dap_ui = { + plugin = true, + n = { + ["È"] = { -- alt+k + function() + require("dapui").eval() + end, + "Debug - eval expression" + } + } +} + M.terminal = { t = { [""] = {""} diff --git a/dot_config/nvim/lua/custom/plugins.lua b/dot_config/nvim/lua/custom/plugins.lua index af1a945..92335a2 100644 --- a/dot_config/nvim/lua/custom/plugins.lua +++ b/dot_config/nvim/lua/custom/plugins.lua @@ -22,6 +22,16 @@ local plugins = { require("core.utils").load_mappings("dap_go") 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 config = function() @@ -45,6 +55,6 @@ local plugins = { build = function() vim.cmd [[silent! GoInstallDeps]] end, - } + }, } return plugins