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
|
||||
else if allowRawValues && value ? __raw then
|
||||
value
|
||||
else if isDerivation value then
|
||||
value
|
||||
else if isList value then
|
||||
let
|
||||
needsFiltering = removeNullListEntries || removeEmptyListEntries;
|
||||
|
@ -205,8 +207,8 @@ rec {
|
|||
builtins.toJSON v
|
||||
else if isBool v then
|
||||
boolToString v
|
||||
else if isPath v then
|
||||
go indent (toString v)
|
||||
else if isPath v || isDerivation v then
|
||||
go indent "${v}"
|
||||
else if isString v then
|
||||
# TODO: support lua's escape sequences, literal string, and content-appropriate quote style
|
||||
# See https://www.lua.org/pil/2.4.html
|
||||
|
@ -217,8 +219,6 @@ rec {
|
|||
"{ }"
|
||||
else if isFunction v then
|
||||
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
|
||||
"{" + introSpace + concatMapStringsSep ("," + introSpace) (go (indent + " ")) v + outroSpace + "}"
|
||||
else if isAttrs v then
|
||||
|
|
|
@ -45,6 +45,8 @@ let
|
|||
];
|
||||
};
|
||||
|
||||
drv = pkgs.writeText "example-derivation" "hello, world!";
|
||||
|
||||
results = pkgs.lib.runTests {
|
||||
testToLuaObject = {
|
||||
expr = helpers.toLuaObject {
|
||||
|
@ -124,6 +126,23 @@ let
|
|||
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 = {
|
||||
expr = helpers.toLuaObject {
|
||||
a = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue