types/plugins: mkPluginSetupOption' with more control

This commit is contained in:
poz 2026-05-11 03:12:48 +02:00
parent 7d6909af19
commit 04e4fee620
No known key found for this signature in database
2 changed files with 34 additions and 31 deletions

View file

@ -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;

View file

@ -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;
};
};
}