2023-12-08 16:34:34 +07:00
|
|
|
|
{
|
|
|
|
|
lib,
|
|
|
|
|
helpers,
|
2024-08-29 09:41:26 -05:00
|
|
|
|
options,
|
2023-12-08 16:34:34 +07:00
|
|
|
|
pkgs,
|
|
|
|
|
...
|
|
|
|
|
}:
|
|
|
|
|
with lib;
|
|
|
|
|
let
|
|
|
|
|
settingsOptions = {
|
|
|
|
|
fzf_bin = helpers.mkNullOrStr ''
|
|
|
|
|
The path to the `fzf` binary to use.
|
|
|
|
|
|
|
|
|
|
Example: `"skim"`
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
settingsExample = {
|
|
|
|
|
winopts = {
|
|
|
|
|
height = 0.4;
|
|
|
|
|
width = 0.93;
|
|
|
|
|
row = 0.99;
|
|
|
|
|
col = 0.3;
|
|
|
|
|
};
|
|
|
|
|
files = {
|
|
|
|
|
find_opts.__raw = "[[-type f -not -path '*.git/objects*' -not -path '*.env*']]";
|
|
|
|
|
prompt = "Files❯ ";
|
|
|
|
|
multiprocess = true;
|
|
|
|
|
file_icons = true;
|
|
|
|
|
color_icons = true;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
in
|
2024-09-01 12:52:28 +01:00
|
|
|
|
helpers.neovim-plugin.mkNeovimPlugin {
|
2023-12-08 16:34:34 +07:00
|
|
|
|
name = "fzf-lua";
|
|
|
|
|
defaultPackage = pkgs.vimPlugins.fzf-lua;
|
|
|
|
|
|
|
|
|
|
extraPackages = [ pkgs.fzf ];
|
|
|
|
|
|
|
|
|
|
maintainers = [ maintainers.GaetanLepage ];
|
|
|
|
|
|
|
|
|
|
inherit settingsOptions settingsExample;
|
|
|
|
|
|
|
|
|
|
extraOptions = {
|
2024-05-17 14:39:55 +02:00
|
|
|
|
fzfPackage = helpers.mkPackageOption {
|
|
|
|
|
name = "fzf";
|
2023-12-08 16:34:34 +07:00
|
|
|
|
default = pkgs.fzf;
|
|
|
|
|
example = pkgs.skim;
|
|
|
|
|
};
|
|
|
|
|
|
2024-08-29 09:41:26 -05:00
|
|
|
|
# TODO: deprecated 2024-08-29 remove after 24.11
|
2023-12-08 16:34:34 +07:00
|
|
|
|
iconsEnabled = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
description = "Toggle icon support. Installs nvim-web-devicons.";
|
2024-08-29 09:41:26 -05:00
|
|
|
|
visible = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
iconsPackage = helpers.mkPackageOption {
|
|
|
|
|
name = "nvim-web-devicons";
|
|
|
|
|
default = pkgs.vimPlugins.nvim-web-devicons;
|
2023-12-08 16:34:34 +07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
profile = helpers.defaultNullOpts.mkEnumFirstDefault [
|
|
|
|
|
"default"
|
|
|
|
|
"fzf-native"
|
|
|
|
|
"fzf-tmux"
|
|
|
|
|
"fzf-vim"
|
|
|
|
|
"max-perf"
|
|
|
|
|
"telescope"
|
|
|
|
|
"skim"
|
|
|
|
|
] "Preconfigured profile to use";
|
|
|
|
|
|
|
|
|
|
keymaps = mkOption {
|
|
|
|
|
type =
|
|
|
|
|
with types;
|
|
|
|
|
attrsOf (
|
|
|
|
|
either str (submodule {
|
|
|
|
|
options = {
|
|
|
|
|
action = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
description = "The `fzf-lua` action to run";
|
|
|
|
|
example = "git_files";
|
2024-05-05 19:39:35 +02:00
|
|
|
|
};
|
2023-12-08 16:34:34 +07:00
|
|
|
|
settings = helpers.mkSettingsOption {
|
|
|
|
|
options = settingsOptions;
|
|
|
|
|
description = "`fzf-lua` settings for this command.";
|
|
|
|
|
example = settingsExample;
|
2024-05-05 19:39:35 +02:00
|
|
|
|
};
|
2023-12-08 16:34:34 +07:00
|
|
|
|
mode = helpers.keymaps.mkModeOption "n";
|
|
|
|
|
options = helpers.keymaps.mapConfigOptions;
|
|
|
|
|
};
|
2024-05-05 19:39:35 +02:00
|
|
|
|
})
|
|
|
|
|
);
|
2023-12-08 16:34:34 +07:00
|
|
|
|
description = "Keymaps for Fzf-Lua.";
|
|
|
|
|
default = { };
|
|
|
|
|
example = {
|
|
|
|
|
"<leader>fg" = "live_grep";
|
|
|
|
|
"<C-p>" = {
|
|
|
|
|
action = "git_files";
|
|
|
|
|
settings = {
|
|
|
|
|
previewers.cat.cmd = "${pkgs.coreutils}/bin/cat";
|
|
|
|
|
winopts.height = 0.5;
|
2024-05-05 19:39:35 +02:00
|
|
|
|
};
|
2023-12-08 16:34:34 +07:00
|
|
|
|
options = {
|
|
|
|
|
silent = true;
|
|
|
|
|
desc = "Fzf-Lua Git Files";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
2024-05-05 19:39:35 +02:00
|
|
|
|
};
|
2023-12-08 16:34:34 +07:00
|
|
|
|
|
2024-08-29 09:41:26 -05:00
|
|
|
|
extraConfig =
|
|
|
|
|
cfg:
|
|
|
|
|
let
|
|
|
|
|
opt = options.plugins.fzf-lua;
|
|
|
|
|
in
|
|
|
|
|
{
|
|
|
|
|
# TODO: deprecated 2024-08-29 remove after 24.11
|
|
|
|
|
warnings = lib.mkIf opt.iconsEnabled.isDefined [
|
|
|
|
|
''
|
|
|
|
|
nixvim (plugins.fzf-lua):
|
|
|
|
|
The option definition `plugins.fzf-lua.iconsEnabled' in ${showFiles opt.iconsEnabled.files} has been deprecated; please remove it.
|
|
|
|
|
You should use `plugins.fzf-lua.iconsPackage' instead.
|
|
|
|
|
''
|
|
|
|
|
];
|
2023-12-08 16:34:34 +07:00
|
|
|
|
|
2024-08-29 09:41:26 -05:00
|
|
|
|
extraPlugins = lib.mkIf (
|
2024-08-29 15:53:33 -05:00
|
|
|
|
cfg.iconsPackage != null && (opt.iconsEnabled.isDefined -> cfg.iconsEnabled)
|
2024-08-29 09:41:26 -05:00
|
|
|
|
) [ cfg.iconsPackage ];
|
2023-12-08 16:34:34 +07:00
|
|
|
|
|
2024-08-29 09:41:26 -05:00
|
|
|
|
extraPackages = [ cfg.fzfPackage ];
|
2023-12-08 16:34:34 +07:00
|
|
|
|
|
2024-08-29 09:41:26 -05:00
|
|
|
|
plugins.fzf-lua.settings.__unkeyed_profile = cfg.profile;
|
|
|
|
|
|
|
|
|
|
keymaps = mapAttrsToList (
|
|
|
|
|
key: mapping:
|
|
|
|
|
let
|
|
|
|
|
actionStr =
|
|
|
|
|
if isString mapping then
|
|
|
|
|
"${mapping}()"
|
|
|
|
|
else
|
|
|
|
|
"${mapping.action}(${helpers.toLuaObject mapping.settings})";
|
|
|
|
|
in
|
|
|
|
|
{
|
|
|
|
|
inherit key;
|
|
|
|
|
mode = mapping.mode or "n";
|
|
|
|
|
action.__raw = "function() require('fzf-lua').${actionStr} end";
|
|
|
|
|
options = mapping.options or { };
|
|
|
|
|
}
|
|
|
|
|
) cfg.keymaps;
|
|
|
|
|
};
|
2023-12-08 16:34:34 +07:00
|
|
|
|
}
|