From 45ce61172ed4a200cdfcafc520e1dc312d52967c Mon Sep 17 00:00:00 2001 From: punkfairie Date: Sat, 16 Nov 2024 15:10:06 -0800 Subject: [PATCH] feat(home): Fzf --- homes/x86_64-linux/marley@nyx/default.nix | 1 + modules/home/programs/fzf/default.nix | 68 +++++++++++++++++++++++ old/home/programs/fzf.nix | 44 --------------- 3 files changed, 69 insertions(+), 44 deletions(-) create mode 100644 modules/home/programs/fzf/default.nix delete mode 100644 old/home/programs/fzf.nix diff --git a/homes/x86_64-linux/marley@nyx/default.nix b/homes/x86_64-linux/marley@nyx/default.nix index 98f65d0..6ce069e 100644 --- a/homes/x86_64-linux/marley@nyx/default.nix +++ b/homes/x86_64-linux/marley@nyx/default.nix @@ -23,6 +23,7 @@ in eza = enabled; figlet = enabled; fish = enabled; + fzf = enabled; journalctl = enabled; neo = enabled; systemctl = enabled; diff --git a/modules/home/programs/fzf/default.nix b/modules/home/programs/fzf/default.nix new file mode 100644 index 0000000..7ec137e --- /dev/null +++ b/modules/home/programs/fzf/default.nix @@ -0,0 +1,68 @@ +{ + lib, + config, + namespace, + ... +}: +let + inherit (lib) mkIf enabled; + inherit (lib.${namespace}) mkEnableModule; + + cfg = config.${namespace}.programs.fzf; + inherit (config.${namespace}) theme; + + 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; + has-difft = config.programs.git.difftastic.enable; +in +{ + options = mkEnableModule "programs.fzf"; + + config = mkIf cfg.enable { + programs.fzf = { + enable = true; + + "${theme.colors.base}" = enabled; + + defaultOptions = [ + "--margin=10%,5%" + "--border=sharp" + "--pointer= " + "--marker= " + "--prompt= " + "--preview-label-pos='bottom'" + "--preview-window='border-sharp'" + ]; + + defaultCommand = lib.mkIf has-ripgrep "rg --files --hidden --glob \"!.git\""; + + changeDirWidgetCommand = lib.mkIf has-fd "fd --type d"; + changeDirWidgetOptions = lib.mkIf has-eza [ + "--preview 'eza --all --color=always --sort=name --group-directories-first --level=3 {}'" + ]; + + fileWidgetCommand = lib.mkIf has-fd "fd --type f"; + fileWidgetOptions = lib.mkIf has-bat [ + "--preview 'bat {}'" + ]; + + tmux.enableShellIntegration = lib.mkIf has-tmux true; + }; + + home.sessionVariables = + if has-delta then + { + fzf_diff_highlighter = "delta --paging=never --features=arctic-fox"; + } + else if has-difft then + { + fzf_diff_highlighter = "difft --color=always"; + } + else + { }; + }; +} diff --git a/old/home/programs/fzf.nix b/old/home/programs/fzf.nix deleted file mode 100644 index a6304db..0000000 --- a/old/home/programs/fzf.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ 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 = { - enable = true; - - rose-pine.enable = true; - - defaultOptions = [ - "--margin=10%,5%" - "--border=sharp" - "--pointer= " - "--marker= " - "--prompt= " - "--preview-label-pos='bottom'" - "--preview-window='border-sharp'" - ]; - - defaultCommand = lib.mkIf has-ripgrep "rg --files --hidden --glob \"!.git\""; - - changeDirWidgetCommand = lib.mkIf has-fd "fd --type d"; - changeDirWidgetOptions = lib.mkIf has-eza [ - "--preview 'eza --all --color=always --sort=name --group-directories-first --level=3 {}'" - ]; - - fileWidgetCommand = lib.mkIf has-fd "fd --type f"; - fileWidgetOptions = lib.mkIf has-bat [ - "--preview 'bat {}'" - ]; - - tmux.enableShellIntegration = lib.mkIf has-tmux true; - }; - - home.sessionVariables = lib.mkIf has-delta { - fzf_diff_highlighter = "delta --paging=never --features=arctic-fox"; - }; -}