Skip to content

Commit

Permalink
lib/options: add mkAttrsOf' & mkListOf' (etc)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSturgeon committed Jun 1, 2024
1 parent e0b60ba commit 1bb4cb9
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,22 @@ rec {
default:
assert default == null || isString default;
mkNullableWithRaw types.str (generators.toPretty { } default);
mkAttributeSet = mkNullable nixvimTypes.attrs;
mkListOf = ty: default: mkNullable (with nixvimTypes; listOf (maybeRaw ty)) default;
mkAttrsOf = ty: default: mkNullable (with nixvimTypes; attrsOf (maybeRaw ty)) default;

mkAttributeSet' = args: mkNullable' (args // { type = nixvimTypes.attrs; });
mkAttributeSet = default: description: mkAttributeSet' { inherit default description; };

mkListOf' =
{ type, ... }@args: mkNullable' (args // { type = with nixvimTypes; listOf (maybeRaw type); });
mkListOf =
type: default: description:
mkListOf' { inherit type default description; };

mkAttrsOf' =
{ type, ... }@args: mkNullable' (args // { type = with nixvimTypes; attrsOf (maybeRaw type); });
mkAttrsOf =
type: default: description:
mkAttrsOf' { inherit type default description; };

mkEnum =
enumValues: default:
mkNullableWithRaw (types.enum enumValues) (
Expand Down

0 comments on commit 1bb4cb9

Please sign in to comment.