Fix recursive subtree configuration not being optimized after the first run
This commit is contained in:
69
lua/dep.lua
Normal file → Executable file
69
lua/dep.lua
Normal file → Executable file
@ -67,7 +67,6 @@ local function register(spec, overrides)
|
|||||||
|
|
||||||
local prev_dir = package.dir -- optimization
|
local prev_dir = package.dir -- optimization
|
||||||
|
|
||||||
-- meta
|
|
||||||
package.name = spec.as or package.name or get_name(id)
|
package.name = spec.as or package.name or get_name(id)
|
||||||
package.url = spec.url or package.url or ("https://github.com/" .. id .. ".git")
|
package.url = spec.url or package.url or ("https://github.com/" .. id .. ".git")
|
||||||
package.branch = spec.branch or package.branch
|
package.branch = spec.branch or package.branch
|
||||||
@ -229,7 +228,7 @@ local function ensure_acyclic()
|
|||||||
for i = 1, #cycle do
|
for i = 1, #cycle do
|
||||||
names[i] = cycle[i].id
|
names[i] = cycle[i].id
|
||||||
end
|
end
|
||||||
error("circular dependency detected in package graph: " .. table.concat(names, " -> "))
|
error("circular dependency detected in package dependency graph: " .. table.concat(names, " -> "))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -285,10 +284,14 @@ local function ensure_added(package)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function configure_recursive(package)
|
local function configure_recursive(package)
|
||||||
if not package.exists or not package.enabled or package.error or package.subtree_configured then
|
if not package.exists or not package.enabled or package.error then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if package.subtree_configured then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
for i = 1, #package.dependencies do
|
for i = 1, #package.dependencies do
|
||||||
if not package.dependencies[i].configured then
|
if not package.dependencies[i].configured then
|
||||||
return
|
return
|
||||||
@ -322,10 +325,14 @@ local function configure_recursive(package)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function load_recursive(package)
|
local function load_recursive(package)
|
||||||
if not package.exists or not package.enabled or package.error or package.subtree_loaded then
|
if not package.exists or not package.enabled or package.error then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if package.subtree_loaded then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
for i = 1, #package.dependencies do
|
for i = 1, #package.dependencies do
|
||||||
if not package.dependencies[i].loaded then
|
if not package.dependencies[i].loaded then
|
||||||
return
|
return
|
||||||
@ -359,21 +366,22 @@ local function load_recursive(package)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function reload_meta()
|
local function reload_meta()
|
||||||
|
local ok, err
|
||||||
bench("meta", function()
|
bench("meta", function()
|
||||||
local ok, err = pcall(
|
ok, err = pcall(
|
||||||
vim.cmd,
|
vim.cmd,
|
||||||
[[
|
[[
|
||||||
silent! helptags ALL
|
silent! helptags ALL
|
||||||
silent! UpdateRemotePlugins
|
silent! UpdateRemotePlugins
|
||||||
]]
|
]]
|
||||||
)
|
)
|
||||||
|
end)
|
||||||
|
|
||||||
if ok then
|
if ok then
|
||||||
logger:log("vim", "reloaded helptags and remote plugins")
|
logger:log("vim", "reloaded helptags and remote plugins")
|
||||||
else
|
else
|
||||||
logger:log("error", string.format("failed to reload helptags and remote plugins; reason: %s", err))
|
logger:log("error", string.format("failed to reload helptags and remote plugins; reason: %s", err))
|
||||||
end
|
end
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function reload()
|
local function reload()
|
||||||
@ -580,7 +588,7 @@ local function print_list(cb)
|
|||||||
local concat = {}
|
local concat = {}
|
||||||
local column = 0
|
local column = 0
|
||||||
|
|
||||||
for i = 1, indent do
|
for _ = 1, indent do
|
||||||
concat[#concat + 1] = " "
|
concat[#concat + 1] = " "
|
||||||
column = column + 2
|
column = column + 2
|
||||||
end
|
end
|
||||||
@ -627,28 +635,28 @@ local function print_list(cb)
|
|||||||
|
|
||||||
loaded[package.id], loaded[#loaded + 1] = true, package
|
loaded[package.id], loaded[#loaded + 1] = true, package
|
||||||
|
|
||||||
local line = {
|
local chunk = {
|
||||||
{ string.format("[%s] ", commits[package.id] or " "), "Comment" },
|
{ string.format("[%s] ", commits[package.id] or " "), "Comment" },
|
||||||
{ package.id, "Underlined" },
|
{ package.id, "Underlined" },
|
||||||
}
|
}
|
||||||
|
|
||||||
if not package.exists then
|
if not package.exists then
|
||||||
line[#line + 1] = { " *not installed", "Comment" }
|
chunk[#chunk + 1] = { " *not installed", "Comment" }
|
||||||
end
|
end
|
||||||
|
|
||||||
if not package.loaded then
|
if not package.loaded then
|
||||||
line[#line + 1] = { " *not loaded", "Comment" }
|
chunk[#chunk + 1] = { " *not loaded", "Comment" }
|
||||||
end
|
end
|
||||||
|
|
||||||
if not package.enabled then
|
if not package.enabled then
|
||||||
line[#line + 1] = { " *disabled", "Comment" }
|
chunk[#chunk + 1] = { " *disabled", "Comment" }
|
||||||
end
|
end
|
||||||
|
|
||||||
if package.pin then
|
if package.pin then
|
||||||
line[#line + 1] = { " *pinned", "Comment" }
|
chunk[#chunk + 1] = { " *pinned", "Comment" }
|
||||||
end
|
end
|
||||||
|
|
||||||
print(line)
|
print(chunk)
|
||||||
|
|
||||||
for i = 1, #package.dependents do
|
for i = 1, #package.dependents do
|
||||||
dry_load(package.dependents[i])
|
dry_load(package.dependents[i])
|
||||||
@ -686,8 +694,8 @@ local function print_list(cb)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, #profile do
|
for j = 1, #profile do
|
||||||
profile.total = profile.total + profile[profile[i]]
|
profile.total = profile.total + profile[profile[j]]
|
||||||
end
|
end
|
||||||
|
|
||||||
profiles[#profiles + 1] = profile
|
profiles[#profiles + 1] = profile
|
||||||
@ -699,19 +707,19 @@ local function print_list(cb)
|
|||||||
|
|
||||||
for i = 1, #profiles do
|
for i = 1, #profiles do
|
||||||
local profile = profiles[i]
|
local profile = profiles[i]
|
||||||
local line = {
|
local chunk = {
|
||||||
{ "- ", "Comment" },
|
{ "- ", "Comment" },
|
||||||
{ profile.package.id, "Underlined" },
|
{ profile.package.id, "Underlined" },
|
||||||
{ string.rep(" ", 40 - #profile.package.id) },
|
{ string.rep(" ", 40 - #profile.package.id) },
|
||||||
}
|
}
|
||||||
|
|
||||||
for i = 1, #profile do
|
for j = 1, #profile do
|
||||||
local key, value = profile[i], profile[profile[i]]
|
local key, value = profile[j], profile[profile[j]]
|
||||||
line[#line + 1] = { string.format(" %5s ", key), "Comment" }
|
chunk[#chunk + 1] = { string.format(" %5s ", key), "Comment" }
|
||||||
line[#line + 1] = { string.format("%4d", value * 1000000) }
|
chunk[#chunk + 1] = { string.format("%4d", value * 1000000) }
|
||||||
end
|
end
|
||||||
|
|
||||||
print(line)
|
print(chunk)
|
||||||
end
|
end
|
||||||
|
|
||||||
indent = 0
|
indent = 0
|
||||||
@ -719,24 +727,25 @@ local function print_list(cb)
|
|||||||
print("Dependency graph:")
|
print("Dependency graph:")
|
||||||
|
|
||||||
local function walk_graph(package)
|
local function walk_graph(package)
|
||||||
local line = {
|
local chunk = {
|
||||||
{ "| ", "Comment" },
|
{ "| ", "Comment" },
|
||||||
{ package.id, "Underlined" },
|
{ package.id, "Underlined" },
|
||||||
}
|
}
|
||||||
|
|
||||||
local function add_edges(package)
|
local function add_edges(p)
|
||||||
for i = 1, #package.dependencies do
|
for i = 1, #p.dependencies do
|
||||||
local dependency = package.dependencies[i]
|
local dependency = p.dependencies[i]
|
||||||
|
|
||||||
if dependency ~= root then -- don't convolute the list
|
if dependency ~= root and not chunk[dependency.id] then -- don't convolute the list
|
||||||
line[#line + 1] = { " " .. dependency.id, "Comment" }
|
chunk[#chunk + 1] = { " " .. dependency.id, "Comment" }
|
||||||
|
chunk[dependency.id] = true
|
||||||
add_edges(dependency)
|
add_edges(dependency)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
add_edges(package)
|
add_edges(package)
|
||||||
print(line)
|
print(chunk)
|
||||||
|
|
||||||
for i = 1, #package.dependents do
|
for i = 1, #package.dependents do
|
||||||
indent = indent + 1
|
indent = indent + 1
|
||||||
@ -809,9 +818,11 @@ return setmetatable({
|
|||||||
vim.cmd("sp " .. config_path)
|
vim.cmd("sp " .. config_path)
|
||||||
end),
|
end),
|
||||||
}, {
|
}, {
|
||||||
__call = function(self, config)
|
__call = function(_, config)
|
||||||
|
local err
|
||||||
perf = {}
|
perf = {}
|
||||||
config_path = debug.getinfo(2, "S").source:sub(2)
|
config_path = debug.getinfo(2, "S").source:sub(2)
|
||||||
|
|
||||||
initialized, err = pcall(function()
|
initialized, err = pcall(function()
|
||||||
base_dir = config.base_dir or (vim.fn.stdpath("data") .. "/site/pack/deps/opt/")
|
base_dir = config.base_dir or (vim.fn.stdpath("data") .. "/site/pack/deps/opt/")
|
||||||
packages = {}
|
packages = {}
|
||||||
|
0
lua/dep/log.lua
Normal file → Executable file
0
lua/dep/log.lua
Normal file → Executable file
0
lua/dep/proc.lua
Normal file → Executable file
0
lua/dep/proc.lua
Normal file → Executable file
0
stylua.toml
Normal file → Executable file
0
stylua.toml
Normal file → Executable file
Reference in New Issue
Block a user