1
0

Make sure lazy setup is using the locked commit

This commit is contained in:
Patrick Auernig 2023-09-03 23:41:31 +02:00
parent c0039f4a4c
commit c18ee3cd1b
2 changed files with 54 additions and 21 deletions

View File

@ -1,23 +1,3 @@
require("valeth.options")
require("valeth.keymaps")
local function lazy_setup()
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup("valeth.plugins")
end
lazy_setup()
require("valeth.lazy")

53
lua/valeth/lazy.lua Normal file
View File

@ -0,0 +1,53 @@
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"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
checkout_commit(lazypath)
vim.wait(1)
vim.notify("Installed lazy.nvim")
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup("valeth.plugins")