mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
parent
34aa3e00e7
commit
6dc0bda459
2 changed files with 23 additions and 4 deletions
|
@ -141,6 +141,8 @@ rec {
|
||||||
value
|
value
|
||||||
else if allowRawValues && value ? __raw then
|
else if allowRawValues && value ? __raw then
|
||||||
value
|
value
|
||||||
|
else if isDerivation value then
|
||||||
|
value
|
||||||
else if isList value then
|
else if isList value then
|
||||||
let
|
let
|
||||||
needsFiltering = removeNullListEntries || removeEmptyListEntries;
|
needsFiltering = removeNullListEntries || removeEmptyListEntries;
|
||||||
|
@ -205,8 +207,8 @@ rec {
|
||||||
builtins.toJSON v
|
builtins.toJSON v
|
||||||
else if isBool v then
|
else if isBool v then
|
||||||
boolToString v
|
boolToString v
|
||||||
else if isPath v then
|
else if isPath v || isDerivation v then
|
||||||
go indent (toString v)
|
go indent "${v}"
|
||||||
else if isString v then
|
else if isString v then
|
||||||
# TODO: support lua's escape sequences, literal string, and content-appropriate quote style
|
# TODO: support lua's escape sequences, literal string, and content-appropriate quote style
|
||||||
# See https://www.lua.org/pil/2.4.html
|
# See https://www.lua.org/pil/2.4.html
|
||||||
|
@ -217,8 +219,6 @@ rec {
|
||||||
"{ }"
|
"{ }"
|
||||||
else if isFunction v then
|
else if isFunction v then
|
||||||
abort "nixvim(toLua): Unexpected function: " + generators.toPretty { } v
|
abort "nixvim(toLua): Unexpected function: " + generators.toPretty { } v
|
||||||
else if isDerivation v then
|
|
||||||
abort "nixvim(toLua): Unexpected derivation: " + generators.toPretty { } v
|
|
||||||
else if isList v then
|
else if isList v then
|
||||||
"{" + introSpace + concatMapStringsSep ("," + introSpace) (go (indent + " ")) v + outroSpace + "}"
|
"{" + introSpace + concatMapStringsSep ("," + introSpace) (go (indent + " ")) v + outroSpace + "}"
|
||||||
else if isAttrs v then
|
else if isAttrs v then
|
||||||
|
|
|
@ -45,6 +45,8 @@ let
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
drv = pkgs.writeText "example-derivation" "hello, world!";
|
||||||
|
|
||||||
results = pkgs.lib.runTests {
|
results = pkgs.lib.runTests {
|
||||||
testToLuaObject = {
|
testToLuaObject = {
|
||||||
expr = helpers.toLuaObject {
|
expr = helpers.toLuaObject {
|
||||||
|
@ -124,6 +126,23 @@ let
|
||||||
expected = ''"foo\\bar\nbaz"'';
|
expected = ''"foo\\bar\nbaz"'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
testToLuaObjectDerivation = {
|
||||||
|
expr = helpers.toLuaObject drv;
|
||||||
|
expected = ''"${drv}"'';
|
||||||
|
};
|
||||||
|
|
||||||
|
testToLuaObjectDerivationNested = {
|
||||||
|
expr = helpers.toLuaObject {
|
||||||
|
a = drv;
|
||||||
|
b = {
|
||||||
|
c = drv;
|
||||||
|
};
|
||||||
|
d = [ drv ];
|
||||||
|
e = [ { f = drv; } ];
|
||||||
|
};
|
||||||
|
expected = ''{ a = "${drv}", b = { c = "${drv}" }, d = { "${drv}" }, e = { { f = "${drv}" } } }'';
|
||||||
|
};
|
||||||
|
|
||||||
testToLuaObjectFilters = {
|
testToLuaObjectFilters = {
|
||||||
expr = helpers.toLuaObject {
|
expr = helpers.toLuaObject {
|
||||||
a = null;
|
a = null;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue