fix(config): make lazyvim.json idempotent, pretty-printed and remove full paths
This commit is contained in:
@ -130,7 +130,7 @@ local defaults = {
|
||||
M.json = {
|
||||
data = {
|
||||
version = nil, ---@type string?
|
||||
hashes = {}, ---@type table<string, string>
|
||||
news = {}, ---@type table<string, string>
|
||||
extras = {}, ---@type string[]
|
||||
},
|
||||
}
|
||||
@ -144,6 +144,11 @@ function M.json.load()
|
||||
local ok, json = pcall(vim.json.decode, data, { luanil = { object = true, array = true } })
|
||||
if ok then
|
||||
M.json.data = vim.tbl_deep_extend("force", M.json.data, json or {})
|
||||
if M.json.data.hashes then
|
||||
---@diagnostic disable-next-line: no-unknown
|
||||
M.json.data.hashes = nil
|
||||
M.json.save()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -152,7 +157,7 @@ function M.json.save()
|
||||
local path = vim.fn.stdpath("config") .. "/lazyvim.json"
|
||||
local f = io.open(path, "w")
|
||||
if f then
|
||||
f:write(vim.json.encode(M.json.data))
|
||||
f:write(Util.json.encode(M.json.data))
|
||||
f:close()
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user