2023-01-25 00:03:26 +00:00
|
|
|
{ pkgs, config, lib, ... }:
|
2021-12-23 20:01:49 +01:00
|
|
|
with lib;
|
|
|
|
let
|
2022-09-18 11:19:23 +01:00
|
|
|
cfg = config.plugins.telescope;
|
2023-01-25 00:03:26 +00:00
|
|
|
helpers = (import ../helpers.nix { inherit lib; });
|
2021-12-23 20:01:49 +01:00
|
|
|
in
|
|
|
|
{
|
2021-12-23 20:12:37 +01:00
|
|
|
imports = [
|
|
|
|
./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
|
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!
|
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
options.plugins.telescope = {
|
2023-01-22 03:32:08 +00:00
|
|
|
enable = mkEnableOption "telescope.nvim";
|
2021-12-23 20:01:49 +01:00
|
|
|
|
2023-01-25 00:03:26 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.vimPlugins.telescope-nvim;
|
|
|
|
description = "Plugin to use for telescope.nvim";
|
|
|
|
};
|
2023-01-19 10:45:15 +00:00
|
|
|
|
2021-12-23 20:01:49 +01:00
|
|
|
highlightTheme = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
description = "The colorscheme to use for syntax highlighting";
|
2022-09-18 11:19:23 +01:00
|
|
|
default = config.colorscheme;
|
2021-12-23 20:01:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enabledExtensions = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = "A list of enabled extensions. Don't use this directly";
|
2022-08-27 01:47:52 +01:00
|
|
|
default = [ ];
|
2021-12-23 20:01:49 +01:00
|
|
|
};
|
2021-12-23 21:29:17 +01:00
|
|
|
|
|
|
|
extensionConfig = mkOption {
|
|
|
|
type = types.attrsOf types.anything;
|
|
|
|
description = "Configuration for the extensions. Don't use this directly";
|
2022-08-27 01:47:52 +01:00
|
|
|
default = { };
|
2021-12-23 21:29:17 +01:00
|
|
|
};
|
2022-12-01 20:58:35 +01:00
|
|
|
|
|
|
|
defaults = mkOption {
|
|
|
|
type = types.nullOr types.attrs;
|
|
|
|
default = null;
|
|
|
|
description = "Telescope default configuration";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraOptions = mkOption {
|
|
|
|
type = types.attrs;
|
|
|
|
default = { };
|
|
|
|
description = "An attribute set, that lets you set extra options or override options set by nixvim";
|
|
|
|
};
|
2021-12-23 20:01:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2022-09-18 11:19:23 +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-01-22 03:32:08 +00:00
|
|
|
extraConfigLua =
|
|
|
|
let
|
|
|
|
options = {
|
|
|
|
extensions = cfg.extensionConfig;
|
|
|
|
defaults = cfg.defaults;
|
|
|
|
} // cfg.extraOptions;
|
|
|
|
in
|
|
|
|
''
|
|
|
|
do
|
|
|
|
local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions}
|
2021-12-23 20:01:49 +01:00
|
|
|
|
2023-01-22 03:32:08 +00:00
|
|
|
require('telescope').setup(${helpers.toLuaObject options})
|
2021-12-23 20:01:49 +01:00
|
|
|
|
2023-01-22 03:32:08 +00:00
|
|
|
for i, extension in ipairs(__telescopeExtensions) do
|
|
|
|
require('telescope').load_extension(extension)
|
|
|
|
end
|
2021-12-23 20:01:49 +01:00
|
|
|
end
|
2023-01-22 03:32:08 +00:00
|
|
|
'';
|
2021-12-23 20:01:49 +01:00
|
|
|
};
|
|
|
|
}
|