2023-04-08 22:59:58 +02:00
|
|
|
{ pkgs, config, lib, ... }:
|
2022-11-11 21:08:36 +01:00
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.programs.fzf;
|
2023-04-08 22:59:58 +02:00
|
|
|
in
|
|
|
|
{
|
2022-11-11 21:08:36 +01:00
|
|
|
options = {
|
|
|
|
programs.fzf = {
|
2022-12-03 16:15:00 +01:00
|
|
|
fuzzyCompletion = mkEnableOption (mdDoc "fuzzy completion with fzf");
|
|
|
|
keybindings = mkEnableOption (mdDoc "fzf keybindings");
|
2022-11-11 21:08:36 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
config = {
|
|
|
|
environment.systemPackages = optional (cfg.keybindings || cfg.fuzzyCompletion) pkgs.fzf;
|
2023-04-08 22:59:58 +02:00
|
|
|
|
2022-11-11 21:08:36 +01:00
|
|
|
programs.bash.interactiveShellInit = optionalString cfg.fuzzyCompletion ''
|
|
|
|
source ${pkgs.fzf}/share/fzf/completion.bash
|
|
|
|
'' + optionalString cfg.keybindings ''
|
|
|
|
source ${pkgs.fzf}/share/fzf/key-bindings.bash
|
|
|
|
'';
|
|
|
|
|
2023-04-08 22:59:58 +02:00
|
|
|
programs.zsh.interactiveShellInit = optionalString (!config.programs.zsh.ohMyZsh.enable)
|
|
|
|
(optionalString cfg.fuzzyCompletion ''
|
|
|
|
source ${pkgs.fzf}/share/fzf/completion.zsh
|
|
|
|
'' + optionalString cfg.keybindings ''
|
|
|
|
source ${pkgs.fzf}/share/fzf/key-bindings.zsh
|
|
|
|
'');
|
|
|
|
|
2023-05-08 21:01:05 +02:00
|
|
|
programs.zsh.ohMyZsh.plugins = lib.mkIf (cfg.keybindings || cfg.fuzzyCompletion) [ "fzf" ];
|
2022-11-11 21:08:36 +01:00
|
|
|
};
|
|
|
|
meta.maintainers = with maintainers; [ laalsaas ];
|
|
|
|
}
|