From 7c39d77b9f1fbcbd8f2a575c4f2948dd54efc5c1 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Thu, 1 Aug 2024 18:05:00 +0100 Subject: [PATCH] lib/helpers: scope each subsection, but offer aliases --- lib/helpers.nix | 86 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 15 deletions(-) diff --git a/lib/helpers.nix b/lib/helpers.nix index a56cfc9a..c1f28bfc 100644 --- a/lib/helpers.nix +++ b/lib/helpers.nix @@ -9,20 +9,76 @@ let call = lib.callPackageWith { inherit pkgs lib helpers; }; # Build helpers recursively - helpers = - { - autocmd = call ./autocmd-helpers.nix { }; - keymaps = call ./keymap-helpers.nix { }; - lua = call ./to-lua.nix { }; - toLuaObject = helpers.lua.toLua; - maintainers = import ./maintainers.nix; - neovim-plugin = call ./neovim-plugin.nix { }; - nixvimTypes = call ./types.nix { }; - vim-plugin = call ./vim-plugin.nix { }; - } - // call ./builders.nix { } - // call ./deprecation.nix { } - // call ./options.nix { } - // call ./utils.nix { inherit _nixvimTests; }; + helpers = { + autocmd = call ./autocmd-helpers.nix { }; + builders = call ./builders.nix { }; + deprecation = call ./deprecation.nix { }; + keymaps = call ./keymap-helpers.nix { }; + lua = call ./to-lua.nix { }; + maintainers = import ./maintainers.nix; + neovim-plugin = call ./neovim-plugin.nix { }; + nixvimTypes = call ./types.nix { }; + options = call ./options.nix { }; + utils = call ./utils.nix { inherit _nixvimTests; }; + vim-plugin = call ./vim-plugin.nix { }; + + # Top-level helper aliases: + # TODO: deprecate some aliases + + inherit (helpers.builders) + writeLua + writeByteCompiledLua + byteCompileLuaFile + byteCompileLuaHook + byteCompileLuaDrv + ; + + inherit (helpers.deprecation) getOptionRecursive mkDeprecatedSubOptionModule transitionType; + + inherit (helpers.options) + defaultNullOpts + mkCompositeOption + mkCompositeOption' + mkNullOrLua + mkNullOrLua' + mkNullOrLuaFn + mkNullOrLuaFn' + mkNullOrOption + mkNullOrOption' + mkNullOrStr + mkNullOrStr' + mkNullOrStrLuaFnOr + mkNullOrStrLuaFnOr' + mkNullOrStrLuaOr + mkNullOrStrLuaOr' + mkPackageOption + mkPluginPackageOption + mkSettingsOption + pluginDefaultText + ; + + inherit (helpers.utils) + concatNonEmptyLines + emptyTable + enableExceptInTests + hasContent + ifNonNull' + listToUnkeyedAttrs + mkIfNonNull + mkIfNonNull' + mkRaw + mkRawKey + override + overrideDerivation + toRawKeys + toSnakeCase + upperFirstChar + wrapDo + wrapLuaForVimscript + wrapVimscriptForLua + ; + + toLuaObject = helpers.lua.toLua; + }; in helpers