local dapui = require('dapui') local dap = require("dap") -- DAP UI setup dapui.setup() -- Basic DAP UI event listeners dap.listeners.after.event_initialized["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 -- DAP for C dap.adapters.gdb = { type = "executable", command = "gdb", args = { "--interpreter=dap", "--eval-command", "set print pretty on" } } dap.adapters.lldb = { type = 'executable', command = 'lldb-dap', name = 'lldb' } 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}", stopOnEntry = 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 process', type = 'gdb', request = 'attach', pid = function () return vim.fn.input('Enter PID: ') end, args = {}, }, { 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}' }, } dap.configurations.zig = { { name = "Debug Zig Executable", type = "lldb", request = "launch", program = function() return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/zig-out/bin/', 'file') end, cwd = "${workspaceFolder}", args = {}, stopOnEntry = false, }, { name = 'Attach to Zig Process', type = 'lldb', request = 'attach', pid = require('dap.ui.widgets').hover, args = {}, } } -- DAP Keybinds vim.keymap.set('n', '', function() dap.continue() end) vim.keymap.set('n', '', function() dap.step_over() end) vim.keymap.set('n', '', function() dap.step_into() end) vim.keymap.set('n', '', function() dap.step_out() end) vim.keymap.set('n', 'bp', function() dap.toggle_breakpoint() end) vim.keymap.set('n', 'dr', function() dap.repl.open() end)