2023-02-20 11:42:13 +01:00
|
|
|
{
|
|
|
|
lib,
|
2023-11-06 15:04:08 +01:00
|
|
|
helpers,
|
|
|
|
config,
|
|
|
|
pkgs,
|
2023-02-20 11:42:13 +01:00
|
|
|
...
|
2023-01-25 19:46:49 +01:00
|
|
|
}:
|
2024-03-24 13:49:23 +01:00
|
|
|
with lib;
|
|
|
|
# TODO:add support for additional filetypes. This requires autocommands!
|
|
|
|
helpers.neovim-plugin.mkNeovimPlugin config {
|
|
|
|
name = "telescope";
|
|
|
|
originalName = "telescope.nvim";
|
|
|
|
defaultPackage = pkgs.vimPlugins.telescope-nvim;
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2024-03-24 13:49:23 +01:00
|
|
|
maintainers = [ maintainers.GaetanLepage ];
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2024-03-24 13:49:23 +01:00
|
|
|
extraPackages = [ pkgs.bat ];
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2024-03-24 13:49:23 +01:00
|
|
|
# TODO introduced 2024-03-24: remove 2024-05-24
|
|
|
|
deprecateExtraOptions = true;
|
|
|
|
optionsRenamedToSettings = [ "defaults" ];
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2024-05-24 23:55:24 +01:00
|
|
|
imports = [
|
|
|
|
./extensions
|
|
|
|
|
|
|
|
# TODO introduced 2024-05-24: remove 2024-08-24
|
|
|
|
(mkRemovedOptionModule
|
|
|
|
[
|
|
|
|
"plugins"
|
|
|
|
"telescope"
|
|
|
|
"keymapsSilent"
|
|
|
|
]
|
|
|
|
"This option no longer has any effect now that the `plugin.telescope.keymaps` implementation uses `<cmd>`."
|
|
|
|
)
|
|
|
|
];
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2024-03-24 13:49:23 +01:00
|
|
|
extraOptions = {
|
2023-03-01 22:57:19 +01:00
|
|
|
keymaps = mkOption {
|
2024-03-24 13:49:23 +01:00
|
|
|
type =
|
|
|
|
with types;
|
|
|
|
attrsOf (
|
|
|
|
either str (submodule {
|
|
|
|
options = {
|
|
|
|
action = mkOption { type = types.str; };
|
|
|
|
mode = helpers.keymaps.mkModeOption "n";
|
|
|
|
options = helpers.keymaps.mapConfigOptions;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
);
|
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";
|
2024-03-24 13:49:23 +01:00
|
|
|
options.desc = "Telescope Git Files";
|
2023-03-01 22:57:19 +01:00
|
|
|
};
|
2023-02-23 10:14:10 +01:00
|
|
|
};
|
2022-12-01 20:58:35 +01:00
|
|
|
};
|
2021-12-23 20:01:49 +01:00
|
|
|
|
2024-03-24 13:49:23 +01:00
|
|
|
highlightTheme = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
description = "The colorscheme to use for syntax highlighting";
|
|
|
|
default = config.colorscheme;
|
|
|
|
};
|
|
|
|
|
2023-03-01 22:57:19 +01:00
|
|
|
enabledExtensions = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
2024-05-24 21:02:08 +01:00
|
|
|
description = ''
|
|
|
|
A list of enabled extensions.
|
|
|
|
|
|
|
|
You should only use this option directly if the Telescope extension you wish to enable is not natively supported
|
|
|
|
by nixvim.
|
|
|
|
|
|
|
|
Most extensions are available as `plugins.telescope.extensions.<name>.enable`, although some plugins that do
|
|
|
|
more than just provide Telescope extensions may use `plugins.<name>.enableTelescope` instead.
|
|
|
|
|
|
|
|
If you add an extension to this list manually, it is your responsibility to ensure the relevant plugin is also
|
|
|
|
added to `extraPackages`.
|
|
|
|
'';
|
2024-05-05 19:39:35 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-03-24 13:49:23 +01:00
|
|
|
callSetup = false;
|
|
|
|
extraConfig = cfg: {
|
|
|
|
extraConfigVim = mkIf (cfg.highlightTheme != null) ''
|
|
|
|
let $BAT_THEME = '${cfg.highlightTheme}'
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
|
|
|
|
2024-03-24 13:49:23 +01:00
|
|
|
keymaps = mapAttrsToList (
|
|
|
|
key: mapping:
|
2024-05-05 19:39:35 +02:00
|
|
|
let
|
2024-03-24 13:49:23 +01:00
|
|
|
actionStr = if isString mapping then mapping else mapping.action;
|
2024-05-05 19:39:35 +02:00
|
|
|
in
|
|
|
|
{
|
2024-03-24 13:49:23 +01:00
|
|
|
mode = mapping.mode or "n";
|
|
|
|
inherit key;
|
2024-05-20 22:00:56 +01:00
|
|
|
action = "<cmd>Telescope ${actionStr}<cr>";
|
2024-05-24 23:55:24 +01:00
|
|
|
options = mapping.options or { };
|
2024-05-05 19:39:35 +02:00
|
|
|
}
|
2024-03-24 13:49:23 +01:00
|
|
|
) cfg.keymaps;
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2024-03-24 13:49:23 +01:00
|
|
|
extraConfigLua = ''
|
|
|
|
require('telescope').setup(${helpers.toLuaObject cfg.settings})
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-02-20 11:42:13 +01:00
|
|
|
local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions}
|
|
|
|
for i, extension in ipairs(__telescopeExtensions) do
|
|
|
|
require('telescope').load_extension(extension)
|
2024-05-05 19:39:35 +02:00
|
|
|
end
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-03-24 13:49:23 +01:00
|
|
|
settingsOptions = {
|
|
|
|
defaults = helpers.mkNullOrOption (with types; attrsOf anything) ''
|
|
|
|
Default configuration for telescope.
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
|
|
|
|
2024-03-24 13:49:23 +01:00
|
|
|
pickers = helpers.mkNullOrOption (with types; attrsOf anything) ''
|
|
|
|
Default configuration for builtin pickers.
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
|
|
|
|
2024-03-24 13:49:23 +01:00
|
|
|
extensions = mkOption {
|
|
|
|
type = with types; attrsOf anything;
|
|
|
|
default = { };
|
|
|
|
# NOTE: We hide this option from the documentation as users should use the top-level
|
|
|
|
# `extensions.*` options.
|
|
|
|
# They can still directly change this `settings.adapters` option.
|
|
|
|
# In this case, they are responsible for explicitly installing the manually added extensions.
|
|
|
|
visible = false;
|
2024-05-05 19:39:35 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-03-24 13:49:23 +01:00
|
|
|
settingsExample = {
|
|
|
|
defaults = {
|
|
|
|
file_ignore_patterns = [
|
2024-05-05 19:39:35 +02:00
|
|
|
"^.git/"
|
2024-03-24 13:49:23 +01:00
|
|
|
"^.mypy_cache/"
|
|
|
|
"^__pycache__/"
|
|
|
|
"^output/"
|
|
|
|
"^data/"
|
|
|
|
"%.ipynb"
|
|
|
|
];
|
|
|
|
set_env.COLORTERM = "truecolor";
|
|
|
|
sorting_strategy = "ascending";
|
|
|
|
selection_caret = "> ";
|
|
|
|
layout_config.prompt_position = "top";
|
|
|
|
mappings = {
|
|
|
|
i = {
|
|
|
|
"<A-j>".__raw = "require('telescope.actions').move_selection_next";
|
|
|
|
"<A-k>".__raw = "require('telescope.actions').move_selection_previous";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-05-05 19:39:35 +02:00
|
|
|
};
|
2024-03-24 13:49:23 +01:00
|
|
|
}
|