plugins/fff: use optional setup

This commit is contained in:
Austin Horstman 2026-04-21 17:15:57 -05:00
parent 3f710c0440
commit 92ec3b4c3e
2 changed files with 136 additions and 108 deletions

View file

@ -5,6 +5,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
description = "A fast fuzzy file finder.";
maintainers = [ lib.maintainers.GaetanLepage ];
callSetup = "optional";
settingsExample = {
base_path = lib.nixvim.nestedLiteralLua "vim.fn.getcwd()";

View file

@ -1,120 +1,147 @@
{ lib }:
{
empty = {
plugins.fff.enable = true;
};
empty =
{ config, ... }:
{
plugins.fff.enable = true;
example = {
plugins.fff = {
enable = true;
settings = {
base_path = lib.nixvim.mkRaw "vim.fn.getcwd()";
max_results = 100;
layout = {
height = 0.8;
width = 0.8;
preview_position = "right";
};
key_bindings = {
close = [
"<Esc>"
"<C-c>"
];
select_file = "<CR>";
open_split = "<C-s>";
open_vsplit = "<C-v>";
open_tab = "<C-t>";
move_up = [
"<Up>"
"<C-p>"
];
move_down = [
"<Down>"
"<C-n>"
];
};
};
assertions = [
{
assertion = !(lib.hasInfix "require('fff').setup(" config.content);
message = "Empty fff config should not emit a setup call.";
}
];
};
};
defaults = {
plugins.fff = {
enable = true;
example =
{ config, ... }:
{
plugins.fff = {
enable = true;
settings = {
base_path = lib.nixvim.mkRaw "vim.fn.getcwd()";
max_results = 100;
layout = {
height = 0.8;
width = 0.8;
preview_position = "right";
};
key_bindings = {
close = [
"<Esc>"
"<C-c>"
];
select_file = "<CR>";
open_split = "<C-s>";
open_vsplit = "<C-v>";
open_tab = "<C-t>";
move_up = [
"<Up>"
"<C-p>"
];
move_down = [
"<Down>"
"<C-n>"
];
};
settings = {
base_path = lib.nixvim.mkRaw "vim.fn.getcwd()";
prompt = "🪿 ";
title = "FFFiles";
max_results = 100;
max_threads = 4;
lazy_sync = true;
layout = {
height = 0.8;
width = 0.8;
prompt_position = "bottom";
preview_position = "right";
preview_size = 0.5;
};
preview = {
enabled = true;
max_size = lib.nixvim.mkRaw "10 * 1024 * 1024";
chunk_size = 8192;
binary_file_threshold = 1024;
imagemagick_info_format_str = "%m: %wx%h, %[colorspace], %q-bit";
line_numbers = false;
wrap_lines = false;
show_file_info = true;
filetypes = {
svg.wrap_lines = true;
markdown.wrap_lines = true;
text.wrap_lines = true;
};
assertions = [
{
assertion = lib.hasInfix "require('fff').setup(" config.content;
message = "Configured fff should still emit a setup call.";
}
];
};
defaults =
{ config, ... }:
{
plugins.fff = {
enable = true;
settings = {
base_path = lib.nixvim.mkRaw "vim.fn.getcwd()";
prompt = "🪿 ";
title = "FFFiles";
max_results = 100;
max_threads = 4;
lazy_sync = true;
layout = {
height = 0.8;
width = 0.8;
prompt_position = "bottom";
preview_position = "right";
preview_size = 0.5;
};
preview = {
enabled = true;
max_size = lib.nixvim.mkRaw "10 * 1024 * 1024";
chunk_size = 8192;
binary_file_threshold = 1024;
imagemagick_info_format_str = "%m: %wx%h, %[colorspace], %q-bit";
line_numbers = false;
wrap_lines = false;
show_file_info = true;
filetypes = {
svg.wrap_lines = true;
markdown.wrap_lines = true;
text.wrap_lines = true;
};
};
keymaps = {
close = "<Esc>";
select = "<CR>";
select_split = "<C-s>";
select_vsplit = "<C-v>";
select_tab = "<C-t>";
move_up = [
"<Up>"
"<C-p>"
];
move_down = [
"<Down>"
"<C-n>"
];
preview_scroll_up = "<C-u>";
preview_scroll_down = "<C-d>";
toggle_debug = "<F2>";
};
hl = {
border = "FloatBorder";
normal = "Normal";
cursor = "CursorLine";
matched = "IncSearch";
title = "Title";
prompt = "Question";
active_file = "Visual";
frecency = "Number";
debug = "Comment";
};
frecency = {
enabled = true;
db_path = lib.nixvim.mkRaw "vim.fn.stdpath('cache') .. '/fff_nvim'";
};
debug = {
enabled = false;
show_scores = false;
};
logging = {
enabled = true;
log_file = lib.nixvim.mkRaw "vim.fn.stdpath('log') .. '/fff.log'";
log_level = "info";
};
};
keymaps = {
close = "<Esc>";
select = "<CR>";
select_split = "<C-s>";
select_vsplit = "<C-v>";
select_tab = "<C-t>";
move_up = [
"<Up>"
"<C-p>"
];
move_down = [
"<Down>"
"<C-n>"
];
preview_scroll_up = "<C-u>";
preview_scroll_down = "<C-d>";
toggle_debug = "<F2>";
};
hl = {
border = "FloatBorder";
normal = "Normal";
cursor = "CursorLine";
matched = "IncSearch";
title = "Title";
prompt = "Question";
active_file = "Visual";
frecency = "Number";
debug = "Comment";
};
frecency = {
enabled = true;
db_path = lib.nixvim.mkRaw "vim.fn.stdpath('cache') .. '/fff_nvim'";
};
debug = {
enabled = false;
show_scores = false;
};
logging = {
enabled = true;
log_file = lib.nixvim.mkRaw "vim.fn.stdpath('log') .. '/fff.log'";
log_level = "info";
};
};
assertions = [
{
assertion = lib.hasInfix "require('fff').setup(" config.content;
message = "Configured fff defaults should emit a setup call.";
}
];
};
};
}