From e3e14dbe1d515d25388c7149a2e5e52da5736608 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Mon, 12 Feb 2024 16:11:34 +0100 Subject: [PATCH] helpers/options: add mkSettingsOption --- lib/options.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/options.nix b/lib/options.nix index 1f242da1..b75bd9f0 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -237,4 +237,31 @@ with nixvimUtils; rec { inherit default; description = "Plugin to use for ${name}"; }; + + mkSettingsOption = { + options ? {}, + description, + example ? null, + }: + mkOption { + type = with types; + submodule { + freeformType = with types; attrsOf anything; + inherit options; + }; + default = {}; + inherit description; + example = + if example == null + then { + foo_bar = 42; + hostname = "localhost:8080"; + callback.__raw = '' + function() + print('nixvim') + end + ''; + } + else example; + }; }