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 <robert@rycee.net>
This commit is contained in:
Samuel Tschiedel 2022-06-06 09:15:37 -03:00 committed by Robert Helgesson
parent e622bad163
commit fd047c84f7
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -8,6 +8,17 @@ let
in { in {
meta.maintainers = [ maintainers.marsam ]; 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 = { options.programs.mcfly = {
enable = mkEnableOption "mcfly"; enable = mkEnableOption "mcfly";
@ -27,11 +38,13 @@ in {
''; '';
}; };
enableFuzzySearch = mkOption { fuzzySearchFactor = mkOption {
default = false; default = 0;
type = types.bool; type = types.ints.unsigned;
description = '' description = ''
Whether to enable fuzzy searching. 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.enableLightTheme { home.sessionVariables.MCFLY_LIGHT = "TRUE"; })
(mkIf cfg.enableFuzzySearch { home.sessionVariables.MCFLY_FUZZY = "TRUE"; }) (mkIf (cfg.fuzzySearchFactor > 0) {
home.sessionVariables.MCFLY_FUZZY = cfg.fuzzySearchFactor;
})
]); ]);
} }