mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 02:11:33 +00:00
feat: improved smartcolumn freeform
This commit is contained in:
parent
2cfeb22764
commit
86fec8646d
4 changed files with 32 additions and 15 deletions
22
lib/lua.nix
22
lib/lua.nix
|
@ -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
|
||||
))
|
||||
)
|
||||
)
|
||||
+ " }";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue