add possibility to skip variable definition
This commit is contained in:
parent
00364dee14
commit
61cd06db30
2 changed files with 7 additions and 1 deletions
4
lib.nix
4
lib.nix
|
@ -127,7 +127,9 @@ let
|
||||||
if isJoin expr && expr.sep == "." then expr
|
if isJoin expr && expr.sep == "." then expr
|
||||||
else if isRaw expr then expr
|
else if isRaw expr then expr
|
||||||
else raw (validString expr);
|
else raw (validString expr);
|
||||||
set = var: val: join " = " [ (validSetVariable var) val ];
|
set = var: val:
|
||||||
|
if val == null then null
|
||||||
|
else join " = " [ (validSetVariable var) val ];
|
||||||
|
|
||||||
# Type: validBlockBody :: a -> [b]
|
# Type: validBlockBody :: a -> [b]
|
||||||
validBlockBody = body:
|
validBlockBody = body:
|
||||||
|
|
|
@ -193,6 +193,10 @@ with nix2lua; pkgs.lib.runTests {
|
||||||
expr = toLua (lset "parser_config.d2" { });
|
expr = toLua (lset "parser_config.d2" { });
|
||||||
expected = "local parser_config.d2 = { }";
|
expected = "local parser_config.d2 = { }";
|
||||||
};
|
};
|
||||||
|
"test skips a var definition if value is null" = {
|
||||||
|
expr = toLua (set "vim.opt.number" null);
|
||||||
|
expected = null;
|
||||||
|
};
|
||||||
"test returns all operations" = {
|
"test returns all operations" = {
|
||||||
expr = toLua (spaceBetween [
|
expr = toLua (spaceBetween [
|
||||||
(set "a" (eq (mul (add 1 2) (sub 2 1)) 3))
|
(set "a" (eq (mul (add 1 2) (sub 2 1)) 3))
|
||||||
|
|
Loading…
Reference in a new issue