2023-05-04 15:41:11 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
2023-11-07 00:50:27 +00:00
|
|
|
}: let
|
2024-02-26 05:05:23 +00:00
|
|
|
inherit (lib.strings) optionalString;
|
|
|
|
inherit (lib.modules) mkIf mkMerge;
|
|
|
|
inherit (lib.attrsets) mapAttrs;
|
2024-09-30 19:58:43 +00:00
|
|
|
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding mkSetLuaLznBinding;
|
2024-02-26 05:05:23 +00:00
|
|
|
inherit (lib.nvim.dag) entryAnywhere entryAfter;
|
2023-11-07 00:50:27 +00:00
|
|
|
|
2023-05-04 15:41:11 +00:00
|
|
|
cfg = config.vim.debugger.nvim-dap;
|
2024-02-26 05:05:23 +00:00
|
|
|
self = import ./nvim-dap.nix {inherit lib;};
|
2023-06-12 00:59:34 +00:00
|
|
|
mappingDefinitions = self.options.vim.debugger.nvim-dap.mappings;
|
|
|
|
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
2023-05-04 15:41:11 +00:00
|
|
|
in {
|
2023-05-05 13:31:55 +00:00
|
|
|
config = mkMerge [
|
|
|
|
(mkIf cfg.enable {
|
|
|
|
vim.startPlugins = ["nvim-dap"];
|
2023-05-04 15:41:11 +00:00
|
|
|
|
2024-07-20 08:30:48 +00:00
|
|
|
vim.pluginRC =
|
2023-05-08 11:01:42 +00:00
|
|
|
{
|
2023-05-08 11:03:03 +00:00
|
|
|
# TODO customizable keymaps
|
2024-02-26 05:05:23 +00:00
|
|
|
nvim-dap = entryAnywhere ''
|
2023-05-08 11:01:42 +00:00
|
|
|
local dap = require("dap")
|
2023-06-15 16:17:13 +00:00
|
|
|
vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "ErrorMsg", linehl = "", numhl = "" })
|
2023-05-08 11:01:42 +00:00
|
|
|
'';
|
|
|
|
}
|
2024-02-26 05:05:23 +00:00
|
|
|
// mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources;
|
2023-06-12 00:59:34 +00: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 13:31:55 +00:00
|
|
|
})
|
|
|
|
(mkIf (cfg.enable && cfg.ui.enable) {
|
2024-09-30 19:58:43 +00:00
|
|
|
vim.startPlugins = ["nvim-nio"];
|
2023-05-05 13:31:55 +00:00
|
|
|
|
2024-09-30 19:58:43 +00:00
|
|
|
vim.lazy.plugins = [
|
|
|
|
{
|
|
|
|
package = "nvim-dap-ui";
|
|
|
|
setupModule = "dapui";
|
|
|
|
setupOpts = {};
|
|
|
|
|
|
|
|
keys = [
|
|
|
|
(mkSetLuaLznBinding mappings.toggleDapUI "function() require('dapui').toggle() end")
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
vim.pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] (
|
|
|
|
optionalString cfg.ui.autoStart ''
|
2023-05-05 13:31:55 +00:00
|
|
|
dap.listeners.after.event_initialized["dapui_config"] = function()
|
2024-09-30 19:58:43 +00:00
|
|
|
require("dapui").open()
|
2023-05-05 13:31:55 +00:00
|
|
|
end
|
|
|
|
dap.listeners.before.event_terminated["dapui_config"] = function()
|
2024-09-30 19:58:43 +00:00
|
|
|
require("dapui").close()
|
2023-05-05 13:31:55 +00:00
|
|
|
end
|
|
|
|
dap.listeners.before.event_exited["dapui_config"] = function()
|
2024-09-30 19:58:43 +00:00
|
|
|
require("dapui").close()
|
2023-05-05 13:31:55 +00:00
|
|
|
end
|
2024-09-30 19:58:43 +00:00
|
|
|
''
|
|
|
|
);
|
2023-05-05 13:31:55 +00:00
|
|
|
})
|
|
|
|
];
|
2023-05-04 15:41:11 +00:00
|
|
|
}
|