From c351c175eccd2c9bc21a2f05db76f75a05eee9d4 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Tue, 25 Jun 2024 22:17:45 +0100 Subject: [PATCH] lib/neovim-plugin: support not having settings Allow callers to explicitly set `settingsOptions = null` to disable creating the `settings` option. `settingsOptions` still defaults to `{ }`. --- lib/neovim-plugin.nix | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/neovim-plugin.nix b/lib/neovim-plugin.nix index a0837c95..0f485e83 100644 --- a/lib/neovim-plugin.nix +++ b/lib/neovim-plugin.nix @@ -50,6 +50,7 @@ rec { defaultPackage, settingsOptions ? { }, settingsExample ? null, + hasSettings ? true, extraOptions ? { }, # config luaName ? name, @@ -95,17 +96,19 @@ rec { mkRenamedOptionModule (basePluginPath ++ optionPath) (settingsPath ++ optionPathSnakeCase) ) optionsRenamedToSettings); - options.${namespace}.${name} = { - enable = mkEnableOption originalName; - - package = nixvimOptions.mkPluginPackageOption originalName defaultPackage; - - settings = mkSettingsOption { - pluginName = name; - options = settingsOptions; - example = settingsExample; - }; - } // extraOptions; + options.${namespace}.${name} = + { + enable = mkEnableOption originalName; + package = nixvimOptions.mkPluginPackageOption originalName defaultPackage; + } + // optionalAttrs hasSettings { + settings = mkSettingsOption { + pluginName = name; + options = settingsOptions; + example = settingsExample; + }; + } + // extraOptions; config = let @@ -118,7 +121,7 @@ rec { inherit extraPackages; ${extraConfigNamespace} = optionalString callSetup '' - require('${luaName}').setup(${toLuaObject cfg.settings}) + require('${luaName}').setup(${optionalString (cfg ? settings) (toLuaObject cfg.settings)}) ''; } (optionalAttrs (isColorscheme && (colorscheme != null)) { colorscheme = mkDefault colorscheme; })