diff --git a/lib/types/default.nix b/lib/types/default.nix index 9b5469db..6fae44ff 100644 --- a/lib/types/default.nix +++ b/lib/types/default.nix @@ -9,7 +9,7 @@ customTypes = import ./custom.nix {inherit lib;}; in { inherit (typesDag) dagOf; - inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType; + inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption mkPluginSetupOption' luaInline pluginType borderType; inherit (typesLanguage) diagnostics mkGrammarOption; inherit (typesLsp) mkLspPresetEnableOption; inherit (customTypes) char hexColor mergelessListOf deprecatedSingleOrListOf enumWithRename; diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index 4be39289..a7d7128c 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -4,6 +4,7 @@ }: let inherit (lib.options) mkOption; inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair; + inherit (lib.lists) toList; inherit (lib.strings) hasPrefix removePrefix; inherit (lib.types) submodule either package enum str lines anything listOf nullOr; @@ -49,8 +50,39 @@ }; borderPresets = ["none" "single" "double" "rounded" "solid" "shadow"]; + + /* + opts is a attrset of options, example: + ``` + mkPluginSetupOption "telescope" { + file_ignore_patterns = mkOption { + description = "..."; + type = types.listOf types.str; + default = []; + }; + layout_config.horizontal = mkOption {...}; + } + ``` + */ + mkPluginSetupOption = pluginName: opts: + mkPluginSetupOption' pluginName { options = opts; }; + + mkPluginSetupOption' = pluginName: modules: + 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 ((toList modules) ++ [ + { freeformType = anything; } + ]); + }; in { - inherit extraPluginType fromInputs pluginType; + inherit extraPluginType fromInputs mkPluginSetupOption mkPluginSetupOption' pluginType; borderType = either (enum borderPresets) (listOf (either str (listOf str))); @@ -68,33 +100,4 @@ in { name = "luaInline"; check = x: lib.nvim.lua.isLuaInline x; }; - - /* - opts is a attrset of options, example: - ``` - mkPluginSetupOption "telescope" { - file_ignore_patterns = mkOption { - description = "..."; - type = types.listOf types.str; - default = []; - }; - layout_config.horizontal = mkOption {...}; - } - ``` - */ - 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 { - freeformType = anything; - options = opts; - }; - }; }