2019-04-14 12:49:55 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.skim;
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
in {
|
2019-04-14 12:49:55 +02:00
|
|
|
options.programs.skim = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "skim - a command-line fuzzy finder";
|
2019-04-14 12:49:55 +02:00
|
|
|
|
2022-01-09 04:53:49 +01:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.skim;
|
|
|
|
defaultText = literalExpression "pkgs.skim";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Package providing the {command}`skim` tool.";
|
2022-01-09 04:53:49 +01:00
|
|
|
};
|
|
|
|
|
2019-04-14 12:49:55 +02:00
|
|
|
defaultCommand = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
example = "fd --type f";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-04-14 12:49:55 +02:00
|
|
|
The command that gets executed as the default source for skim
|
|
|
|
when running.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
defaultOptions = mkOption {
|
|
|
|
type = types.listOf types.str;
|
2020-02-02 00:39:17 +01:00
|
|
|
default = [ ];
|
2019-04-14 12:49:55 +02:00
|
|
|
example = [ "--height 40%" "--prompt ⟫" ];
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-04-14 12:49:55 +02:00
|
|
|
Extra command line options given to skim by default.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
fileWidgetCommand = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
example = "fd --type f";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-04-14 12:49:55 +02:00
|
|
|
The command that gets executed as the source for skim for the
|
|
|
|
CTRL-T keybinding.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
fileWidgetOptions = mkOption {
|
|
|
|
type = types.listOf types.str;
|
2020-02-02 00:39:17 +01:00
|
|
|
default = [ ];
|
2019-04-14 12:49:55 +02:00
|
|
|
example = [ "--preview 'head {}'" ];
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-04-14 12:49:55 +02:00
|
|
|
Command line options for the CTRL-T keybinding.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
changeDirWidgetCommand = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2020-02-02 00:39:17 +01:00
|
|
|
example = "fd --type d";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-04-14 12:49:55 +02:00
|
|
|
The command that gets executed as the source for skim for the
|
|
|
|
ALT-C keybinding.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
changeDirWidgetOptions = mkOption {
|
|
|
|
type = types.listOf types.str;
|
2020-02-02 00:39:17 +01:00
|
|
|
default = [ ];
|
2019-04-14 12:49:55 +02:00
|
|
|
example = [ "--preview 'tree -C {} | head -200'" ];
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-04-14 12:49:55 +02:00
|
|
|
Command line options for the ALT-C keybinding.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
historyWidgetOptions = mkOption {
|
|
|
|
type = types.listOf types.str;
|
2020-02-02 00:39:17 +01:00
|
|
|
default = [ ];
|
2019-04-14 12:49:55 +02:00
|
|
|
example = [ "--tac" "--exact" ];
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-04-14 12:49:55 +02:00
|
|
|
Command line options for the CTRL-R keybinding.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
enableBashIntegration = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-04-14 12:49:55 +02:00
|
|
|
Whether to enable Bash integration.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
enableZshIntegration = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-04-14 12:49:55 +02:00
|
|
|
Whether to enable Zsh integration.
|
|
|
|
'';
|
|
|
|
};
|
2020-10-10 07:16:50 +02:00
|
|
|
|
|
|
|
enableFishIntegration = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2020-10-10 07:16:50 +02:00
|
|
|
Whether to enable Fish integration.
|
|
|
|
'';
|
|
|
|
};
|
2019-04-14 12:49:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2022-01-09 04:53:49 +01:00
|
|
|
home.packages = [ cfg.package ];
|
2019-04-14 12:49:55 +02:00
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
home.sessionVariables = mapAttrs (n: v: toString v)
|
|
|
|
(filterAttrs (n: v: v != [ ] && v != null) {
|
|
|
|
SKIM_ALT_C_COMMAND = cfg.changeDirWidgetCommand;
|
|
|
|
SKIM_ALT_C_OPTS = cfg.changeDirWidgetOptions;
|
|
|
|
SKIM_CTRL_R_OPTS = cfg.historyWidgetOptions;
|
|
|
|
SKIM_CTRL_T_COMMAND = cfg.fileWidgetCommand;
|
|
|
|
SKIM_CTRL_T_OPTS = cfg.fileWidgetOptions;
|
|
|
|
SKIM_DEFAULT_COMMAND = cfg.defaultCommand;
|
|
|
|
SKIM_DEFAULT_OPTIONS = cfg.defaultOptions;
|
|
|
|
});
|
2019-04-14 12:49:55 +02:00
|
|
|
|
|
|
|
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
|
|
|
if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then
|
2022-01-11 03:51:06 +01:00
|
|
|
. ${cfg.package}/share/skim/completion.bash
|
|
|
|
. ${cfg.package}/share/skim/key-bindings.bash
|
2019-04-14 12:49:55 +02:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
|
|
|
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
|
|
|
|
if [[ $options[zle] = on ]]; then
|
2022-01-11 03:51:06 +01:00
|
|
|
. ${cfg.package}/share/skim/completion.zsh
|
|
|
|
. ${cfg.package}/share/skim/key-bindings.zsh
|
2019-04-14 12:49:55 +02:00
|
|
|
fi
|
|
|
|
'';
|
2020-10-10 07:16:50 +02:00
|
|
|
|
|
|
|
programs.fish.shellInit = mkIf cfg.enableFishIntegration ''
|
2022-01-11 03:51:06 +01:00
|
|
|
source ${cfg.package}/share/skim/key-bindings.fish && skim_key_bindings
|
2020-10-10 07:16:50 +02:00
|
|
|
'';
|
2019-04-14 12:49:55 +02:00
|
|
|
};
|
|
|
|
}
|