aboutsummaryrefslogtreecommitdiff
path: root/lua/user
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2023-03-12 21:19:25 +0200
committersrdusr <trevorgray@srdusr.com>2023-03-12 21:19:25 +0200
commit3999f9e6639eba12708689b6bb58353da198210a (patch)
treef97f7a840eb38e5587214a178c3f5df091709bf7 /lua/user
parent02a32cd80527bcfbe8befcc4a87861e05462c070 (diff)
downloaddotfiles-3999f9e6639eba12708689b6bb58353da198210a.tar.gz
dotfiles-3999f9e6639eba12708689b6bb58353da198210a.zip
Add plugin dap mappings
Diffstat (limited to 'lua/user')
-rw-r--r--lua/user/keys.lua39
1 files changed, 39 insertions, 0 deletions
diff --git a/lua/user/keys.lua b/lua/user/keys.lua
index 689ff13..77edfa8 100644
--- a/lua/user/keys.lua
+++ b/lua/user/keys.lua
@@ -331,6 +331,45 @@ map("n", "<leader>q", function()
end
end, { desc = "Toggle quickfix window" })
+-- Dap (debugging)
+local dap_ok, dap = pcall(require, "dap")
+local dap_ui_ok, ui = pcall(require, "dapui")
+
+if not (dap_ok and dap_ui_ok) then
+ require("notify")("nvim-dap or dap-ui not installed!", "warning") -- nvim-notify is a separate plugin, I recommend it too!
+ return
+end
+
+vim.fn.sign_define('DapBreakpoint', { text = '🐞' })
+
+-- Start debugging session
+vim.keymap.set("n", "<localleader>ds", function()
+ dap.continue()
+ ui.toggle({})
+ vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<C-w>=", false, true, true), "n", false) -- Spaces buffers evenly
+end)
+
+-- Set breakpoints, get variable values, step into/out of functions, etc.
+map("n", "<leader>dl", require("dap.ui.widgets").hover)
+map("n", "<leader>dc", dap.continue)
+map("n", "<leader>db", dap.toggle_breakpoint)
+map("n", "<leader>dn", dap.step_over)
+map("n", "<leader>di", dap.step_into)
+map("n", "<leader>do", dap.step_out)
+map("n", "<leader>dC", function()
+ dap.clear_breakpoints()
+ require("notify")("Breakpoints cleared", "warn")
+end)
+
+-- Close debugger and clear breakpoints
+map("n", "<leader>de", function()
+ dap.clear_breakpoints()
+ ui.toggle({})
+ dap.terminate()
+ vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<C-w>=", false, true, true), "n", false)
+ require("notify")("Debugger session ended", "warn")
+end)
+
-- Dashboard
map("n", "<leader>db", "<CMD>Dashboard<CR>")