mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-06-28 11:24:14 +00:00
deps_of_all_optional: Second, also disable unneeded deps from plugins marked as all optional
This commit is contained in:
parent
bbfcd98ce8
commit
aa8a33218b
1 changed files with 13 additions and 3 deletions
|
@ -185,6 +185,7 @@ function Spec:fix_cond()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Spec:fix_optional()
|
function Spec:fix_optional()
|
||||||
|
local all_optional_deps = {}
|
||||||
if not self.optional then
|
if not self.optional then
|
||||||
---@param plugin LazyPlugin
|
---@param plugin LazyPlugin
|
||||||
local function all_optional(plugin)
|
local function all_optional(plugin)
|
||||||
|
@ -195,9 +196,13 @@ function Spec:fix_optional()
|
||||||
for _, plugin in pairs(self.plugins) do
|
for _, plugin in pairs(self.plugins) do
|
||||||
if plugin.optional and all_optional(plugin) then
|
if plugin.optional and all_optional(plugin) then
|
||||||
self.plugins[plugin.name] = nil
|
self.plugins[plugin.name] = nil
|
||||||
|
if plugin.dependencies then
|
||||||
|
vim.list_extend(all_optional_deps, plugin.dependencies)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return all_optional_deps
|
||||||
end
|
end
|
||||||
|
|
||||||
function Spec:fix_disabled()
|
function Spec:fix_disabled()
|
||||||
|
@ -208,15 +213,16 @@ function Spec:fix_disabled()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:fix_optional()
|
|
||||||
self:fix_cond()
|
|
||||||
|
|
||||||
---@type table<string,string[]> plugin to parent plugin
|
---@type table<string,string[]> plugin to parent plugin
|
||||||
local dep_of = {}
|
local dep_of = {}
|
||||||
|
|
||||||
---@type string[] dependencies of disabled plugins
|
---@type string[] dependencies of disabled plugins
|
||||||
local disabled_deps = {}
|
local disabled_deps = {}
|
||||||
|
|
||||||
|
---@type string[] dependencies of plugins that are all optional
|
||||||
|
local all_optional_deps = self:fix_optional()
|
||||||
|
self:fix_cond()
|
||||||
|
|
||||||
for _, plugin in pairs(self.plugins) do
|
for _, plugin in pairs(self.plugins) do
|
||||||
local enabled = not (plugin.enabled == false or (type(plugin.enabled) == "function" and not plugin.enabled()))
|
local enabled = not (plugin.enabled == false or (type(plugin.enabled) == "function" and not plugin.enabled()))
|
||||||
if enabled then
|
if enabled then
|
||||||
|
@ -234,6 +240,10 @@ function Spec:fix_disabled()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- fix deps of plugins that are all optional
|
||||||
|
self:fix_dependencies(all_optional_deps, dep_of, function(dep_name)
|
||||||
|
self.plugins[dep_name] = nil
|
||||||
|
end)
|
||||||
-- fix deps of disabled plugins
|
-- fix deps of disabled plugins
|
||||||
self:fix_dependencies(disabled_deps, dep_of, function(dep_name)
|
self:fix_dependencies(disabled_deps, dep_of, function(dep_name)
|
||||||
local plugin = self.plugins[dep_name]
|
local plugin = self.plugins[dep_name]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue