From 54db7915d03dbafe99e520096d9a9b966e315ef1 Mon Sep 17 00:00:00 2001 From: RockWolf Date: Sun, 15 Mar 2026 11:27:25 +0100 Subject: [PATCH] fish: change `mode` & `setsMode` bind options to allow arbitrary strings additional to default enum values --- modules/programs/fish.nix | 24 ++++++++++++++---------- tests/modules/programs/fish/binds.nix | 8 ++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index ad9e8d93..88164685 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -250,11 +250,13 @@ let description = "Specify the bind mode that the bind is used in"; type = with types; - nullOr (enum [ - "default" - "insert" - "paste" - ]); + nullOr ( + either (enum [ + "default" + "insert" + "paste" + ]) str + ); default = null; }; command = mkOption { @@ -279,11 +281,13 @@ let description = "Change current mode after bind is executed"; type = with types; - nullOr (enum [ - "default" - "insert" - "paste" - ]); + nullOr ( + either (enum [ + "default" + "insert" + "paste" + ]) str + ); default = null; }; erase = mkEnableOption "remove bind"; diff --git a/tests/modules/programs/fish/binds.nix b/tests/modules/programs/fish/binds.nix index 65e8a264..d41766ba 100644 --- a/tests/modules/programs/fish/binds.nix +++ b/tests/modules/programs/fish/binds.nix @@ -14,6 +14,12 @@ command = "exit"; }; + # Allow arbitrary modes + "f" = { + mode = "something-non-default"; + command = "exit"; + }; + "ctrl-c" = { mode = "insert"; command = [ @@ -57,6 +63,8 @@ "bind --preset alt-s 'fish_commandline_prepend sudo" assertFileContains home-files/.config/fish/functions/fish_user_key_bindings.fish \ "bind --mode visual ctrl-d exit" + assertFileContains home-files/.config/fish/functions/fish_user_key_bindings.fish \ + "bind --mode something-non-default f exit" ''; }; };