neovim-flake/modules/debugger/nvim-dap/config.nix
2023-06-27 00:04:58 +02:00

42 lines
1.1 KiB
Nix

{
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.debugger.nvim-dap;
in {
config = mkMerge [
(mkIf cfg.enable {
vim.startPlugins = ["nvim-dap"];
vim.luaConfigRC =
{
nvim-dap = nvim.dag.entryAnywhere ''
local dap = require("dap")
'';
}
// mapAttrs (_: v: (nvim.dag.entryAfter ["nvim-dap"] v)) cfg.sources;
})
(mkIf (cfg.enable && cfg.ui.enable) {
vim.startPlugins = ["nvim-dap-ui"];
vim.luaConfigRC.nvim-dap-ui = nvim.dag.entryAfter ["nvim-dap"] (''
local dapui = require("dapui")
require("dapui").setup()
''
+ optionalString cfg.ui.autoStart ''
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
'');
})
];
}