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
cfg = config.filetype;
mkFiletypeDetect = ft: pattern: {
"filetype-detect-${ft}" = {
event = [ "BufNewFile" "BufRead" ];
inherit pattern;
command = "setfiletype ${ft}";
};
};
mkFiletypeDetect = ft: pattern:
lib.nameValuePair
"filetype-detect-${ft}"
{
event = [ "BufNewFile" "BufRead" ];
inherit pattern;
command = "setfiletype ${ft}";
};
in
{
@ -51,7 +52,7 @@ in
};
ignore = mkOption {
type = extCommas;
type = uniq (listOf str);
default = [ "Z" "gz" "bz2" "zip" "tgz" ];
description = ''
To avoid that certain files are being inspected, the g:ft_ignore_pat variable
@ -62,7 +63,7 @@ in
};
extraIgnore = mkOption {
type = extCommas;
type = uniq (listOf str);
default = [ ];
};
@ -80,7 +81,7 @@ in
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 {
type = with types; nullOr (either str (listOf str));
type = with types; nullOr extCommas;
default = null;
description = ''
pattern(s) to match literally.