From 0dbfa8f4226c60432a9d775ed194ba334e5bedca Mon Sep 17 00:00:00 2001 From: schreifuchs Date: Wed, 6 Nov 2024 11:36:46 +0100 Subject: [PATCH] sorted toml for better git merge --- .timer.toml | 6 ++++-- .timer.toml.b | 11 +++++++++++ lua/toml.lua | 14 ++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 .timer.toml.b diff --git a/.timer.toml b/.timer.toml index aaa4746..e920487 100644 --- a/.timer.toml +++ b/.timer.toml @@ -1,9 +1,11 @@ ## dates and their corresponding seconds been here :) -[24-10-08] -u80864958_at_u80864958 = 425 [24-10-07] u80864958_at_u80864958 = 432 +[24-10-08] +u80864958_at_u80864958 = 425 [24-10-11] u80864958_at_u80864958 = 6021 [24-10-15] schreifuchs_at_archlinux = 128 +[24-11-06] +schreifuchs_at_archibald = 301 diff --git a/.timer.toml.b b/.timer.toml.b new file mode 100644 index 0000000..46ab767 --- /dev/null +++ b/.timer.toml.b @@ -0,0 +1,11 @@ +## dates and their corresponding seconds been here :) +[24-10-07] +u80864958_at_u80864958 = 432 +[24-10-08] +u80864958_at_u80864958 = 425 +[24-10-11] +u80864958_at_u80864958 = 6021 +[24-10-15] +schreifuchs_at_archlinux = 128 +[24-11-06] +schreifuchs_at_archibald = 18 diff --git a/lua/toml.lua b/lua/toml.lua index b1a34bc..e963872 100644 --- a/lua/toml.lua +++ b/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)