modules/filetype: fixup options

This commit is contained in:
Dmitriy Pleshevskiy 2024-05-17 15:27:04 +03:00
parent e5f2d7236a
commit 37156d182b
Signed by: pleshevskiy
GPG Key ID: 17041163DA10A9A2
2 changed files with 12 additions and 11 deletions

View File

@ -3,13 +3,14 @@
let let
cfg = config.filetype; cfg = config.filetype;
mkFiletypeDetect = ft: pattern: { mkFiletypeDetect = ft: pattern:
"filetype-detect-${ft}" = { lib.nameValuePair
event = [ "BufNewFile" "BufRead" ]; "filetype-detect-${ft}"
inherit pattern; {
command = "setfiletype ${ft}"; event = [ "BufNewFile" "BufRead" ];
}; inherit pattern;
}; command = "setfiletype ${ft}";
};
in in
{ {
@ -51,7 +52,7 @@ in
}; };
ignore = mkOption { ignore = mkOption {
type = extCommas; type = uniq (listOf str);
default = [ "Z" "gz" "bz2" "zip" "tgz" ]; default = [ "Z" "gz" "bz2" "zip" "tgz" ];
description = '' description = ''
To avoid that certain files are being inspected, the g:ft_ignore_pat variable To avoid that certain files are being inspected, the g:ft_ignore_pat variable
@ -62,7 +63,7 @@ in
}; };
extraIgnore = mkOption { extraIgnore = mkOption {
type = extCommas; type = uniq (listOf str);
default = [ ]; default = [ ];
}; };
@ -80,7 +81,7 @@ in
vim.g.ft_ignore_pat = "\\\\.(${lib.concatStringsSep "|" (cfg.ignore ++ cfg.extraIgnore)})$"; vim.g.ft_ignore_pat = "\\\\.(${lib.concatStringsSep "|" (cfg.ignore ++ cfg.extraIgnore)})$";
vim.augroup = lib.mkIf (cfg.detect != { }) (lib.mapAttrsToList mkFiletypeDetect cfg.detect); vim.augroup = lib.mkIf (cfg.detect != { }) (lib.listToAttrs (lib.mapAttrsToList mkFiletypeDetect cfg.detect));
}; };
} }

View File

@ -21,7 +21,7 @@ let
''; '';
}; };
pattern = mkOption { pattern = mkOption {
type = with types; nullOr (either str (listOf str)); type = with types; nullOr extCommas;
default = null; default = null;
description = '' description = ''
pattern(s) to match literally. pattern(s) to match literally.