diff --git a/docs/release-notes/rl-0.6.md b/docs/release-notes/rl-0.6.md index 061555f1..01fbe62f 100644 --- a/docs/release-notes/rl-0.6.md +++ b/docs/release-notes/rl-0.6.md @@ -48,3 +48,7 @@ Release notes for release 0.6 [elijahimmer](https://github.com/elijahimmer) - Added rose-pine theme + +[frothymarrow](https://github.com/frothymarrow) + +- Added option `vim.luaPackages` to wrap neovim with extra Lua packages. diff --git a/lib/lua.nix b/lib/lua.nix index 55e22d37..708b4647 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -1,7 +1,7 @@ # Helpers for converting values to lua {lib}: let inherit (lib) mapAttrsToList filterAttrs concatStringsSep concatMapStringsSep stringToCharacters boolToString; - inherit (builtins) hasAttr head; + inherit (builtins) hasAttr head throw typeOf; in rec { # Convert a null value to lua's nil nullString = value: @@ -19,6 +19,8 @@ in rec { then lib.boolToString exp # if bool, convert to string else if builtins.isInt exp then builtins.toString exp # if int, convert to string + else if exp == null + then "nil" else (builtins.toJSON exp); # otherwise jsonify the value and print as is # convert list to a lua table @@ -80,7 +82,7 @@ in rec { then "${toString args}" else if builtins.isInt args then "${toString args}" - else if (args != null) + else if (args == null) then "nil" - else ""; + else throw "could not convert object of type `${typeOf args}` to lua object"; } diff --git a/modules/core/build/default.nix b/modules/core/build/default.nix index 3b88e648..bbd634ce 100644 --- a/modules/core/build/default.nix +++ b/modules/core/build/default.nix @@ -153,6 +153,14 @@ in { ''; }; + luaPackages = mkOption { + type = types.listOf types.str; + default = []; + description = '' + List of lua packages to install. + ''; + }; + globals = mkOption { default = {}; description = "Set containing global variable values"; diff --git a/modules/default.nix b/modules/default.nix index 31cf87dd..c9703b90 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -23,6 +23,8 @@ inputs: { vimOptions = module.config.vim; + extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages; + buildPlug = {pname, ...} @ args: assert lib.asserts.assertMsg (pname != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter."; buildVimPlugin (args @@ -59,6 +61,8 @@ inputs: { inherit (vimOptions) viAlias; inherit (vimOptions) vimAlias; + inherit extraLuaPackages; + configure = { customRC = vimOptions.builtConfigRC;