From 167167e4b371a07e4388fb4a2dc71fdcd72731ad Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Tue, 17 Dec 2024 18:13:02 +0100 Subject: [PATCH] lib/vim-plugin: expose new helpers `settingsOptionDescription` and `processPrefixedGlobals` and `mkSettingsOption` --- lib/vim-plugin.nix | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/lib/vim-plugin.nix b/lib/vim-plugin.nix index b5060486..6d56aced 100644 --- a/lib/vim-plugin.nix +++ b/lib/vim-plugin.nix @@ -1,5 +1,29 @@ { 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 = { name, @@ -36,18 +60,10 @@ createSettingsOption = (lib.isString globalPrefix) && (globalPrefix != ""); settingsOption = lib.optionalAttrs createSettingsOption { - settings = lib.nixvim.mkSettingsOption { + settings = mkSettingsOption { options = settingsOptions; example = settingsExample; - description = '' - 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` - ''; + inherit name globalPrefix; }; };