2023-05-04 17:41:11 +02:00
|
|
|
{
|
2024-11-17 20:28:20 +01:00
|
|
|
options,
|
2023-05-04 17:41:11 +02:00
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
2023-11-07 01:50:27 +01:00
|
|
|
}: let
|
2024-02-26 06:05:23 +01:00
|
|
|
inherit (lib.strings) optionalString;
|
|
|
|
inherit (lib.modules) mkIf mkMerge;
|
|
|
|
inherit (lib.attrsets) mapAttrs;
|
2024-11-17 20:28:20 +01:00
|
|
|
inherit (lib.nvim.binds) mkKeymap;
|
2024-02-26 06:05:23 +01:00
|
|
|
inherit (lib.nvim.dag) entryAnywhere entryAfter;
|
2023-11-07 01:50:27 +01:00
|
|
|
|
2023-05-04 17:41:11 +02:00
|
|
|
cfg = config.vim.debugger.nvim-dap;
|
2024-11-17 20:28:20 +01:00
|
|
|
inherit (options.vim.debugger.nvim-dap) mappings;
|
2023-05-04 17:41:11 +02:00
|
|
|
in {
|
2023-05-05 15:31:55 +02:00
|
|
|
config = mkMerge [
|
|
|
|
(mkIf cfg.enable {
|
2024-10-09 19:50:34 +02:00
|
|
|
vim = {
|
|
|
|
startPlugins = ["nvim-dap"];
|
2023-05-04 17:41:11 +02:00
|
|
|
|
2024-10-09 19:50:34 +02:00
|
|
|
pluginRC =
|
|
|
|
{
|
|
|
|
# TODO customizable keymaps
|
|
|
|
nvim-dap = entryAnywhere ''
|
|
|
|
local dap = require("dap")
|
|
|
|
vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "ErrorMsg", linehl = "", numhl = "" })
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
// mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources;
|
2023-06-12 02:59:34 +02:00
|
|
|
|
2024-10-09 19:50:34 +02:00
|
|
|
maps.normal = mkMerge [
|
2024-11-17 20:28:20 +01:00
|
|
|
(mkKeymap "n" cfg.mappings.continue "require('dap').continue" {desc = mappings.continue.description;})
|
|
|
|
(mkKeymap "n" cfg.mappings.restart "require('dap').restart" {desc = mappings.restart.description;})
|
|
|
|
(mkKeymap "n" cfg.mappings.terminate "require('dap').terminate" {desc = mappings.terminate.description;})
|
|
|
|
(mkKeymap "n" cfg.mappings.runLast "require('dap').run_last" {desc = mappings.runLast.description;})
|
2023-06-12 02:59:34 +02:00
|
|
|
|
2024-11-17 20:28:20 +01:00
|
|
|
(mkKeymap "n" cfg.mappings.toggleRepl "require('dap').repl.toggle" {desc = mappings.toggleRepl.description;})
|
|
|
|
(mkKeymap "n" cfg.mappings.hover "require('dap.ui.widgets').hover" {desc = mappings.hover.description;})
|
|
|
|
(mkKeymap "n" cfg.mappings.toggleBreakpoint "require('dap').toggle_breakpoint" {desc = mappings.toggleBreakpoint.description;})
|
2023-06-12 02:59:34 +02:00
|
|
|
|
2024-11-17 20:28:20 +01:00
|
|
|
(mkKeymap "n" cfg.mappings.runToCursor "require('dap').run_to_cursor" {desc = mappings.runToCursor.description;})
|
|
|
|
(mkKeymap "n" cfg.mappings.stepInto "require('dap').step_into" {desc = mappings.stepInto.description;})
|
|
|
|
(mkKeymap "n" cfg.mappings.stepOut "require('dap').step_out" {desc = mappings.stepOut.description;})
|
|
|
|
(mkKeymap "n" cfg.mappings.stepOver "require('dap').step_over" {desc = mappings.stepOver.description;})
|
|
|
|
(mkKeymap "n" cfg.mappings.stepBack "require('dap').step_back" {desc = mappings.stepBack.description;})
|
2023-06-12 02:59:34 +02:00
|
|
|
|
2024-11-17 20:28:20 +01:00
|
|
|
(mkKeymap "n" cfg.mappings.goUp "require('dap').up" {desc = mappings.goUp.description;})
|
|
|
|
(mkKeymap "n" cfg.mappings.goDown "require('dap').down" {desc = mappings.goDown.description;})
|
2024-10-09 19:50:34 +02:00
|
|
|
];
|
|
|
|
};
|
2023-05-05 15:31:55 +02:00
|
|
|
})
|
|
|
|
(mkIf (cfg.enable && cfg.ui.enable) {
|
2024-10-09 19:50:34 +02:00
|
|
|
vim = {
|
2024-11-04 16:50:50 +01:00
|
|
|
startPlugins = ["nvim-nio"];
|
2023-05-05 15:31:55 +02:00
|
|
|
|
2024-11-04 16:50:50 +01:00
|
|
|
lazy.plugins.nvim-dap-ui = {
|
|
|
|
package = "nvim-dap-ui";
|
|
|
|
setupModule = "dapui";
|
|
|
|
inherit (cfg.ui) setupOpts;
|
|
|
|
|
|
|
|
keys = [
|
2024-11-17 20:28:20 +01:00
|
|
|
(mkKeymap "n" cfg.mappings.toggleDapUI "function() require('dapui').toggle() end" {desc = mappings.toggleDapUI.descritpion;})
|
2024-11-04 16:50:50 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] (
|
|
|
|
optionalString cfg.ui.autoStart ''
|
2024-10-09 19:50:34 +02:00
|
|
|
dap.listeners.after.event_initialized["dapui_config"] = function()
|
2024-11-04 16:50:50 +01:00
|
|
|
require("dapui").open()
|
2024-10-09 19:50:34 +02:00
|
|
|
end
|
|
|
|
dap.listeners.before.event_terminated["dapui_config"] = function()
|
2024-11-04 16:50:50 +01:00
|
|
|
require("dapui").close()
|
2024-10-09 19:50:34 +02:00
|
|
|
end
|
|
|
|
dap.listeners.before.event_exited["dapui_config"] = function()
|
2024-11-04 16:50:50 +01:00
|
|
|
require("dapui").close()
|
2024-10-09 19:50:34 +02:00
|
|
|
end
|
2024-11-04 16:50:50 +01:00
|
|
|
''
|
|
|
|
);
|
2024-10-09 19:50:34 +02:00
|
|
|
};
|
2023-05-05 15:31:55 +02:00
|
|
|
})
|
|
|
|
];
|
2023-05-04 17:41:11 +02:00
|
|
|
}
|