From e45be89f1267faaae0e67fd6d3f3a2457314a94c Mon Sep 17 00:00:00 2001 From: traxys Date: Mon, 6 Nov 2023 15:53:26 +0100 Subject: [PATCH] plugins/todo-comments: Allow to pass keymap options (#599) This re-uses the keymap options defined in the keymaps module to allow to define the options of todo-comments key mappings. Fixes #598 Co-authored-by: gaetan@glepage.com --- plugins/utils/todo-comments.nix | 27 ++++++++++++------- .../plugins/utils/todo-comments.nix | 20 ++++++++++++-- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/plugins/utils/todo-comments.nix b/plugins/utils/todo-comments.nix index 5cb9b0e1..2465079f 100644 --- a/plugins/utils/todo-comments.nix +++ b/plugins/utils/todo-comments.nix @@ -15,6 +15,13 @@ with lib; let todoTelescope = "TodoTelescope"; }; in { + imports = [ + ( + mkRemovedOptionModule + ["plugins" "todo-comments" "keymapsSilent"] + "Use `plugins.todo-comments.keymaps..options.silent`." + ) + ]; options = { plugins.todo-comments = helpers.extraOptionsOptions @@ -182,16 +189,11 @@ in { ''; }; - # Keyboard shortcuts for :Todo* commands - keymapsSilent = mkOption { - type = types.bool; - description = "Whether todo-comments keymaps should be silent."; - default = false; - }; - keymaps = let mkKeymapOption = optionName: funcName: - helpers.mkCompositeOption "Keymap settings for the `:${funcName}` function." { + helpers.mkCompositeOption + "Keymap settings for the `:${funcName}` function." + { key = mkOption { type = types.str; description = "Key for the `${funcName}` function."; @@ -213,6 +215,8 @@ in { default = null; example = "TODO,FIX"; }; + + options = helpers.keymaps.mapConfigOptions; }; in mapAttrs mkKeymapOption commands; @@ -279,9 +283,12 @@ in { (keymap != null) { mode = "n"; - inherit (keymap) key; + inherit + (keymap) + key + options + ; action = ":${funcName}${cwd}${keywords}"; - options.silent = cfg.keymapsSilent; } ) commands diff --git a/tests/test-sources/plugins/utils/todo-comments.nix b/tests/test-sources/plugins/utils/todo-comments.nix index 0c0e532c..7ffc6ff4 100644 --- a/tests/test-sources/plugins/utils/todo-comments.nix +++ b/tests/test-sources/plugins/utils/todo-comments.nix @@ -89,14 +89,13 @@ pattern = ''\b(KEYWORDS):''; }; - keymapsSilent = true; - keymaps = { todoQuickFix.key = ""; todoLocList = { key = ""; cwd = "~/projects/foobar"; keywords = "TODO,FIX"; + options.silent = true; }; todoTrouble = { key = ""; @@ -109,4 +108,21 @@ }; }; }; + + keymapsOptions = { + plugins.todo-comments = { + enable = true; + + keymaps = { + todoTrouble = { + key = ""; + keywords = "TODO,FIX"; + options = { + desc = "Description for todoTrouble"; + silent = true; + }; + }; + }; + }; + }; }