fzf: add historyWidget.command option
Expose FZF_CTRL_R_COMMAND again so users can disable fzf's Ctrl-R binding explicitly, and warn when the configured package is too old to support it.
This commit is contained in:
parent
cde77509b6
commit
fe3ce0a527
5 changed files with 70 additions and 9 deletions
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
options,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
|
@ -39,6 +40,7 @@ let
|
|||
fzfEnvVars = lib.filterAttrs (_n: v: v != [ ] && v != null) {
|
||||
FZF_ALT_C_COMMAND = cfg.changeDirWidget.command;
|
||||
FZF_ALT_C_OPTS = cfg.changeDirWidget.options;
|
||||
FZF_CTRL_R_COMMAND = cfg.historyWidget.command;
|
||||
FZF_CTRL_R_OPTS = cfg.historyWidget.options;
|
||||
FZF_CTRL_T_COMMAND = cfg.fileWidget.command;
|
||||
FZF_CTRL_T_OPTS = cfg.fileWidget.options;
|
||||
|
|
@ -85,11 +87,10 @@ in
|
|||
"historyWidget"
|
||||
"options"
|
||||
])
|
||||
(lib.mkRemovedOptionModule [
|
||||
"programs"
|
||||
"fzf"
|
||||
"historyWidgetCommand"
|
||||
] "This option is no longer supported by fzf.")
|
||||
(mkRenamedFzfOption "historyWidgetCommand" [
|
||||
"historyWidget"
|
||||
"command"
|
||||
])
|
||||
];
|
||||
|
||||
options.programs.fzf =
|
||||
|
|
@ -170,6 +171,16 @@ in
|
|||
};
|
||||
|
||||
historyWidget = mkWidgetOption {
|
||||
commandExample = "";
|
||||
commandDescription = ''
|
||||
The command that gets executed as the source for fzf for the
|
||||
CTRL-R keybinding.
|
||||
|
||||
An empty string disables the CTRL-R binding, which is the supported
|
||||
way to yield CTRL-R to a history manager such as Atuin or McFly.
|
||||
Non-empty custom commands require fzf 0.66.0 or later but are not
|
||||
supported by fzf yet and currently print a shell startup warning.
|
||||
'';
|
||||
optionsExample = [
|
||||
"--sort"
|
||||
"--exact"
|
||||
|
|
@ -224,6 +235,15 @@ in
|
|||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
warnings =
|
||||
lib.optional (cfg.historyWidget.command != null && lib.versionOlder cfg.package.version "0.66.0")
|
||||
''
|
||||
`programs.fzf.historyWidget.command` defined in ${lib.showFiles options.programs.fzf.historyWidget.command.files} requires fzf 0.66.0 or greater.
|
||||
|
||||
The configured FZF_CTRL_R_COMMAND value will be ignored by older fzf
|
||||
versions.
|
||||
'';
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion =
|
||||
|
|
|
|||
|
|
@ -14,10 +14,13 @@
|
|||
command = "fd --type d";
|
||||
options = [ "--preview 'tree -C {} | head -200'" ];
|
||||
};
|
||||
historyWidget.options = [
|
||||
"--sort"
|
||||
"--exact"
|
||||
];
|
||||
historyWidget = {
|
||||
command = "";
|
||||
options = [
|
||||
"--sort"
|
||||
"--exact"
|
||||
];
|
||||
};
|
||||
colors = {
|
||||
bg = "#1e1e1e";
|
||||
};
|
||||
|
|
@ -47,6 +50,8 @@
|
|||
'FZF_ALT_C_OPTS="--preview'
|
||||
|
||||
# Test history widget
|
||||
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'FZF_CTRL_R_COMMAND=""'
|
||||
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'FZF_CTRL_R_OPTS="--sort --exact"'
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
fzf-bash-integration = ./bash-integration.nix;
|
||||
fzf-zsh-integration = ./zsh-integration.nix;
|
||||
fzf-fish-integration = ./fish-integration.nix;
|
||||
fzf-history-command-version-warning = ./history-command-version-warning.nix;
|
||||
fzf-nushell-integration = ./nushell-integration.nix;
|
||||
fzf-renamed-options = ./renamed-options.nix;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
options,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
programs.fzf = {
|
||||
enable = true;
|
||||
enableNushellIntegration = false;
|
||||
|
||||
historyWidget.command = "history";
|
||||
|
||||
package = config.lib.test.mkStubPackage {
|
||||
name = "fzf";
|
||||
version = "0.65.0";
|
||||
};
|
||||
};
|
||||
|
||||
test.asserts.warnings.expected = [
|
||||
''
|
||||
`programs.fzf.historyWidget.command` defined in ${lib.showFiles options.programs.fzf.historyWidget.command.files} requires fzf 0.66.0 or greater.
|
||||
|
||||
The configured FZF_CTRL_R_COMMAND value will be ignored by older fzf
|
||||
versions.
|
||||
''
|
||||
];
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-path/etc/profile.d/hm-session-vars.sh
|
||||
'';
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
fileWidgetOptions = [ "--preview 'head {}'" ];
|
||||
changeDirWidgetCommand = "fd --type d";
|
||||
changeDirWidgetOptions = [ "--preview 'tree -C {} | head -200'" ];
|
||||
historyWidgetCommand = "";
|
||||
historyWidgetOptions = [
|
||||
"--sort"
|
||||
"--exact"
|
||||
|
|
@ -14,6 +15,7 @@
|
|||
};
|
||||
|
||||
test.asserts.warnings.expected = [
|
||||
"The option `programs.fzf.historyWidgetCommand' defined in ${lib.showFiles options.programs.fzf.historyWidgetCommand.files} has been renamed to `programs.fzf.historyWidget.command'."
|
||||
"The option `programs.fzf.historyWidgetOptions' defined in ${lib.showFiles options.programs.fzf.historyWidgetOptions.files} has been renamed to `programs.fzf.historyWidget.options'."
|
||||
"The option `programs.fzf.changeDirWidgetOptions' defined in ${lib.showFiles options.programs.fzf.changeDirWidgetOptions.files} has been renamed to `programs.fzf.changeDirWidget.options'."
|
||||
"The option `programs.fzf.changeDirWidgetCommand' defined in ${lib.showFiles options.programs.fzf.changeDirWidgetCommand.files} has been renamed to `programs.fzf.changeDirWidget.command'."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue