2023-04-08 14:59:58 -06:00
|
|
|
{ pkgs, config, lib, ... }:
|
2024-03-24 11:28:11 -06:00
|
|
|
|
2022-11-11 13:08:36 -07:00
|
|
|
let
|
|
|
|
cfg = config.programs.fzf;
|
2023-04-08 14:59:58 -06:00
|
|
|
in
|
|
|
|
{
|
2022-11-11 13:08:36 -07:00
|
|
|
options = {
|
2024-04-10 14:27:33 -06:00
|
|
|
programs.fzf = {
|
|
|
|
fuzzyCompletion = lib.mkEnableOption "fuzzy completion with fzf";
|
|
|
|
keybindings = lib.mkEnableOption "fzf keybindings";
|
|
|
|
};
|
2022-11-11 13:08:36 -07:00
|
|
|
};
|
2023-04-08 14:59:58 -06:00
|
|
|
|
2024-04-10 14:27:33 -06:00
|
|
|
config = lib.mkIf (cfg.keybindings || cfg.fuzzyCompletion) {
|
|
|
|
environment.systemPackages = lib.mkIf (cfg.keybindings || cfg.fuzzyCompletion) [ pkgs.fzf ];
|
2024-03-24 11:28:11 -06:00
|
|
|
|
2024-04-10 14:27:33 -06:00
|
|
|
programs = {
|
2024-02-26 04:09:22 -07:00
|
|
|
# load after programs.bash.completion.enable
|
2024-04-16 12:34:12 -06:00
|
|
|
bash.promptPluginInit = lib.mkAfter (lib.optionalString cfg.fuzzyCompletion ''
|
2024-04-10 14:27:33 -06:00
|
|
|
source ${pkgs.fzf}/share/fzf/completion.bash
|
|
|
|
'' + lib.optionalString cfg.keybindings ''
|
|
|
|
source ${pkgs.fzf}/share/fzf/key-bindings.bash
|
2024-04-16 12:34:12 -06:00
|
|
|
'');
|
2023-04-08 14:59:58 -06:00
|
|
|
|
2024-04-10 14:27:33 -06: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
|
|
|
|
'');
|
|
|
|
|
|
|
|
ohMyZsh.plugins = lib.mkIf config.programs.zsh.ohMyZsh.enable [ "fzf" ];
|
|
|
|
};
|
2024-03-24 11:28:11 -06:00
|
|
|
};
|
2022-11-11 13:08:36 -07:00
|
|
|
};
|
2024-03-24 11:28:11 -06:00
|
|
|
|
2024-04-10 14:27:33 -06:00
|
|
|
meta.maintainers = with lib.maintainers; [ laalsaas ];
|
2022-11-11 13:08:36 -07:00
|
|
|
}
|