feat: improved smartcolumn freeform

This commit is contained in:
NotAShelf 2023-06-04 17:36:01 +03:00
commit 86fec8646d
No known key found for this signature in database
GPG key ID: F0D14CCB5ED5AA22
4 changed files with 32 additions and 15 deletions

View file

@ -12,21 +12,29 @@
then "nil"
else "'${value}'";
# Helper function to convert an attribute name to a Lua table key
attrToKey = name: name;
expToLua = exp:
if builtins.isList exp
then listToLuaTable exp
else if builtins.isAttrs exp
then attrsetToLuaTable exp
else ("\"" + builtins.toJSON exp + "\"");
listToLuaTable = list:
"{ " + (builtins.concatStringsSep ", " (map expToLua list)) + " }";
# Function to convert a Nix attrset to a Lua table
attrsetToLuaTable = attrset:
"{ "
+ (
builtins.concatStringsSep ", "
(builtins.attrValues (
builtins.mapAttrs (
(
lib.mapAttrsToList (
name: value:
attrToKey name + " = " + ("\"" + builtins.toJSON value + "\"")
name
+ " = "
+ (expToLua value)
)
attrset
))
)
)
+ " }";
}