diff --git a/plugins/telescope/default.nix b/plugins/telescope/default.nix index 986062cb..92c7f840 100644 --- a/plugins/telescope/default.nix +++ b/plugins/telescope/default.nix @@ -27,12 +27,15 @@ in { package = helpers.mkPackageOption "telescope.nvim" pkgs.vimPlugins.telescope-nvim; keymaps = mkOption { - type = types.attrsOf types.str; + type = with types; attrsOf (either str attrs); description = "Keymaps for telescope."; default = {}; example = { "fg" = "live_grep"; - "" = "git_files"; + "" = { + action = "git_files"; + desc = "Telescope Git Files"; + }; }; }; @@ -82,11 +85,22 @@ in { maps.normal = mapAttrs - (key: action: { - silent = cfg.keymapsSilent; - action = "require('telescope.builtin').${action}"; - lua = true; - }) + (key: action: let + actionStr = + if isString action + then action + else action.action; + actionProps = + if isString action + then {} + else filterAttrs (n: v: n != "action") action; + in + { + silent = cfg.keymapsSilent; + action = "require('telescope.builtin').${actionStr}"; + lua = true; + } + // actionProps) cfg.keymaps; extraConfigLua = let diff --git a/tests/test-sources/plugins/telescope/default.nix b/tests/test-sources/plugins/telescope/default.nix new file mode 100644 index 00000000..dd4c50a5 --- /dev/null +++ b/tests/test-sources/plugins/telescope/default.nix @@ -0,0 +1,21 @@ +{ + empty = { + plugins.telescope.enable = true; + }; + + example = { + plugins.telescope = { + enable = true; + + keymaps = { + "fg" = "live_grep"; + "" = { + action = "git_files"; + desc = "Telescope Git Files"; + }; + }; + keymapsSilent = true; + highlightTheme = "gruvbox"; + }; + }; +}