helpers: Add option helpers for types that are either a lua str or a value (#876)

Those types needed the following code in apply:

if builtins.isString value
then mkRaw value
else value

This commit avoids this boilerplate, and clarifies that the `str` is lua
code in the documentation.
This commit is contained in:
traxys 2024-01-02 00:30:10 +01:00 committed by GitHub
parent 8b8a1c0f4b
commit 8aa4b7e4ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 109 additions and 129 deletions

View file

@ -21,13 +21,8 @@ in {
'';
overrides =
helpers.defaultNullOpts.mkNullable
(
with types;
either
(attrsOf helpers.nixvimTypes.highlight)
str
)
helpers.defaultNullOpts.mkStrLuaOr
(with helpers.nixvimTypes; attrsOf highlight)
"{}"
''
A dictionary of group names, each associated with a dictionary of parameters
@ -44,10 +39,7 @@ in {
config = let
setupOptions = with cfg;
{
overrides =
if isString overrides
then helpers.mkRaw overrides
else overrides;
inherit overrides;
}
// cfg.extraOptions;
in