From 59b2e6b17c0233eeb08b4c5aa805724c03b47bc3 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Wed, 3 Jan 2024 00:54:49 +0100 Subject: [PATCH] internal: add customizable plugin setup option --- lib/types/default.nix | 2 +- lib/types/plugins.nix | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/types/default.nix b/lib/types/default.nix index bfaa38d..59a5181 100644 --- a/lib/types/default.nix +++ b/lib/types/default.nix @@ -4,6 +4,6 @@ typesLanguage = import ./languages.nix {inherit lib;}; in { inherit (typesDag) dagOf; - inherit (typesPlugin) pluginsOpt extraPluginType; + inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption; inherit (typesLanguage) diagnostics mkGrammarOption; } diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index ee33a42..bcc1dda 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -138,4 +138,25 @@ in { inherit description default; type = pluginsType; }; + + # 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; + default = {}; + type = types.submodule { + freeformType = with types; attrsOf anything; + options = opts; + }; + }; }