nvim-dap: use new keybind helpers

This commit is contained in:
Ching Pei Yang 2024-11-17 20:28:20 +01:00
parent dd1bc19600
commit e812ef2c3f
No known key found for this signature in database
GPG key ID: B3841364253DC4C8

View file

@ -1,4 +1,5 @@
{ {
options,
config, config,
lib, lib,
... ...
@ -6,13 +7,11 @@
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.attrsets) mapAttrs; inherit (lib.attrsets) mapAttrs;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding mkSetLuaLznBinding; inherit (lib.nvim.binds) mkKeymap;
inherit (lib.nvim.dag) entryAnywhere entryAfter; inherit (lib.nvim.dag) entryAnywhere entryAfter;
cfg = config.vim.debugger.nvim-dap; cfg = config.vim.debugger.nvim-dap;
self = import ./nvim-dap.nix {inherit lib;}; inherit (options.vim.debugger.nvim-dap) mappings;
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 {
@ -30,23 +29,23 @@ in {
// mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources; // mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources;
maps.normal = mkMerge [ maps.normal = mkMerge [
(mkSetLuaBinding mappings.continue "require('dap').continue") (mkKeymap "n" cfg.mappings.continue "require('dap').continue" {desc = mappings.continue.description;})
(mkSetLuaBinding mappings.restart "require('dap').restart") (mkKeymap "n" cfg.mappings.restart "require('dap').restart" {desc = mappings.restart.description;})
(mkSetLuaBinding mappings.terminate "require('dap').terminate") (mkKeymap "n" cfg.mappings.terminate "require('dap').terminate" {desc = mappings.terminate.description;})
(mkSetLuaBinding mappings.runLast "require('dap').run_last") (mkKeymap "n" cfg.mappings.runLast "require('dap').run_last" {desc = mappings.runLast.description;})
(mkSetLuaBinding mappings.toggleRepl "require('dap').repl.toggle") (mkKeymap "n" cfg.mappings.toggleRepl "require('dap').repl.toggle" {desc = mappings.toggleRepl.description;})
(mkSetLuaBinding mappings.hover "require('dap.ui.widgets').hover") (mkKeymap "n" cfg.mappings.hover "require('dap.ui.widgets').hover" {desc = mappings.hover.description;})
(mkSetLuaBinding mappings.toggleBreakpoint "require('dap').toggle_breakpoint") (mkKeymap "n" cfg.mappings.toggleBreakpoint "require('dap').toggle_breakpoint" {desc = mappings.toggleBreakpoint.description;})
(mkSetLuaBinding mappings.runToCursor "require('dap').run_to_cursor") (mkKeymap "n" cfg.mappings.runToCursor "require('dap').run_to_cursor" {desc = mappings.runToCursor.description;})
(mkSetLuaBinding mappings.stepInto "require('dap').step_into") (mkKeymap "n" cfg.mappings.stepInto "require('dap').step_into" {desc = mappings.stepInto.description;})
(mkSetLuaBinding mappings.stepOut "require('dap').step_out") (mkKeymap "n" cfg.mappings.stepOut "require('dap').step_out" {desc = mappings.stepOut.description;})
(mkSetLuaBinding mappings.stepOver "require('dap').step_over") (mkKeymap "n" cfg.mappings.stepOver "require('dap').step_over" {desc = mappings.stepOver.description;})
(mkSetLuaBinding mappings.stepBack "require('dap').step_back") (mkKeymap "n" cfg.mappings.stepBack "require('dap').step_back" {desc = mappings.stepBack.description;})
(mkSetLuaBinding mappings.goUp "require('dap').up") (mkKeymap "n" cfg.mappings.goUp "require('dap').up" {desc = mappings.goUp.description;})
(mkSetLuaBinding mappings.goDown "require('dap').down") (mkKeymap "n" cfg.mappings.goDown "require('dap').down" {desc = mappings.goDown.description;})
]; ];
}; };
}) })
@ -60,7 +59,7 @@ in {
inherit (cfg.ui) setupOpts; inherit (cfg.ui) setupOpts;
keys = [ keys = [
(mkSetLuaLznBinding "n" mappings.toggleDapUI "function() require('dapui').toggle() end") (mkKeymap "n" cfg.mappings.toggleDapUI "function() require('dapui').toggle() end" {desc = mappings.toggleDapUI.descritpion;})
]; ];
}; };