mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
lib/lua: only quote table keys when needed
This commit is contained in:
parent
01cf43dbaa
commit
00ce71f51a
2 changed files with 25 additions and 13 deletions
|
@ -47,16 +47,18 @@ rec {
|
|||
mapAttrsToList (
|
||||
n: v:
|
||||
let
|
||||
keyString =
|
||||
if n == "__emptyString" then
|
||||
"['']"
|
||||
else if hasPrefix "__rawKey__" n then
|
||||
"[${removePrefix "__rawKey__" n}]"
|
||||
else if isIdentifier n then
|
||||
n
|
||||
else
|
||||
"[${toLuaObject n}]";
|
||||
valueString = toLuaObject v;
|
||||
in
|
||||
if hasPrefix "__unkeyed" n then
|
||||
valueString
|
||||
else if hasPrefix "__rawKey__" n then
|
||||
''[${removePrefix "__rawKey__" n}] = '' + valueString
|
||||
else if n == "__emptyString" then
|
||||
"[''] = " + valueString
|
||||
else
|
||||
"[${toLuaObject n}] = " + valueString
|
||||
if hasPrefix "__unkeyed" n then valueString else "${keyString} = ${valueString}"
|
||||
) (filterAttrs (n: v: v != null && (toLuaObject v != "{}")) args)
|
||||
))
|
||||
+ "}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue