diff --git a/plugins/by-name/todo-comments/default.nix b/plugins/by-name/todo-comments/default.nix index 7898c7cd..04899b76 100644 --- a/plugins/by-name/todo-comments/default.nix +++ b/plugins/by-name/todo-comments/default.nix @@ -373,8 +373,11 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin { defaults = { inherit action; mode = "n"; + key = null; }; + key.type = with types; nullOr str; + extraOptions = { cwd = mkOption { type = types.nullOr types.str; @@ -430,7 +433,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin { extraPackages = [ cfg.ripgrepPackage ]; keymaps = lib.pipe cfg.keymaps [ - (filterAttrs (n: keymap: keymap != null)) + (filterAttrs (n: keymap: keymap != null && keymap.key != null)) (mapAttrsToList ( name: keymap: { inherit (keymap) key mode options; diff --git a/tests/test-sources/plugins/by-name/todo-comments/default.nix b/tests/test-sources/plugins/by-name/todo-comments/default.nix index 12b1ab98..0d99e86c 100644 --- a/tests/test-sources/plugins/by-name/todo-comments/default.nix +++ b/tests/test-sources/plugins/by-name/todo-comments/default.nix @@ -1,3 +1,4 @@ +{ lib, ... }: { empty = { plugins.todo-comments.enable = true; @@ -166,6 +167,27 @@ }; }; + conditional-mappings = + { config, ... }: + { + plugins.telescope.enable = true; + plugins.todo-comments = { + enable = true; + + keymaps = { + todoTrouble.key = lib.mkIf config.plugins.trouble.enable "xq"; + todoTelescope = lib.mkIf config.plugins.telescope.enable { + key = "ft"; + keywords = [ + "TODO" + "FIX" + "FIX" + ]; + }; + }; + }; + }; + without-ripgrep = { plugins.todo-comments = { enable = true;