switching from handling plugin downloading on our own to use vim.pack

This commit is contained in:
Squibid 2026-01-01 14:34:49 -05:00
parent 70853bd01e
commit 9b19b61372
Signed by: squibid
GPG key ID: BECE5684D3C4005D
14 changed files with 26 additions and 802 deletions

View file

@ -1,19 +1,12 @@
local logger = require("dep.log")
local git = require("dep.git")
local fs = require("dep.fs")
local packager = require("dep.package")
local modules = require("dep.modules")
local bench = require("dep.bench")
local lazy = require("dep.lazy")
local ui = require("dep.ui")
-- all functions for convenience
local M = {}
-- TODO: maybe add the ability to get a lockfile? it's useful to make a config
-- rebuildable, but idk if it's actually useful for a neovim config
-- (look into how ofter people who use lazy.nvim us it)
--- sync a tree of plugins
---@param tree package[] tree of plugins
---@param cb function? callback
@ -32,9 +25,8 @@ local function synctree(tree, cb)
logger:log("update", "synchronized %s %s", #tree, #tree == 1 and "package" or "packages")
end
fs:clean(packager)
for _, package in pairs(tree) do
package:reload()
for _, p in pairs(tree) do
p:reload()
end
if cb then
@ -43,18 +35,20 @@ local function synctree(tree, cb)
end
end
for _, package in pairs(tree) do
local co = coroutine.create(function()
-- if the package provided prefers a local source then use the local
-- source instead of the git repository
if package.path then
fs:sync(package, done)
else
git.sync(package, done)
end
end)
coroutine.resume(co)
-- convert our spec to vim.pack.Spec
local vimspecs = {}
for _, p in ipairs(tree) do
table.insert(vimspecs, {
name = p.name,
src = p.path or p.url,
version = p.commit or p.branch
})
end
vim.pack.add(vimspecs, {
load = done,
confirm = false,
})
end
--- check if a package should be synced
@ -100,7 +94,7 @@ return function(opts)
local root = packager:new({
"squibid/dep",
url = "https://git.squi.bid/squibid/dep.git",
branch = "lazy"
branch = "pack"
})
if not root then
logger:log("error", "couldn't register root package")
@ -157,21 +151,4 @@ return function(opts)
package:reload()
end
end, {})
vim.api.nvim_create_user_command("DepClean", function()
-- clean AND reload to make sure that all old packages are gone
fs:clean(packager)
end, {})
vim.api.nvim_create_user_command("DepUi", function()
ui.open(packager)
ui.set_page("P")
end, {})
vim.api.nvim_create_user_command("DepLog", function()
ui.open(packager)
ui.set_page("L")
end, {})
logger:cleanup()
end