1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

fzf: add compatibility with fzf≥0.48.0

fzf 0.48.0 [1] changed the way it integrates with shells.

[1] https://github.com/junegunn/fzf/releases/tag/0.48.0
This commit is contained in:
Mario Rodas 2024-04-09 01:57:29 -05:00 committed by GitHub
parent a561ad6ab3
commit 40a99619da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,6 +10,35 @@ let
concatStringsSep "," concatStringsSep ","
(mapAttrsToList (name: value: "${name}:${value}") colors); (mapAttrsToList (name: value: "${name}:${value}") colors);
hasShellIntegrationEmbedded = lib.versionAtLeast cfg.package.version "0.48.0";
bashIntegration = if hasShellIntegrationEmbedded then ''
if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then
eval "$(${getExe cfg.package} --bash)"
fi
'' else ''
if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then
. ${cfg.package}/share/fzf/completion.bash
. ${cfg.package}/share/fzf/key-bindings.bash
fi
'';
zshIntegration = if hasShellIntegrationEmbedded then ''
if [[ $options[zle] = on ]]; then
eval "$(${getExe cfg.package} --zsh)"
fi
'' else ''
if [[ $options[zle] = on ]]; then
. ${cfg.package}/share/fzf/completion.zsh
. ${cfg.package}/share/fzf/key-bindings.zsh
fi
'';
fishIntegration = if hasShellIntegrationEmbedded then ''
${getExe cfg.package} --fish | source
'' else ''
source ${cfg.package}/share/fzf/key-bindings.fish && fzf_key_bindings
'';
in { in {
imports = [ imports = [
(mkRemovedOptionModule [ "programs" "fzf" "historyWidgetCommand" ] (mkRemovedOptionModule [ "programs" "fzf" "historyWidgetCommand" ]
@ -173,26 +202,16 @@ in {
# Note, since fzf unconditionally binds C-r we use `mkOrder` to make the # Note, since fzf unconditionally binds C-r we use `mkOrder` to make the
# initialization show up a bit earlier. This is to make initialization of # initialization show up a bit earlier. This is to make initialization of
# other history managers, like mcfly or atuin, take precedence. # other history managers, like mcfly or atuin, take precedence.
programs.bash.initExtra = mkIf cfg.enableBashIntegration (mkOrder 200 '' programs.bash.initExtra =
if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then mkIf cfg.enableBashIntegration (mkOrder 200 bashIntegration);
. ${cfg.package}/share/fzf/completion.bash
. ${cfg.package}/share/fzf/key-bindings.bash
fi
'');
# Note, since fzf unconditionally binds C-r we use `mkOrder` to make the # Note, since fzf unconditionally binds C-r we use `mkOrder` to make the
# initialization show up a bit earlier. This is to make initialization of # initialization show up a bit earlier. This is to make initialization of
# other history managers, like mcfly or atuin, take precedence. # other history managers, like mcfly or atuin, take precedence.
programs.zsh.initExtra = mkIf cfg.enableZshIntegration (mkOrder 200 '' programs.zsh.initExtra =
if [[ $options[zle] = on ]]; then mkIf cfg.enableZshIntegration (mkOrder 200 zshIntegration);
. ${cfg.package}/share/fzf/completion.zsh
. ${cfg.package}/share/fzf/key-bindings.zsh
fi
'');
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration programs.fish.interactiveShellInit =
(mkOrder 200 '' mkIf cfg.enableFishIntegration (mkOrder 200 fishIntegration);
source ${cfg.package}/share/fzf/key-bindings.fish && fzf_key_bindings
'');
}; };
} }