mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-13 02:44:39 +02:00
fix(config): make lazyvim.json idempotent, pretty-printed and remove full paths
This commit is contained in:
parent
7d9a395565
commit
2a0b7a88ba
4 changed files with 59 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue