sorted toml for better git merge
This commit is contained in:
14
lua/toml.lua
14
lua/toml.lua
@ -564,7 +564,17 @@ TOML.encode = function(tbl)
|
||||
local cache = {}
|
||||
|
||||
local function parse(tbl)
|
||||
for k, v in pairs(tbl) do
|
||||
local tbl_keys = {}
|
||||
for k in pairs(tbl) do
|
||||
table.insert(tbl_keys, k)
|
||||
end
|
||||
table.sort(tbl_keys)
|
||||
|
||||
|
||||
for _, k in pairs(tbl_keys) do
|
||||
local v = tbl[k]
|
||||
print(k)
|
||||
print(v)
|
||||
if type(v) == "boolean" then
|
||||
toml = toml .. k .. " = " .. tostring(v) .. "\n"
|
||||
elseif type(v) == "number" then
|
||||
@ -572,7 +582,7 @@ TOML.encode = function(tbl)
|
||||
elseif type(v) == "string" then
|
||||
local quote = '"'
|
||||
v = v:gsub("\\", "\\\\")
|
||||
|
||||
--
|
||||
-- if the string has any line breaks, make it multiline
|
||||
if v:match("^\n(.*)$") then
|
||||
quote = quote:rep(3)
|
||||
|
Reference in New Issue
Block a user