mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-24 09:48:42 +02:00
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:
parent
8b8a1c0f4b
commit
8aa4b7e4ce
13 changed files with 109 additions and 129 deletions
|
@ -219,8 +219,7 @@ in {
|
|||
'';
|
||||
|
||||
transformExplicit =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; either str (enum [false]))
|
||||
helpers.defaultNullOpts.mkStrLuaFnOr (types.enum [false])
|
||||
"false"
|
||||
''
|
||||
A function that transforms the text to be inserted as the source/path of a link when a
|
||||
|
@ -241,8 +240,7 @@ in {
|
|||
'';
|
||||
|
||||
transformImplicit =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; either str (enum [false]))
|
||||
helpers.defaultNullOpts.mkStrLuaFnOr (types.enum [false])
|
||||
''
|
||||
function(text)
|
||||
text = text:gsub(" ", "-")
|
||||
|
@ -578,14 +576,8 @@ in {
|
|||
context
|
||||
;
|
||||
implicit_extension = implicitExtension;
|
||||
transform_implicit =
|
||||
if isString transformImplicit
|
||||
then helpers.mkRaw transformImplicit
|
||||
else transformImplicit;
|
||||
transform_explicit =
|
||||
if isString transformExplicit
|
||||
then helpers.mkRaw transformExplicit
|
||||
else transformExplicit;
|
||||
transform_implicit = transformImplicit;
|
||||
transform_explicit = transformExplicit;
|
||||
};
|
||||
to_do = with toDo; {
|
||||
inherit symbols;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue