This commit is contained in:
Christian Nieves
2022-12-22 21:34:02 +00:00
parent 396b23be3b
commit 5908112f1b
3 changed files with 87 additions and 1 deletions

View File

@ -30,4 +30,37 @@ function M.dump(o)
end
end
function M.tprint (tbl, indent)
if not indent then indent = 0 end
local toprint = string.rep(" ", indent) .. "{\r\n"
indent = indent + 2
for k, v in pairs(tbl) do
toprint = toprint .. string.rep(" ", indent)
if (type(k) == "number") then
toprint = toprint .. "[" .. k .. "] = "
elseif (type(k) == "string") then
toprint = toprint .. k .. "= "
end
if (type(v) == "number") then
toprint = toprint .. v .. ",\r\n"
elseif (type(v) == "string") then
toprint = toprint .. "\"" .. v .. "\",\r\n"
elseif (type(v) == "table") then
toprint = toprint .. M.tprint(v, indent + 2) .. ",\r\n"
else
toprint = toprint .. "\"" .. tostring(v) .. "\",\r\n"
end
end
toprint = toprint .. string.rep(" ", indent-2) .. "}"
return toprint
end
function M.log(message)
local log_file_path = vim.fn.expand('$HOME/nvim.log')
local log_file = io.open(log_file_path, "a")
io.output(log_file)
io.write(message.."\n")
io.close(log_file)
end
return M