2023-05-24 13:37:59 +00:00
|
|
|
{ pkgs, config, lib, ... }:
|
2024-04-21 15:54:59 +00:00
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
let
|
|
|
|
cfg = config.programs.fzf;
|
2023-05-24 13:37:59 +00:00
|
|
|
in
|
|
|
|
{
|
2022-12-17 10:02:37 +00:00
|
|
|
options = {
|
|
|
|
programs.fzf = {
|
2024-04-21 15:54:59 +00:00
|
|
|
fuzzyCompletion = lib.mkEnableOption "fuzzy completion with fzf";
|
|
|
|
keybindings = lib.mkEnableOption "fzf keybindings";
|
2022-12-17 10:02:37 +00:00
|
|
|
};
|
|
|
|
};
|
2023-05-24 13:37:59 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
config = lib.mkIf (cfg.keybindings || cfg.fuzzyCompletion) {
|
|
|
|
environment.systemPackages = lib.mkIf (cfg.keybindings || cfg.fuzzyCompletion) [ pkgs.fzf ];
|
|
|
|
|
|
|
|
programs = {
|
2024-06-20 14:57:18 +00:00
|
|
|
# load after programs.bash.completion.enable
|
2024-05-15 15:35:15 +00:00
|
|
|
bash.promptPluginInit = lib.mkAfter (lib.optionalString cfg.fuzzyCompletion ''
|
2024-04-21 15:54:59 +00:00
|
|
|
source ${pkgs.fzf}/share/fzf/completion.bash
|
|
|
|
'' + lib.optionalString cfg.keybindings ''
|
|
|
|
source ${pkgs.fzf}/share/fzf/key-bindings.bash
|
2024-05-15 15:35:15 +00:00
|
|
|
'');
|
2022-12-17 10:02:37 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
zsh = {
|
|
|
|
interactiveShellInit = lib.optionalString (!config.programs.zsh.ohMyZsh.enable)
|
|
|
|
(lib.optionalString cfg.fuzzyCompletion ''
|
|
|
|
source ${pkgs.fzf}/share/fzf/completion.zsh
|
|
|
|
'' + lib.optionalString cfg.keybindings ''
|
|
|
|
source ${pkgs.fzf}/share/fzf/key-bindings.zsh
|
|
|
|
'');
|
2023-05-24 13:37:59 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
ohMyZsh.plugins = lib.mkIf config.programs.zsh.ohMyZsh.enable [ "fzf" ];
|
|
|
|
};
|
|
|
|
};
|
2022-12-17 10:02:37 +00:00
|
|
|
};
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ laalsaas ];
|
2022-12-17 10:02:37 +00:00
|
|
|
}
|