From 95566f10fba984eca53813fc8ad2f813dd76ed45 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 17 Feb 2024 16:44:05 +0100 Subject: [PATCH 1/5] fix: expToLua convert null to nil --- lib/lua.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/lua.nix b/lib/lua.nix index 55e22d37..e37db7a1 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -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 From 40b985c066227b5237d6506e070cc5dc91ff1b90 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 17 Feb 2024 16:44:41 +0100 Subject: [PATCH 2/5] fix: bug where toLuaObject converts null to "" --- lib/lua.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lua.nix b/lib/lua.nix index e37db7a1..4bd4930e 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -82,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 ""; } From a57e89dece266c95e3de16311661efbcd8dfe1ab Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 17 Feb 2024 21:55:07 +0100 Subject: [PATCH 3/5] fix: throw error when converting unknown object to lua --- lib/lua.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/lua.nix b/lib/lua.nix index 4bd4930e..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: @@ -84,5 +84,5 @@ in rec { then "${toString args}" else if (args == null) then "nil" - else ""; + else throw "could not convert object of type `${typeOf args}` to lua object"; } From 35143b7ddafa899a0668a0f2cc695c7e8886b1ae Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Sat, 17 Feb 2024 17:03:47 -0500 Subject: [PATCH 4/5] wrapper: optionally wrap neovim with extra lua packages --- modules/core/default.nix | 8 ++++++++ modules/default.nix | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/modules/core/default.nix b/modules/core/default.nix index e4703b6c..13534a4a 100644 --- a/modules/core/default.nix +++ b/modules/core/default.nix @@ -209,6 +209,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; From 949a60c569ded7b4bdcf6b55177f7fd91e5ec0d8 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Sat, 17 Feb 2024 18:10:06 -0500 Subject: [PATCH 5/5] docs: add entry for `vim.luaPackages` option --- docs/release-notes/rl-0.6.md | 4 ++++ 1 file changed, 4 insertions(+) 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.