mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-25 13:14:37 +02:00
plugins: Introduce helpers.defaultNullOpts.mkLuaFn (#855)
This allows to avoid calling `mkRaw` on lua functions, as they will get applied automatically. This could also help in the future to refactor the use of Lua code to make it more user-friendly.
This commit is contained in:
parent
b38dbdb0dc
commit
1d8e7906c9
30 changed files with 140 additions and 119 deletions
|
@ -140,6 +140,33 @@ with lib; rec {
|
|||
# documentation
|
||||
mkNullableWithRaw = type: mkNullable (maybeRaw type);
|
||||
|
||||
mkLuaFn = default: desc:
|
||||
lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
description = let
|
||||
defaultDesc = ''
|
||||
default:
|
||||
```lua
|
||||
${default}
|
||||
```
|
||||
'';
|
||||
in
|
||||
if desc == ""
|
||||
then ''
|
||||
(lua function)
|
||||
|
||||
${defaultDesc}
|
||||
''
|
||||
else ''
|
||||
${desc}
|
||||
|
||||
(lua function)
|
||||
|
||||
${defaultDesc}
|
||||
'';
|
||||
apply = mkRaw;
|
||||
};
|
||||
mkNum = default: mkNullable (maybeRaw lib.types.number) (toString default);
|
||||
mkInt = default: mkNullable (maybeRaw lib.types.int) (toString default);
|
||||
# Positive: >0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue