lib/helpers: factor out nixvimUtils

This commit is contained in:
Gaetan Lepage 2024-01-25 16:58:58 +01:00 committed by Gaétan Lepage
parent 98dbe8a89b
commit 7164a89f72
3 changed files with 35 additions and 45 deletions

View file

@ -1,44 +1,7 @@
{lib, ...}:
with lib; let
misc = {
listToUnkeyedAttrs = list:
builtins.listToAttrs
(lib.lists.imap0 (idx: lib.nameValuePair "__unkeyed-${toString idx}") list);
emptyTable = {"__empty" = null;};
mkIfNonNull' = x: y: (mkIf (x != null) y);
mkIfNonNull = x: (mkIfNonNull' x x);
ifNonNull' = x: y:
if (x == null)
then null
else y;
mkRaw = r:
if (isString r && (r != ""))
then {__raw = r;}
else null;
wrapDo = string: ''
do
${string}
end
'';
};
{lib, ...}: let
nixvimTypes = import ./types.nix {inherit lib nixvimOptions;};
nixvimOptions = import ./options.nix {
inherit lib;
inherit
(misc)
mkIf
mkIfNonNull
mkRaw
;
inherit nixvimTypes;
};
nixvimUtils = import ./utils.nix {inherit lib;};
nixvimOptions = import ./options.nix {inherit lib nixvimTypes nixvimUtils;};
in
{
maintainers = import ./maintainers.nix;
@ -48,5 +11,5 @@ in
inherit (import ./to-lua.nix {inherit lib;}) toLuaObject;
inherit nixvimTypes;
}
// misc
// nixvimUtils
// nixvimOptions