♻ refactor(fzf): Properly check that requirements exist

This commit is contained in:
punkfairie 2024-11-03 19:00:37 -08:00
parent 7d98dd2edd
commit a5b03ec1ad
Signed by: punkfairie
GPG key ID: 01823C057725C266

View file

@ -1,4 +1,12 @@
{ lib, config, ... }: { lib, config, ... }:
let
has-ripgrep = config.programs.ripgrep.enable;
has-fd = config.programs.fd.enable;
has-eza = config.programs.eza.enable;
has-bat = config.programs.bat.enable;
has-tmux = config.programs.tmux.enable;
has-delta = config.programs.git.delta.enable;
in
{ {
programs.fzf = { programs.fzf = {
enable = true; enable = true;
@ -15,23 +23,20 @@
"--preview-window='border-sharp'" "--preview-window='border-sharp'"
]; ];
# TODO: Check that rg is installed. defaultCommand = lib.mkIf has-ripgrep "rg --files --hidden --glob \"!.git\"";
defaultCommand = "rg --files --hidden --glob \"!.git\"";
# TODO: Check that fd is installed. changeDirWidgetCommand = lib.mkIf has-fd "fd --type d";
changeDirWidgetCommand = "fd --type d"; changeDirWidgetOptions = lib.mkIf has-eza [
changeDirWidgetOptions = lib.mkIf config.programs.eza.enable [
"--preview 'eza --all --color=always --sort=name --group-directories-first --level=3 {}'" "--preview 'eza --all --color=always --sort=name --group-directories-first --level=3 {}'"
]; ];
# TODO: Check that fd is installed. fileWidgetCommand = lib.mkIf has-fd "fd --type f";
fileWidgetCommand = "fd --type f"; fileWidgetOptions = lib.mkIf has-bat [
fileWidgetOptions = lib.mkIf config.programs.bat.enable [
"--preview 'bat {}'" "--preview 'bat {}'"
]; ];
tmux.enableShellIntegration = lib.mkIf config.programs.tmux.enable true; tmux.enableShellIntegration = lib.mkIf has-tmux true;
}; };
home.sessionVariables.fzf_diff_highlighter = "delta --paging=never --features=arctic-fox"; home.sessionVariables.fzf_diff_highlighter = lib.mkIf has-delta "delta --paging=never --features=arctic-fox";
} }