mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-27 03:09:07 +02:00
feat(config): lazyvim.json
is now versioned and migrates to a newer version when needed
This commit is contained in:
parent
8e71968c2b
commit
c9892652d2
3 changed files with 34 additions and 14 deletions
|
@ -128,6 +128,7 @@ local defaults = {
|
|||
}
|
||||
|
||||
M.json = {
|
||||
version = 1,
|
||||
data = {
|
||||
version = nil, ---@type string?
|
||||
news = {}, ---@type table<string, string>
|
||||
|
@ -144,24 +145,13 @@ 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()
|
||||
if M.json.data.version ~= M.json.version then
|
||||
Util.json.migrate()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M.json.save()
|
||||
local path = vim.fn.stdpath("config") .. "/lazyvim.json"
|
||||
local f = io.open(path, "w")
|
||||
if f then
|
||||
f:write(Util.json.encode(M.json.data))
|
||||
f:close()
|
||||
end
|
||||
end
|
||||
|
||||
---@type LazyVimOptions
|
||||
local options
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue