lib/options: mkEnum quote default if string

As there's only a handful of call-sites to fix, ensure all `mkEnum`
defaults are passed in as the correct type (tree wide) and change
`mkEnum` to now correctly render string-type defaults "quoted" (like
`mkString` does).
This commit is contained in:
Matt Sturgeon 2024-05-30 03:08:22 +01:00
parent 993deb227e
commit ff1ab1700c
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
3 changed files with 11 additions and 8 deletions

View file

@ -120,7 +120,12 @@ rec {
mkAttributeSet = default: mkNullable nixvimTypes.attrs ''${default}'';
mkListOf = ty: default: mkNullable (with nixvimTypes; listOf (maybeRaw ty)) default;
mkAttrsOf = ty: default: mkNullable (with nixvimTypes; attrsOf (maybeRaw ty)) default;
mkEnum = enumValues: default: mkNullableWithRaw (types.enum enumValues) ''"${default}"'';
mkEnum =
enumValues: default:
mkNullableWithRaw (types.enum enumValues) (
# TODO we should remove this once `mkDefaultDesc` no longer has a special case
if isString default then generators.toPretty { } default else default
);
mkEnumFirstDefault = enumValues: mkEnum enumValues (head enumValues);
mkBorder =
default: name: desc: