2023-02-20 11:42:13 +01:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
2023-01-25 19:46:49 +01:00
|
|
|
}:
|
2023-02-20 11:42:13 +01:00
|
|
|
with lib; let
|
2022-09-18 11:19:23 +01:00
|
|
|
cfg = config.plugins.telescope;
|
2023-02-20 11:42:13 +01:00
|
|
|
helpers = import ../helpers.nix {inherit lib;};
|
|
|
|
in {
|
2021-12-23 20:12:37 +01:00
|
|
|
imports = [
|
2023-07-02 10:01:22 +03:30
|
|
|
./file-browser.nix
|
2021-12-23 20:12:37 +01:00
|
|
|
./frecency.nix
|
2021-12-23 21:51:56 +01:00
|
|
|
./fzf-native.nix
|
2021-12-23 21:58:22 +01:00
|
|
|
./fzy-native.nix
|
2022-08-27 23:26:03 +00:00
|
|
|
./media-files.nix
|
2022-10-25 01:15:09 +02:00
|
|
|
./project-nvim.nix
|
2023-10-25 22:08:23 +01:00
|
|
|
./undo.nix
|
2021-12-23 20:12:37 +01:00
|
|
|
];
|
|
|
|
|
2021-12-23 20:01:49 +01:00
|
|
|
# TODO:add support for aditional filetypes. This requires autocommands!
|
|
|
|
|
2023-03-01 22:57:19 +01:00
|
|
|
options.plugins.telescope =
|
|
|
|
helpers.extraOptionsOptions
|
|
|
|
// {
|
|
|
|
enable = mkEnableOption "telescope.nvim";
|
|
|
|
|
|
|
|
package = helpers.mkPackageOption "telescope.nvim" pkgs.vimPlugins.telescope-nvim;
|
|
|
|
|
|
|
|
keymaps = mkOption {
|
2023-07-17 13:18:08 +02:00
|
|
|
type = with types; attrsOf (either str attrs);
|
2023-03-01 22:57:19 +01:00
|
|
|
description = "Keymaps for telescope.";
|
|
|
|
default = {};
|
|
|
|
example = {
|
|
|
|
"<leader>fg" = "live_grep";
|
2023-07-17 13:18:08 +02:00
|
|
|
"<C-p>" = {
|
|
|
|
action = "git_files";
|
|
|
|
desc = "Telescope Git Files";
|
|
|
|
};
|
2023-03-01 22:57:19 +01:00
|
|
|
};
|
2023-02-23 10:14:10 +01:00
|
|
|
};
|
|
|
|
|
2023-03-01 22:57:19 +01:00
|
|
|
keymapsSilent = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
description = "Whether telescope keymaps should be silent";
|
|
|
|
default = false;
|
|
|
|
};
|
2021-12-23 20:01:49 +01:00
|
|
|
|
2023-03-01 22:57:19 +01:00
|
|
|
highlightTheme = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
description = "The colorscheme to use for syntax highlighting";
|
|
|
|
default = config.colorscheme;
|
|
|
|
};
|
2021-12-23 21:29:17 +01:00
|
|
|
|
2023-03-01 22:57:19 +01:00
|
|
|
enabledExtensions = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = "A list of enabled extensions. Don't use this directly";
|
|
|
|
default = [];
|
|
|
|
};
|
2022-12-01 20:58:35 +01:00
|
|
|
|
2023-03-01 22:57:19 +01:00
|
|
|
extensionConfig = mkOption {
|
|
|
|
type = types.attrsOf types.anything;
|
|
|
|
description = "Configuration for the extensions. Don't use this directly";
|
|
|
|
default = {};
|
|
|
|
};
|
2022-12-01 20:58:35 +01:00
|
|
|
|
2023-03-01 22:57:19 +01:00
|
|
|
defaults = mkOption {
|
|
|
|
type = types.nullOr types.attrs;
|
|
|
|
default = null;
|
|
|
|
description = "Telescope default configuration";
|
|
|
|
};
|
2022-12-01 20:58:35 +01:00
|
|
|
};
|
2021-12-23 20:01:49 +01:00
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2023-02-20 11:42:13 +01:00
|
|
|
extraPackages = [pkgs.bat];
|
2021-12-23 20:01:49 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
extraPlugins = with pkgs.vimPlugins; [
|
2023-01-19 10:45:15 +00:00
|
|
|
cfg.package
|
2022-09-18 11:19:23 +01:00
|
|
|
plenary-nvim
|
|
|
|
popup-nvim
|
|
|
|
];
|
2021-12-23 20:01:49 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
extraConfigVim = mkIf (cfg.highlightTheme != null) ''
|
|
|
|
let $BAT_THEME = '${cfg.highlightTheme}'
|
|
|
|
'';
|
2021-12-23 20:01:49 +01:00
|
|
|
|
2023-09-15 14:35:13 +02:00
|
|
|
keymaps =
|
|
|
|
mapAttrsToList
|
|
|
|
(
|
|
|
|
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 {
|
|
|
|
mode = "n";
|
|
|
|
inherit key;
|
2023-07-17 13:18:08 +02:00
|
|
|
action = "require('telescope.builtin').${actionStr}";
|
|
|
|
lua = true;
|
2023-09-15 14:35:13 +02:00
|
|
|
|
|
|
|
options =
|
|
|
|
{
|
|
|
|
silent = cfg.keymapsSilent;
|
|
|
|
}
|
|
|
|
// actionProps;
|
2023-07-17 13:18:08 +02:00
|
|
|
}
|
2023-09-15 14:35:13 +02:00
|
|
|
)
|
2023-02-23 10:14:10 +01:00
|
|
|
cfg.keymaps;
|
|
|
|
|
2023-02-20 11:42:13 +01:00
|
|
|
extraConfigLua = let
|
|
|
|
options =
|
|
|
|
{
|
2023-01-22 03:32:08 +00:00
|
|
|
extensions = cfg.extensionConfig;
|
2023-05-22 15:45:47 +05:30
|
|
|
inherit (cfg) defaults;
|
2023-02-20 11:42:13 +01:00
|
|
|
}
|
|
|
|
// cfg.extraOptions;
|
|
|
|
in ''
|
|
|
|
do
|
|
|
|
local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions}
|
2021-12-23 20:01:49 +01:00
|
|
|
|
2023-02-20 11:42:13 +01:00
|
|
|
require('telescope').setup(${helpers.toLuaObject options})
|
2021-12-23 20:01:49 +01:00
|
|
|
|
2023-02-20 11:42:13 +01:00
|
|
|
for i, extension in ipairs(__telescopeExtensions) do
|
|
|
|
require('telescope').load_extension(extension)
|
2021-12-23 20:01:49 +01:00
|
|
|
end
|
2023-02-20 11:42:13 +01:00
|
|
|
end
|
|
|
|
'';
|
2021-12-23 20:01:49 +01:00
|
|
|
};
|
|
|
|
}
|