{ pkgs, ... }: let debuggers = { c = "lldb"; }; in { plugins.dap = { enable = true; extensions = { dap-ui.enable = true; dap-go.enable = true; dap-python.enable = true; dap-virtual-text.enable = true; }; adapters = { executables = { gdb = { id = "gdb"; command = "${pkgs.gdb}/bin/gdb"; args = [ "--interpreter=dap" "--quiet" "--eval-command" "set pretty print on" ]; }; cppdbg = { id = "cppdbg"; command = "${pkgs.vscode-extensions.ms-vscode.cpptools}/share/vscode/extensions/ms-vscode.cpptools/debugAdapters/bin/OpenDebugAD7"; }; lldb = { id = "lldb"; command = "${pkgs.llvmPackages.lldb}/bin/lldb-dap"; }; }; }; configurations = rec { c = cpp; rust = cpp; cpp = [ { name = "Launch"; request = "launch"; type = debuggers.c; cwd = "\${workspaceFolder}"; stopOnEntry = true; runInTerminal = true; program = { __raw = '' get_program ''; }; } { name = "Launch with Arguments"; request = "launch"; type = debuggers.c; cwd = "\${workspaceFolder}"; stopOnEntry = true; runInTerminal = true; program = { __raw = '' get_program ''; }; args = { __raw = '' function() local arguments_string = vim.fn.input('Executable arguments: ') return vim.split(arguments_string, " +") end ''; }; } ]; }; }; keymaps = [ { action = ":DapToggleBreakpoint"; key = "db"; options = { silent = true; desc = "[dap] Toggle Breakpoint"; }; } { action = ":DapUiToggle"; key = "du"; options = { silent = true; desc = "[dap] Toggle UI"; }; } { action = ":DapContinue"; key = "dc"; options = { silent = true; desc = "[dap] Continue / Run Debug"; }; } { action = ":DapRerun"; key = "dC"; options = { silent = true; desc = "[dap] Rerun Last"; }; } { action = ":DapStepOver"; key = "do"; options = { silent = true; desc = "[dap] Step over"; }; } { action = ":DapStepIn"; key = "di"; options = { silent = true; desc = "[dap] Step in"; }; } { action = ":DapStepOut"; key = "dO"; options = { silent = true; desc = "[dap] Step out"; }; } { action = ":DapTerminate"; key = "dT"; options = { silent = true; desc = "[dap] Terminate Process"; }; } { action = ":DapToggleRepl"; key = "dr"; options = { silent = true; desc = "[dap] Toggle REPL"; }; } ]; }