mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-12 18:34:36 +02:00
feat(config): load/save some data in lazyvim.json
This commit is contained in:
parent
058089d0d6
commit
739409cd4b
1 changed files with 30 additions and 0 deletions
|
@ -83,6 +83,35 @@ local defaults = {
|
|||
},
|
||||
}
|
||||
|
||||
M.json = {
|
||||
data = {
|
||||
version = nil, ---@type string?
|
||||
extras = {}, ---@type string[]
|
||||
},
|
||||
}
|
||||
|
||||
function M.json.load()
|
||||
local path = vim.fn.stdpath("config") .. "/lazyvim.json"
|
||||
local f = io.open(path, "r")
|
||||
if f then
|
||||
local data = f:read("*a")
|
||||
f:close()
|
||||
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 {})
|
||||
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(vim.json.encode(M.json.data))
|
||||
f:close()
|
||||
end
|
||||
end
|
||||
|
||||
---@type LazyVimOptions
|
||||
local options
|
||||
|
||||
|
@ -176,6 +205,7 @@ function M.init()
|
|||
Util.plugin.fix_imports()
|
||||
Util.plugin.fix_renames()
|
||||
Util.plugin.lazy_file()
|
||||
M.json.load()
|
||||
end
|
||||
|
||||
setmetatable(M, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue