mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-24 01:38:40 +02:00
plugins/telescope: allow key mappings to be attrs
This commit is contained in:
parent
71c0b4cb59
commit
6152f77a63
2 changed files with 42 additions and 7 deletions
|
@ -27,12 +27,15 @@ in {
|
||||||
package = helpers.mkPackageOption "telescope.nvim" pkgs.vimPlugins.telescope-nvim;
|
package = helpers.mkPackageOption "telescope.nvim" pkgs.vimPlugins.telescope-nvim;
|
||||||
|
|
||||||
keymaps = mkOption {
|
keymaps = mkOption {
|
||||||
type = types.attrsOf types.str;
|
type = with types; attrsOf (either str attrs);
|
||||||
description = "Keymaps for telescope.";
|
description = "Keymaps for telescope.";
|
||||||
default = {};
|
default = {};
|
||||||
example = {
|
example = {
|
||||||
"<leader>fg" = "live_grep";
|
"<leader>fg" = "live_grep";
|
||||||
"<C-p>" = "git_files";
|
"<C-p>" = {
|
||||||
|
action = "git_files";
|
||||||
|
desc = "Telescope Git Files";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -82,11 +85,22 @@ in {
|
||||||
|
|
||||||
maps.normal =
|
maps.normal =
|
||||||
mapAttrs
|
mapAttrs
|
||||||
(key: action: {
|
(key: action: let
|
||||||
silent = cfg.keymapsSilent;
|
actionStr =
|
||||||
action = "require('telescope.builtin').${action}";
|
if isString action
|
||||||
lua = true;
|
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;
|
cfg.keymaps;
|
||||||
|
|
||||||
extraConfigLua = let
|
extraConfigLua = let
|
||||||
|
|
21
tests/test-sources/plugins/telescope/default.nix
Normal file
21
tests/test-sources/plugins/telescope/default.nix
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
empty = {
|
||||||
|
plugins.telescope.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
example = {
|
||||||
|
plugins.telescope = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
keymaps = {
|
||||||
|
"<leader>fg" = "live_grep";
|
||||||
|
"<C-p>" = {
|
||||||
|
action = "git_files";
|
||||||
|
desc = "Telescope Git Files";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
keymapsSilent = true;
|
||||||
|
highlightTheme = "gruvbox";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue