From 745da4539edc8b4189fcab4de0e2afb9fe4bea45 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Thu, 5 Dec 2024 00:09:40 +0100 Subject: [PATCH 1/2] keymaps: fix null key problems --- modules/neovim/mappings/options.nix | 2 +- modules/wrapper/rc/config.nix | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/neovim/mappings/options.nix b/modules/neovim/mappings/options.nix index 8f0e8ebf..98e04a65 100644 --- a/modules/neovim/mappings/options.nix +++ b/modules/neovim/mappings/options.nix @@ -32,7 +32,7 @@ mapConfigOptions // { key = mkOption { - type = str; + type = nullOr str; description = "The key that triggers this keybind."; }; mode = mkOption { diff --git a/modules/wrapper/rc/config.nix b/modules/wrapper/rc/config.nix index 627fd05b..ff8a4585 100644 --- a/modules/wrapper/rc/config.nix +++ b/modules/wrapper/rc/config.nix @@ -5,7 +5,7 @@ }: let inherit (builtins) map mapAttrs filter; inherit (lib.attrsets) mapAttrsToList; - inherit (lib.strings) concatLines concatMapStringsSep optionalString; + inherit (lib.strings) concatLines concatMapStringsSep; inherit (lib.trivial) showWarnings; inherit (lib.generators) mkLuaInline; inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere; @@ -43,7 +43,7 @@ in { toLuaKeymap = bind: "vim.keymap.set(${toLuaObject bind.mode}, ${toLuaObject bind.key}, ${toLuaObject (getAction bind)}, ${toLuaObject (getOpts bind)})"; - keymaps = concatLines (map toLuaKeymap cfg.keymaps); + keymaps = concatLines (map toLuaKeymap (filter (x: x.key != null) cfg.keymaps)); in { vim = { luaConfigRC = { From ff07905bb8b3150daad92634c125444f63b35ca5 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Thu, 5 Dec 2024 00:58:23 +0100 Subject: [PATCH 2/2] nvim-dap: fix bad keymap options --- modules/plugins/debugger/nvim-dap/config.nix | 34 +++++++++++--------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/modules/plugins/debugger/nvim-dap/config.nix b/modules/plugins/debugger/nvim-dap/config.nix index aa8f8386..70bd9891 100644 --- a/modules/plugins/debugger/nvim-dap/config.nix +++ b/modules/plugins/debugger/nvim-dap/config.nix @@ -11,6 +11,10 @@ inherit (lib.nvim.dag) entryAnywhere entryAfter; cfg = config.vim.debugger.nvim-dap; + opt = { + silent = true; + lua = true; + }; inherit (options.vim.debugger.nvim-dap) mappings; in { config = mkMerge [ @@ -29,23 +33,23 @@ in { // mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources; keymaps = [ - (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;}) + (mkKeymap "n" cfg.mappings.continue "require('dap').continue" (opt // {desc = mappings.continue.description;})) + (mkKeymap "n" cfg.mappings.restart "require('dap').restart" (opt // {desc = mappings.restart.description;})) + (mkKeymap "n" cfg.mappings.terminate "require('dap').terminate" (opt // {desc = mappings.terminate.description;})) + (mkKeymap "n" cfg.mappings.runLast "require('dap').run_last" (opt // {desc = mappings.runLast.description;})) - (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;}) + (mkKeymap "n" cfg.mappings.toggleRepl "require('dap').repl.toggle" (opt // {desc = mappings.toggleRepl.description;})) + (mkKeymap "n" cfg.mappings.hover "require('dap.ui.widgets').hover" (opt // {desc = mappings.hover.description;})) + (mkKeymap "n" cfg.mappings.toggleBreakpoint "require('dap').toggle_breakpoint" (opt // {desc = mappings.toggleBreakpoint.description;})) - (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;}) + (mkKeymap "n" cfg.mappings.runToCursor "require('dap').run_to_cursor" (opt // {desc = mappings.runToCursor.description;})) + (mkKeymap "n" cfg.mappings.stepInto "require('dap').step_into" (opt // {desc = mappings.stepInto.description;})) + (mkKeymap "n" cfg.mappings.stepOut "require('dap').step_out" (opt // {desc = mappings.stepOut.description;})) + (mkKeymap "n" cfg.mappings.stepOver "require('dap').step_over" (opt // {desc = mappings.stepOver.description;})) + (mkKeymap "n" cfg.mappings.stepBack "require('dap').step_back" (opt // {desc = mappings.stepBack.description;})) - (mkKeymap "n" cfg.mappings.goUp "require('dap').up" {desc = mappings.goUp.description;}) - (mkKeymap "n" cfg.mappings.goDown "require('dap').down" {desc = mappings.goDown.description;}) + (mkKeymap "n" cfg.mappings.goUp "require('dap').up" (opt // {desc = mappings.goUp.description;})) + (mkKeymap "n" cfg.mappings.goDown "require('dap').down" (opt // {desc = mappings.goDown.description;})) ]; }; }) @@ -59,7 +63,7 @@ in { inherit (cfg.ui) setupOpts; keys = [ - (mkKeymap "n" cfg.mappings.toggleDapUI "function() require('dapui').toggle() end" {desc = mappings.toggleDapUI.description;}) + (mkKeymap "n" cfg.mappings.toggleDapUI "function() require('dapui').toggle() end" (opt // {desc = mappings.toggleDapUI.description;})) ]; };