1
0

Do not checkout git commit on lazy.nvim setup

This commit is contained in:
Patrick Auernig 2025-02-14 14:46:58 +01:00
parent 7a7b38bce3
commit 3c116413e4

View File

@ -1,50 +1,22 @@
local uv = vim.loop
local function locked_commit()
local lockfile_path = vim.fn.stdpath("config") .. "/lazy-lock.json"
local lockfile = io.open(lockfile_path, "r")
if not lockfile then
return nil
end
local text = lockfile:read("*all")
lockfile:close()
local json = vim.json.decode(text)
return json["lazy.nvim"]["commit"]
end
local function checkout_commit(path)
local commit = locked_commit()
if not commit then
return
end
uv.spawn("git", {
args = { "checkout", commit },
cwd = path
})
end
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ local output = vim.fn.system({
"git", "git",
"clone", "clone",
"--filter=blob:none", "--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", "--branch=stable",
"https://github.com/folke/lazy.nvim.git",
lazypath, lazypath,
}) })
checkout_commit(lazypath) if vim.v.shell_error ~= 0 then
vim.wait(1) vim.notify("Failed to clone lazy.nvim", vim.log.levels.ERROR)
vim.notify(output, vim.log.levels.ERROR)
vim.fn.getchar()
os.exit(1)
end
vim.notify("Installed lazy.nvim") vim.notify("Installed lazy.nvim")
end end