mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-31 16:14:46 +02:00
plugins/fzf-lua: init
This commit is contained in:
parent
375453feff
commit
5a744a7006
3 changed files with 200 additions and 0 deletions
|
@ -123,6 +123,7 @@
|
||||||
./utils/endwise.nix
|
./utils/endwise.nix
|
||||||
./utils/flash.nix
|
./utils/flash.nix
|
||||||
./utils/floaterm.nix
|
./utils/floaterm.nix
|
||||||
|
./utils/fzf-lua.nix
|
||||||
./utils/goyo.nix
|
./utils/goyo.nix
|
||||||
./utils/hardtime.nix
|
./utils/hardtime.nix
|
||||||
./utils/harpoon.nix
|
./utils/harpoon.nix
|
||||||
|
|
142
plugins/utils/fzf-lua.nix
Normal file
142
plugins/utils/fzf-lua.nix
Normal file
|
@ -0,0 +1,142 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
helpers,
|
||||||
|
config,
|
||||||
|
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
|
||||||
|
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||||
|
name = "fzf-lua";
|
||||||
|
defaultPackage = pkgs.vimPlugins.fzf-lua;
|
||||||
|
|
||||||
|
extraPackages = [pkgs.fzf];
|
||||||
|
|
||||||
|
maintainers = [maintainers.GaetanLepage];
|
||||||
|
|
||||||
|
inherit
|
||||||
|
settingsOptions
|
||||||
|
settingsExample
|
||||||
|
;
|
||||||
|
|
||||||
|
extraOptions = {
|
||||||
|
fzfPackage = mkOption {
|
||||||
|
type = with types; nullOr package;
|
||||||
|
default = pkgs.fzf;
|
||||||
|
description = ''
|
||||||
|
The fzf package to use.
|
||||||
|
Set to `null` to not install any package.
|
||||||
|
'';
|
||||||
|
example = pkgs.skim;
|
||||||
|
};
|
||||||
|
|
||||||
|
iconsEnabled = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
description = "Toggle icon support. Installs nvim-web-devicons.";
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
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";
|
||||||
|
};
|
||||||
|
settings = helpers.mkSettingsOption {
|
||||||
|
options = settingsOptions;
|
||||||
|
description = "`fzf-lua` settings for this command.";
|
||||||
|
example = settingsExample;
|
||||||
|
};
|
||||||
|
mode = helpers.keymaps.mkModeOption "n";
|
||||||
|
options = helpers.keymaps.mapConfigOptions;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
));
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Fzf-Lua Git Files";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
extraConfig = cfg: {
|
||||||
|
extraPlugins =
|
||||||
|
optional
|
||||||
|
cfg.iconsEnabled
|
||||||
|
pkgs.vimPlugins.nvim-web-devicons;
|
||||||
|
|
||||||
|
extraPackages = optional (cfg.fzfPackage != null) cfg.fzfPackage;
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
}
|
57
tests/test-sources/plugins/utils/fzf-lua.nix
Normal file
57
tests/test-sources/plugins/utils/fzf-lua.nix
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
{
|
||||||
|
empty = {
|
||||||
|
plugins.fzf-lua.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
example = {
|
||||||
|
plugins.fzf-lua = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
profile = "telescope";
|
||||||
|
keymaps = {
|
||||||
|
"<Leader>ff" = {
|
||||||
|
action = "files";
|
||||||
|
settings = {
|
||||||
|
cwd = "~/Github";
|
||||||
|
winopts = {
|
||||||
|
height = 0.10;
|
||||||
|
width = 0.50;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
options.silent = true;
|
||||||
|
};
|
||||||
|
"<Leader>fg" = "live_grep";
|
||||||
|
"<C-x><C-f>" = {
|
||||||
|
mode = "i";
|
||||||
|
action = "complete_file";
|
||||||
|
settings = {
|
||||||
|
cmd = "rg --files";
|
||||||
|
winopts.preview.hidden = "nohidden";
|
||||||
|
};
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Fuzzy complete file";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
settings = {
|
||||||
|
grep = {
|
||||||
|
prompt = "Grep ";
|
||||||
|
};
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue