mirror of
https://github.com/nix-community/nixvim.git
synced 2025-08-10 04:46:04 +02:00
plugins/telescope: switch to mkNeovimPlugin
This commit is contained in:
parent
07de1fe92e
commit
3c0951ebc8
9 changed files with 133 additions and 97 deletions
|
@ -5,9 +5,21 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib;
|
||||||
cfg = config.plugins.telescope;
|
# TODO:add support for additional filetypes. This requires autocommands!
|
||||||
in {
|
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||||
|
name = "telescope";
|
||||||
|
originalName = "telescope.nvim";
|
||||||
|
defaultPackage = pkgs.vimPlugins.telescope-nvim;
|
||||||
|
|
||||||
|
maintainers = [maintainers.GaetanLepage];
|
||||||
|
|
||||||
|
extraPackages = [pkgs.bat];
|
||||||
|
|
||||||
|
# TODO introduced 2024-03-24: remove 2024-05-24
|
||||||
|
deprecateExtraOptions = true;
|
||||||
|
optionsRenamedToSettings = ["defaults"];
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
./file-browser.nix
|
./file-browser.nix
|
||||||
./frecency.nix
|
./frecency.nix
|
||||||
|
@ -18,24 +30,30 @@ in {
|
||||||
./undo.nix
|
./undo.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
# TODO:add support for additional filetypes. This requires autocommands!
|
extraOptions = {
|
||||||
|
|
||||||
options.plugins.telescope =
|
|
||||||
helpers.neovim-plugin.extraOptionsOptions
|
|
||||||
// {
|
|
||||||
enable = mkEnableOption "telescope.nvim";
|
|
||||||
|
|
||||||
package = helpers.mkPackageOption "telescope.nvim" pkgs.vimPlugins.telescope-nvim;
|
|
||||||
|
|
||||||
keymaps = mkOption {
|
keymaps = mkOption {
|
||||||
type = with types; attrsOf (either str attrs);
|
type = with types;
|
||||||
|
attrsOf
|
||||||
|
(
|
||||||
|
either
|
||||||
|
str
|
||||||
|
(submodule {
|
||||||
|
options = {
|
||||||
|
action = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
};
|
||||||
|
mode = helpers.keymaps.mkModeOption "n";
|
||||||
|
options = helpers.keymaps.mapConfigOptions;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
description = "Keymaps for telescope.";
|
description = "Keymaps for telescope.";
|
||||||
default = {};
|
default = {};
|
||||||
example = {
|
example = {
|
||||||
"<leader>fg" = "live_grep";
|
"<leader>fg" = "live_grep";
|
||||||
"<C-p>" = {
|
"<C-p>" = {
|
||||||
action = "git_files";
|
action = "git_files";
|
||||||
desc = "Telescope Git Files";
|
options.desc = "Telescope Git Files";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -59,31 +77,10 @@ in {
|
||||||
internal = true;
|
internal = true;
|
||||||
visible = false;
|
visible = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
extensionConfig = mkOption {
|
|
||||||
type = types.attrsOf types.anything;
|
|
||||||
description = "Configuration for the extensions. Don't use this directly";
|
|
||||||
default = {};
|
|
||||||
internal = true;
|
|
||||||
visible = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
defaults = mkOption {
|
callSetup = false;
|
||||||
type = types.nullOr types.attrs;
|
extraConfig = cfg: {
|
||||||
default = null;
|
|
||||||
description = "Telescope default configuration";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
|
||||||
extraPackages = [pkgs.bat];
|
|
||||||
|
|
||||||
extraPlugins = with pkgs.vimPlugins; [
|
|
||||||
cfg.package
|
|
||||||
plenary-nvim
|
|
||||||
popup-nvim
|
|
||||||
];
|
|
||||||
|
|
||||||
extraConfigVim = mkIf (cfg.highlightTheme != null) ''
|
extraConfigVim = mkIf (cfg.highlightTheme != null) ''
|
||||||
let $BAT_THEME = '${cfg.highlightTheme}'
|
let $BAT_THEME = '${cfg.highlightTheme}'
|
||||||
'';
|
'';
|
||||||
|
@ -91,17 +88,13 @@ in {
|
||||||
keymaps =
|
keymaps =
|
||||||
mapAttrsToList
|
mapAttrsToList
|
||||||
(
|
(
|
||||||
key: action: let
|
key: mapping: let
|
||||||
actionStr =
|
actionStr =
|
||||||
if isString action
|
if isString mapping
|
||||||
then action
|
then mapping
|
||||||
else action.action;
|
else mapping.action;
|
||||||
actionProps =
|
|
||||||
if isString action
|
|
||||||
then {}
|
|
||||||
else filterAttrs (n: v: n != "action") action;
|
|
||||||
in {
|
in {
|
||||||
mode = "n";
|
mode = mapping.mode or "n";
|
||||||
inherit key;
|
inherit key;
|
||||||
action.__raw = "require('telescope.builtin').${actionStr}";
|
action.__raw = "require('telescope.builtin').${actionStr}";
|
||||||
|
|
||||||
|
@ -109,28 +102,61 @@ in {
|
||||||
{
|
{
|
||||||
silent = cfg.keymapsSilent;
|
silent = cfg.keymapsSilent;
|
||||||
}
|
}
|
||||||
// actionProps;
|
// (mapping.options or {});
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
cfg.keymaps;
|
cfg.keymaps;
|
||||||
|
|
||||||
extraConfigLua = let
|
extraConfigLua = ''
|
||||||
options =
|
require('telescope').setup(${helpers.toLuaObject cfg.settings})
|
||||||
{
|
|
||||||
extensions = cfg.extensionConfig;
|
|
||||||
inherit (cfg) defaults;
|
|
||||||
}
|
|
||||||
// cfg.extraOptions;
|
|
||||||
in ''
|
|
||||||
do
|
|
||||||
local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions}
|
local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions}
|
||||||
|
|
||||||
require('telescope').setup(${helpers.toLuaObject options})
|
|
||||||
|
|
||||||
for i, extension in ipairs(__telescopeExtensions) do
|
for i, extension in ipairs(__telescopeExtensions) do
|
||||||
require('telescope').load_extension(extension)
|
require('telescope').load_extension(extension)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
settingsOptions = {
|
||||||
|
defaults = helpers.mkNullOrOption (with types; attrsOf anything) ''
|
||||||
|
Default configuration for telescope.
|
||||||
|
'';
|
||||||
|
|
||||||
|
pickers = helpers.mkNullOrOption (with types; attrsOf anything) ''
|
||||||
|
Default configuration for builtin pickers.
|
||||||
|
'';
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
settingsExample = {
|
||||||
|
defaults = {
|
||||||
|
file_ignore_patterns = [
|
||||||
|
"^.git/"
|
||||||
|
"^.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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -210,7 +210,7 @@ in {
|
||||||
|
|
||||||
plugins.telescope = {
|
plugins.telescope = {
|
||||||
enabledExtensions = ["file_browser"];
|
enabledExtensions = ["file_browser"];
|
||||||
extensionConfig."file_browser" = options;
|
settings.extensions.file_browser = options;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,9 @@ in {
|
||||||
sqlite-lua
|
sqlite-lua
|
||||||
];
|
];
|
||||||
|
|
||||||
plugins.telescope.enabledExtensions = ["frecency"];
|
plugins.telescope = {
|
||||||
plugins.telescope.extensionConfig."frecency" = configuration;
|
enabledExtensions = ["frecency"];
|
||||||
|
settings.extensions.frecency = configuration;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,9 @@ in {
|
||||||
mkIf cfg.enable {
|
mkIf cfg.enable {
|
||||||
extraPlugins = [cfg.package];
|
extraPlugins = [cfg.package];
|
||||||
|
|
||||||
plugins.telescope.enabledExtensions = ["fzf"];
|
plugins.telescope = {
|
||||||
plugins.telescope.extensionConfig."fzf" = configuration;
|
enabledExtensions = ["fzf"];
|
||||||
|
settings.extensions.fzf = configuration;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,9 @@ in {
|
||||||
mkIf cfg.enable {
|
mkIf cfg.enable {
|
||||||
extraPlugins = [pkgs.vimPlugins.telescope-fzy-native-nvim];
|
extraPlugins = [pkgs.vimPlugins.telescope-fzy-native-nvim];
|
||||||
|
|
||||||
plugins.telescope.enabledExtensions = ["fzy_native"];
|
plugins.telescope = {
|
||||||
plugins.telescope.extensionConfig."fzy_native" = configuration;
|
enabledExtensions = ["fzy_native"];
|
||||||
|
settings.extensions.fzy_native = options;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,9 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
plugins.telescope.enabledExtensions = ["media_files"];
|
plugins.telescope = {
|
||||||
|
enabledExtensions = ["media_files"];
|
||||||
|
};
|
||||||
|
|
||||||
extraPlugins = with pkgs.vimPlugins; [
|
extraPlugins = with pkgs.vimPlugins; [
|
||||||
popup-nvim
|
popup-nvim
|
||||||
|
|
|
@ -26,7 +26,7 @@ in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
plugins.telescope = {
|
plugins.telescope = {
|
||||||
enabledExtensions = ["ui-select"];
|
enabledExtensions = ["ui-select"];
|
||||||
extensionConfig."ui-select" = cfg.settings;
|
settings.extensions.ui-select = cfg.settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
extraPlugins = [cfg.package];
|
extraPlugins = [cfg.package];
|
||||||
|
|
|
@ -107,7 +107,9 @@ in {
|
||||||
{
|
{
|
||||||
extraPlugins = [cfg.package];
|
extraPlugins = [cfg.package];
|
||||||
|
|
||||||
plugins.telescope.enabledExtensions = ["undo"];
|
plugins.telescope = {
|
||||||
plugins.telescope.extensionConfig."undo" = configuration;
|
enabledExtensions = ["undo"];
|
||||||
|
settings.extensions.undo = configuration;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
"<leader>fg" = "live_grep";
|
"<leader>fg" = "live_grep";
|
||||||
"<C-p>" = {
|
"<C-p>" = {
|
||||||
action = "git_files";
|
action = "git_files";
|
||||||
desc = "Telescope Git Files";
|
options.desc = "Telescope Git Files";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
keymapsSilent = true;
|
keymapsSilent = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue