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
"filetype-detect-${ft}"
{
event = [ "BufNewFile" "BufRead" ]; event = [ "BufNewFile" "BufRead" ];
inherit pattern; inherit pattern;
command = "setfiletype ${ft}"; 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.