mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-22 09:49:49 +01:00
feat: add mapping options for nvim-dap
This commit is contained in:
parent
588d348bd2
commit
fe9da14d85
2 changed files with 49 additions and 22 deletions
|
@ -6,6 +6,11 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.debugger.nvim-dap;
|
cfg = config.vim.debugger.nvim-dap;
|
||||||
|
self = import ./nvim-dap.nix {
|
||||||
|
inherit lib;
|
||||||
|
};
|
||||||
|
mappingDefinitions = self.options.vim.debugger.nvim-dap.mappings;
|
||||||
|
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||||
in {
|
in {
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
(mkIf cfg.enable {
|
(mkIf cfg.enable {
|
||||||
|
@ -16,37 +21,36 @@ in {
|
||||||
# TODO customizable keymaps
|
# TODO customizable keymaps
|
||||||
nvim-dap = nvim.dag.entryAnywhere ''
|
nvim-dap = nvim.dag.entryAnywhere ''
|
||||||
local dap = require("dap")
|
local dap = require("dap")
|
||||||
local opts = { noremap = true, silent = true }
|
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>d.", "<cmd>lua require'dap'.run_last()<cr>", opts)
|
|
||||||
vim.keymap.set("n", "<leader>dR", "<cmd>lua require'dap'.restart()<cr>", opts)
|
|
||||||
vim.keymap.set("n", "<leader>dq", "<cmd>lua require'dap'.terminate()<cr>", opts)
|
|
||||||
vim.keymap.set("n", "<leader>db", "<cmd>lua require'dap'.toggle_breakpoint()<cr>", opts)
|
|
||||||
vim.keymap.set("n", "<leader>dc", "<cmd>lua require'dap'.continue()<cr>", opts)
|
|
||||||
vim.keymap.set("n", "<leader>dl", "<cmd>lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<cr>", opts)
|
|
||||||
vim.keymap.set("n", "<leader>dgb", "<cmd>lua require'dap'.continue()<cr>", opts)
|
|
||||||
vim.keymap.set("n", "<leader>dgc", "<cmd>lua require'dap'.run_to_cursor()<cr>", opts)
|
|
||||||
vim.keymap.set("n", "<leader>dgi", "<cmd>lua require'dap'.step_into()<cr>", opts)
|
|
||||||
vim.keymap.set("n", "<leader>dgo", "<cmd>lua require'dap'.step_out()<cr>", opts)
|
|
||||||
vim.keymap.set("n", "<leader>dgI", "<cmd>lua require'dap'.down()<cr>", opts)
|
|
||||||
vim.keymap.set("n", "<leader>dgO", "<cmd>lua require'dap'.up()<cr>", opts)
|
|
||||||
vim.keymap.set("n", "<leader>dgj", "<cmd>lua require'dap'.step_over()<cr>", opts)
|
|
||||||
vim.keymap.set("n", "<leader>dgk", "<cmd>lua require'dap'.step_back()<cr>", opts)
|
|
||||||
vim.keymap.set("n", "<leader>dr", "<cmd>lua require'dap'.repl.toggle()<cr>", opts)
|
|
||||||
vim.keymap.set("n", "<leader>dh", "<cmd>lua require'dap.ui.widgets'.hover()<cr>", opts)
|
|
||||||
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
// mapAttrs (_: v: (nvim.dag.entryAfter ["nvim-dap"] v)) cfg.sources;
|
// mapAttrs (_: v: (nvim.dag.entryAfter ["nvim-dap"] v)) cfg.sources;
|
||||||
|
|
||||||
|
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")
|
||||||
|
];
|
||||||
})
|
})
|
||||||
(mkIf (cfg.enable && cfg.ui.enable) {
|
(mkIf (cfg.enable && cfg.ui.enable) {
|
||||||
vim.startPlugins = ["nvim-dap-ui"];
|
vim.startPlugins = ["nvim-dap-ui"];
|
||||||
|
|
||||||
vim.luaConfigRC.nvim-dap-ui = nvim.dag.entryAfter ["nvim-dap"] (''
|
vim.luaConfigRC.nvim-dap-ui = nvim.dag.entryAfter ["nvim-dap"] (''
|
||||||
local dapui = require("dapui")
|
local dapui = require("dapui")
|
||||||
require("dapui").setup()
|
dapui.setup()
|
||||||
vim.keymap.set("n", "<leader>du", "<cmd>lua require'dapui'.toggle()<cr>", opts)
|
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>dd", "<cmd>lua require'dapui'.eval()<cr>", opts)
|
|
||||||
''
|
''
|
||||||
+ optionalString cfg.ui.autoStart ''
|
+ optionalString cfg.ui.autoStart ''
|
||||||
dap.listeners.after.event_initialized["dapui_config"] = function()
|
dap.listeners.after.event_initialized["dapui_config"] = function()
|
||||||
|
@ -59,6 +63,7 @@ in {
|
||||||
dapui.close()
|
dapui.close()
|
||||||
end
|
end
|
||||||
'');
|
'');
|
||||||
|
vim.maps.normal = mkSetLuaBinding mappings.toggleDapUI "require('dapui').toggle";
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,5 +17,27 @@ with lib; {
|
||||||
description = "List of debuggers to install";
|
description = "List of debuggers to install";
|
||||||
type = with types; attrsOf string;
|
type = with types; attrsOf string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
continue = mkMappingOption "Contiue" "<leader>dc";
|
||||||
|
restart = mkMappingOption "Restart" "<leader>dR";
|
||||||
|
terminate = mkMappingOption "Terminate" "<leader>dq";
|
||||||
|
runLast = mkMappingOption "Re-run Last Debug Session" "<leader>d.";
|
||||||
|
|
||||||
|
toggleRepl = mkMappingOption "Toggle Repl" "<leader>dr";
|
||||||
|
hover = mkMappingOption "Hover" "<leader>dh";
|
||||||
|
toggleBreakpoint = mkMappingOption "Toggle breakpoint" "<leader>db";
|
||||||
|
|
||||||
|
runToCursor = mkMappingOption "Continue to the current cursor" "<leader>dgc";
|
||||||
|
stepInto = mkMappingOption "Step into function" "<leader>dgi";
|
||||||
|
stepOut = mkMappingOption "Step out of function" "<leader>dgo";
|
||||||
|
stepOver = mkMappingOption "Next step" "<leader>dgj";
|
||||||
|
stepBack = mkMappingOption "Step back" "<leader>dgk";
|
||||||
|
|
||||||
|
goUp = mkMappingOption "Go up stacktrace" "<leader>dvo";
|
||||||
|
goDown = mkMappingOption "Go down stacktrace" "<leader>dvi";
|
||||||
|
|
||||||
|
toggleDapUI = mkMappingOption "Toggle DAP-UI" "<leader>du";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue