mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-23 17:28:39 +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;
|
||||
|
||||
keymaps = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
type = with types; attrsOf (either str attrs);
|
||||
description = "Keymaps for telescope.";
|
||||
default = {};
|
||||
example = {
|
||||
"<leader>fg" = "live_grep";
|
||||
"<C-p>" = "git_files";
|
||||
"<C-p>" = {
|
||||
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
|
||||
|
|
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