neovim-flake/modules/debugger/nvim-dap/config.nix

70 lines
2.4 KiB
Nix
Raw Normal View History

2023-05-04 17:41:11 +02:00
{
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.debugger.nvim-dap;
2023-06-12 02:59:34 +02:00
self = import ./nvim-dap.nix {
inherit lib;
};
mappingDefinitions = self.options.vim.debugger.nvim-dap.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
2023-05-04 17:41:11 +02:00
in {
2023-05-05 15:31:55 +02:00
config = mkMerge [
(mkIf cfg.enable {
vim.startPlugins = ["nvim-dap"];
2023-05-04 17:41:11 +02:00
2023-05-08 13:01:42 +02:00
vim.luaConfigRC =
{
2023-05-08 13:03:03 +02:00
# TODO customizable keymaps
2023-05-08 13:01:42 +02:00
nvim-dap = nvim.dag.entryAnywhere ''
local dap = require("dap")
'';
}
// mapAttrs (_: v: (nvim.dag.entryAfter ["nvim-dap"] v)) cfg.sources;
2023-06-12 02:59:34 +02:00
vim.maps.normal = mkMerge [
(mkSetLuaBinding mappings.continue "require('dap').continue")
(mkSetLuaBinding mappings.restart "require('dap').restart")
(mkSetLuaBinding mappings.terminate "require('dap').terminate")
(mkSetLuaBinding mappings.runLast "require('dap').run_last")
(mkSetLuaBinding mappings.toggleRepl "require('dap').repl.toggle")
(mkSetLuaBinding mappings.hover "require('dap.ui.widgets').hover")
(mkSetLuaBinding mappings.toggleBreakpoint "require('dap').toggle_breakpoint")
(mkSetLuaBinding mappings.runToCursor "require('dap').run_to_cursor")
(mkSetLuaBinding mappings.stepInto "require('dap').step_into")
(mkSetLuaBinding mappings.stepOut "require('dap').step_out")
(mkSetLuaBinding mappings.stepOver "require('dap').step_over")
(mkSetLuaBinding mappings.stepBack "require('dap').step_back")
(mkSetLuaBinding mappings.goUp "require('dap').up")
(mkSetLuaBinding mappings.goDown "require('dap').down")
];
2023-05-05 15:31:55 +02:00
})
(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")
2023-06-12 02:59:34 +02:00
dapui.setup()
2023-05-05 15:31:55 +02:00
''
+ 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
'');
2023-06-12 02:59:34 +02:00
vim.maps.normal = mkSetLuaBinding mappings.toggleDapUI "require('dapui').toggle";
2023-05-05 15:31:55 +02:00
})
];
2023-05-04 17:41:11 +02:00
}