From 586a7f5b4146e453e21294f466d3d38eaa682d9d Mon Sep 17 00:00:00 2001 From: n3oney Date: Tue, 18 Apr 2023 18:14:44 +0200 Subject: [PATCH] feat: add todo-comments keybindings --- modules/notes/todo-comments/config.nix | 12 +++++++----- modules/notes/todo-comments/todo-comments.nix | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/modules/notes/todo-comments/config.nix b/modules/notes/todo-comments/config.nix index 45a26bc..3adb0f6 100644 --- a/modules/notes/todo-comments/config.nix +++ b/modules/notes/todo-comments/config.nix @@ -7,17 +7,19 @@ with lib; with builtins; let cfg = config.vim.notes.todo-comments; + self = import ./todo-comments.nix {inherit lib;}; + mappings = self.options.vim.notes.todo-comments.mappings; in { config = mkIf (cfg.enable) { vim.startPlugins = [ "todo-comments" ]; - vim.maps.normal = { - "tdq" = {action = ":TodoQuickFix";}; - "tds" = {action = ":TodoTelescope";}; - "tdt" = {action = ":TodoTrouble";}; - }; + vim.maps.normal = mkMerge [ + (mkBinding cfg.mappings.quickFix ":TodoQuickFix" mappings.quickFix.description) + (mkIf config.vim.telescope.enable (mkBinding cfg.mappings.telescope ":TodoTelescope" mappings.telescope.description)) + (mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble" mappings.trouble.description)) + ]; vim.luaConfigRC.todo-comments = '' require('todo-comments').setup { diff --git a/modules/notes/todo-comments/todo-comments.nix b/modules/notes/todo-comments/todo-comments.nix index 3064e75..39b8aad 100644 --- a/modules/notes/todo-comments/todo-comments.nix +++ b/modules/notes/todo-comments/todo-comments.nix @@ -1,8 +1,4 @@ -{ - config, - lib, - ... -}: +{lib, ...}: with lib; with builtins; { options.vim.notes.todo-comments = { @@ -21,5 +17,11 @@ with builtins; { description = "ripgrep regex pattern used for searching comments"; }; }; + + mappings = { + quickFix = mkMappingOption "Open Todo-s in a quickfix list" "tdq"; + telescope = mkMappingOption "Open Todo-s in telescope" "tds"; + trouble = mkMappingOption "Open Todo-s in Trouble" "tdt"; + }; }; }