nixos-combined-flake/modules/nixvim/plugins/dap.nix

147 lines
3.2 KiB
Nix

{ 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<CR>";
key = "<leader>db";
options = {
silent = true;
desc = "[dap] Toggle Breakpoint";
};
}
{
action = ":DapUiToggle<CR>";
key = "<leader>du";
options = {
silent = true;
desc = "[dap] Toggle UI";
};
}
{
action = ":DapContinue<CR>";
key = "<leader>dc";
options = {
silent = true;
desc = "[dap] Continue / Run Debug";
};
}
{
action = ":DapRerun<CR>";
key = "<leader>dC";
options = {
silent = true;
desc = "[dap] Rerun Last";
};
}
{
action = ":DapStepOver<CR>";
key = "<leader>do";
options = {
silent = true;
desc = "[dap] Step over";
};
}
{
action = ":DapStepIn<CR>";
key = "<leader>di";
options = {
silent = true;
desc = "[dap] Step in";
};
}
{
action = ":DapStepOut<CR>";
key = "<leader>dO";
options = {
silent = true;
desc = "[dap] Step out";
};
}
{
action = ":DapTerminate<CR>";
key = "<leader>dT";
options = {
silent = true;
desc = "[dap] Terminate Process";
};
}
{
action = ":DapToggleRepl<CR>";
key = "<leader>dr";
options = {
silent = true;
desc = "[dap] Toggle REPL";
};
}
];
}