Skip to content

Commit

Permalink
feat(config): load/save some data in lazyvim.json
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Oct 12, 2023
1 parent 7fb7948 commit 11d66e7
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lua/lazyvim/config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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, {
Expand Down

0 comments on commit 11d66e7

Please sign in to comment.