From fd047c84f705442f04105e363ed450f54309591e Mon Sep 17 00:00:00 2001 From: Samuel Tschiedel Date: Mon, 6 Jun 2022 09:15:37 -0300 Subject: [PATCH] mcfly: add fuzzy search factor option Per the [docs], MCFLY_FUZZY is no longer a boolean, taking now a positive integer that controls the fuzziness factor. [docs]: https://github.com/cantino/mcfly#fuzzy-searching Co-authored-by: Robert Helgesson --- modules/programs/mcfly.nix | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/modules/programs/mcfly.nix b/modules/programs/mcfly.nix index e6b1640bb..8d4bfd3c0 100644 --- a/modules/programs/mcfly.nix +++ b/modules/programs/mcfly.nix @@ -8,6 +8,17 @@ let in { meta.maintainers = [ maintainers.marsam ]; + imports = [ + (mkChangedOptionModule # \ + [ "programs" "mcfly" "enableFuzzySearch" ] # \ + [ "programs" "mcfly" "fuzzySearchFactor" ] # \ + (config: + let + value = + getAttrFromPath [ "programs" "mcfly" "enableFuzzySearch" ] config; + in if value then 2 else 0)) + ]; + options.programs.mcfly = { enable = mkEnableOption "mcfly"; @@ -27,11 +38,13 @@ in { ''; }; - enableFuzzySearch = mkOption { - default = false; - type = types.bool; + fuzzySearchFactor = mkOption { + default = 0; + type = types.ints.unsigned; description = '' Whether to enable fuzzy searching. + 0 is off; higher numbers weight toward shorter matches. + Values in the 2-5 range get good results so far. ''; }; @@ -81,6 +94,8 @@ in { (mkIf cfg.enableLightTheme { home.sessionVariables.MCFLY_LIGHT = "TRUE"; }) - (mkIf cfg.enableFuzzySearch { home.sessionVariables.MCFLY_FUZZY = "TRUE"; }) + (mkIf (cfg.fuzzySearchFactor > 0) { + home.sessionVariables.MCFLY_FUZZY = cfg.fuzzySearchFactor; + }) ]); }