From d1fdbfc0b10adb0c514f6b62ca555f2232cd51e9 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Jun 2026 02:04:18 +0300 Subject: [PATCH] lib/types: allow passing raw Lua as a value to `setupOpts` directly Lets users pass an entire inline Lua table to `setupOpts` for ad-hoc overrides. Signed-off-by: NotAShelf Change-Id: I7901c8b6e9b8d4e8c23685ad35fb507e6a6a6964 --- lib/types/plugins.nix | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index 4be39289..49541705 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -6,6 +6,7 @@ inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair; inherit (lib.strings) hasPrefix removePrefix; inherit (lib.types) submodule either package enum str lines anything listOf nullOr; + inherit (lib.nvim.types) luaInline; # Get the names of all flake inputs that start with the given prefix. fromInputs = { @@ -82,19 +83,27 @@ in { } ``` */ - mkPluginSetupOption = pluginName: opts: - mkOption { - description = '' - Option table to pass into the setup function of ${pluginName} - - You can pass in any additional options even if they're - not listed in the docs - ''; - - default = {}; - type = submodule { + mkPluginSetupOption = pluginName: opts: let + luaOrModule = + either (submodule { freeformType = anything; options = opts; - }; + }) + luaInline; + in + mkOption { + type = luaOrModule; + default = {}; + + description = '' + Option table to pass into the setup function of ${pluginName}. + + Accepts either an attribute set of options, or a raw Lua expression + via `lib.mkLuaInline`. When set to a `luaInline` value, the + expression is passed verbatim as the argument to `setup()`. + + You can pass in any additional options even if they're not listed + in the docs. + ''; }; }