configure packages after install
This commit is contained in:
parent
09f1ae6854
commit
903d62befb
1 changed files with 21 additions and 18 deletions
39
lua/dep.lua
39
lua/dep.lua
|
|
@ -12,41 +12,44 @@ local M = {}
|
||||||
---@param cb function? callback
|
---@param cb function? callback
|
||||||
local function synctree(tree, cb)
|
local function synctree(tree, cb)
|
||||||
local progress = 0
|
local progress = 0
|
||||||
local has_errors = false
|
|
||||||
|
|
||||||
local function done(err)
|
---@param spec vim.pack.Spec
|
||||||
|
---@param path string
|
||||||
|
local function done(spec, path)
|
||||||
|
---@type package
|
||||||
|
local p = spec.data
|
||||||
|
_ = path
|
||||||
progress = progress + 1
|
progress = progress + 1
|
||||||
has_errors = has_errors or err
|
|
||||||
|
|
||||||
if progress == #tree then
|
local info = vim.pack.get({ spec.name }, { info = false })[1]
|
||||||
if has_errors then
|
if info.active then
|
||||||
logger:log("error", "there were errors during sync; see :messages or :DepLog for more information")
|
p.exists = true
|
||||||
else
|
p:unconfiguretree()
|
||||||
logger:log("update", "synchronized %s %s", #tree, #tree == 1 and "package" or "packages")
|
p:runhooks("on_config")
|
||||||
end
|
logger:log("config", "package: %s configured", p.id)
|
||||||
|
p.configured = true
|
||||||
for _, p in pairs(tree) do
|
|
||||||
p:reload()
|
|
||||||
end
|
|
||||||
|
|
||||||
if cb then
|
|
||||||
cb()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- convert our spec to vim.pack.Spec
|
-- convert our spec to vim.pack.Spec
|
||||||
|
---@type vim.pack.Spec[]
|
||||||
local vimspecs = {}
|
local vimspecs = {}
|
||||||
for _, p in ipairs(tree) do
|
for _, p in ipairs(tree) do
|
||||||
table.insert(vimspecs, {
|
table.insert(vimspecs, {
|
||||||
name = p.name,
|
name = p.name,
|
||||||
src = p.path or p.url,
|
src = p.path or p.url,
|
||||||
version = p.commit or p.branch
|
version = p.commit or p.branch,
|
||||||
|
data = p,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- install/update all packages
|
||||||
vim.pack.add(vimspecs, { load = done, confirm = false })
|
vim.pack.add(vimspecs, { load = done, confirm = false })
|
||||||
vim.pack.update(vimspecs, { force = true })
|
vim.pack.update(vimspecs, { force = true })
|
||||||
|
|
||||||
|
-- reload all packages
|
||||||
|
tree[1].get_root():reload()
|
||||||
|
if cb then cb() end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- check if a package should be synced
|
--- check if a package should be synced
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue