mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
lib: add types.flagInt
+ defaultNullOpts.mkIntFlag
Either `0` or `1`, but can be coerced from a boolean definition to support legacy definitions. When coerced, a warning is printed
This commit is contained in:
parent
2de406d972
commit
555035ef79
2 changed files with 17 additions and 2 deletions
|
@ -187,6 +187,8 @@ rec {
|
|||
# Unsigned: >=0
|
||||
mkUnsignedInt' = args: mkNullableWithRaw' (args // { type = types.ints.unsigned; });
|
||||
mkUnsignedInt = pluginDefault: description: mkUnsignedInt' { inherit pluginDefault description; };
|
||||
mkFlagInt = pluginDefault: description: mkFlagInt' { inherit pluginDefault description; };
|
||||
mkFlagInt' = args: mkNullableWithRaw' (args // { type = types.intFlag; });
|
||||
mkBool' = args: mkNullableWithRaw' (args // { type = types.bool; });
|
||||
mkBool = pluginDefault: description: mkBool' { inherit pluginDefault description; };
|
||||
mkStr' = args: mkNullableWithRaw' (args // { type = types.str; });
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
# Custom types to be included in `lib.types`
|
||||
{ lib, helpers }:
|
||||
{ lib }:
|
||||
let
|
||||
inherit (lib) types;
|
||||
inherit (lib.nixvim) mkNullOrStr mkNullOrOption;
|
||||
inherit (lib.nixvim)
|
||||
deprecation
|
||||
mkNullOrStr
|
||||
mkNullOrOption
|
||||
;
|
||||
|
||||
strLikeType =
|
||||
description:
|
||||
|
@ -30,6 +34,15 @@ rec {
|
|||
|
||||
maybeRaw = type: types.either type rawLua;
|
||||
|
||||
# Describes an boolean-like integer flag that is either 0 or 1
|
||||
# Has legacy support for boolean definitions, added 2024-09-08
|
||||
intFlag =
|
||||
with types;
|
||||
deprecation.transitionType bool (v: if v then 1 else 0) (enum [
|
||||
0
|
||||
1
|
||||
]);
|
||||
|
||||
border =
|
||||
with types;
|
||||
oneOf [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue