From 768117465337152284c286be645b83eda02a2cea Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Tue, 10 Dec 2024 15:16:36 +0100 Subject: [PATCH] feat: add dap --- lua/plugins/dap.lua | 86 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 lua/plugins/dap.lua diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua new file mode 100644 index 0000000..0782b4c --- /dev/null +++ b/lua/plugins/dap.lua @@ -0,0 +1,86 @@ +-- https://github.com/mfussenegger/nvim-dap + +---@type LazyPluginSpec +return { + "mfussenegger/nvim-dap", + keys = { + { + "db", + function() + require("dap").toggle_breakpoint() + end, + }, + { + "", + function() + require("dap.ui.widgets").hover() + end, + }, + { + "", + function() + require("dap").step_into() + end, + }, + { + "", + function() + require("dap").step_over() + end, + }, + { + "", + function() + require("dap").step_out() + end, + }, + { + "", + function() + require("dap").continue() + end, + }, + { + "", + function() + local widgets = require("dap.ui.widgets") + widgets.centered_float(widgets.scopes) + end, + }, + { + "", + function() + require("dap").terminate() + end, + }, + }, + config = function() + local dap = require("dap") + + -- https://sourceware.org/gdb/current/onlinedocs/gdb#Debugger-Adapter-Protocol + dap.adapters.gdb = { + type = "executable", + command = "gdb", + args = { + "--interpreter=dap", + "--eval-command", + "set print pretty on", + "--eval-command", + "set startup-with-shell off", + }, + } + + dap.configurations.cpp = { + { + name = "Launch", + type = "gdb", + request = "launch", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end, + cwd = "${workspaceFolder}", + stopAtBeginningOfMainSubprogram = false, + }, + } + end, +}