From 90937c49eb24f0bd1225a9fc712e8433bc26aecd Mon Sep 17 00:00:00 2001 From: Warwick Date: Sat, 28 Sep 2024 14:24:41 +0100 Subject: [PATCH] Added file that should have been in last commit --- lua/core/plugin_config/dap-debug.lua | 59 ++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 lua/core/plugin_config/dap-debug.lua diff --git a/lua/core/plugin_config/dap-debug.lua b/lua/core/plugin_config/dap-debug.lua new file mode 100644 index 0000000..28a05e4 --- /dev/null +++ b/lua/core/plugin_config/dap-debug.lua @@ -0,0 +1,59 @@ +local dap = require("dap") +local dapui = require("dapui") +dap.set_log_level('TRACE') + +-- open dapui on events +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 + +-- C/C++/Rust (via gdb) +dap.adapters.gdb = { + type = "executable", + command = "gdb", + args = { "--interpreter=dap", "--eval-command", "set print pretty on" } +} +dap.configurations.c = { + { + name = "Launch", + type = "gdb", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = "${workspaceFolder}", + stopAtBeginningOfMainSubprogram = false, + }, + { + name = "Select and attach to process", + type = "gdb", + request = "attach", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + pid = function() + local name = vim.fn.input('Executable name (filter): ') + return require("dap.utils").pick_process({ filter = name }) + end, + cwd = '${workspaceFolder}' + }, + { + name = 'Attach to gdbserver :1234', + type = 'gdb', + request = 'attach', + target = 'localhost:1234', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}' + }, +}