lib/vim-plugin: expose new helpers settingsOptionDescription and processPrefixedGlobals and mkSettingsOption

This commit is contained in:
Gaetan Lepage 2024-12-17 18:13:02 +01:00
parent 1d50fa4f63
commit 167167e4b3

View file

@ -1,5 +1,29 @@
{ lib }: { lib }:
{ rec {
mkSettingsOptionDescription =
{ name, globalPrefix }:
''
The configuration options for **${name}** without the `${globalPrefix}` prefix.
For example, the following settings are equivialent to these `:setglobal` commands:
- `foo_bar = 1` -> `:setglobal ${globalPrefix}foo_bar=1`
- `hello = "world"` -> `:setglobal ${globalPrefix}hello="world"`
- `some_toggle = true` -> `:setglobal ${globalPrefix}some_toggle`
- `other_toggle = false` -> `:setglobal no${globalPrefix}other_toggle`
'';
mkSettingsOption =
{
options ? { },
example ? { },
name,
globalPrefix,
}:
lib.nixvim.mkSettingsOption {
inherit options example;
description = mkSettingsOptionDescription { inherit name globalPrefix; };
};
mkVimPlugin = mkVimPlugin =
{ {
name, name,
@ -36,18 +60,10 @@
createSettingsOption = (lib.isString globalPrefix) && (globalPrefix != ""); createSettingsOption = (lib.isString globalPrefix) && (globalPrefix != "");
settingsOption = lib.optionalAttrs createSettingsOption { settingsOption = lib.optionalAttrs createSettingsOption {
settings = lib.nixvim.mkSettingsOption { settings = mkSettingsOption {
options = settingsOptions; options = settingsOptions;
example = settingsExample; example = settingsExample;
description = '' inherit name globalPrefix;
The configuration options for **${name}** without the `${globalPrefix}` prefix.
For example, the following settings are equivialent to these `:setglobal` commands:
- `foo_bar = 1` -> `:setglobal ${globalPrefix}foo_bar=1`
- `hello = "world"` -> `:setglobal ${globalPrefix}hello="world"`
- `some_toggle = true` -> `:setglobal ${globalPrefix}some_toggle`
- `other_toggle = false` -> `:setglobal no${globalPrefix}other_toggle`
'';
}; };
}; };