mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-06-28 19:34:15 +00:00
prioritize plugin cond
- loader: Don't enable plugin's lazy loaders if plugin's condition isn't met - manage: Only Check for updates if plugin's condition is met - view: Don't show lazy loader details for disabled plugins
This commit is contained in:
parent
4739c2d95a
commit
916ac4a4b0
4 changed files with 20 additions and 11 deletions
|
@ -42,9 +42,20 @@ end
|
||||||
---@param plugin LazyPlugin
|
---@param plugin LazyPlugin
|
||||||
function M.enable(plugin)
|
function M.enable(plugin)
|
||||||
if not plugin._.loaded then
|
if not plugin._.loaded then
|
||||||
for type, handler in pairs(M.handlers) do
|
local cond = type(plugin.cond) == "function" and plugin.cond
|
||||||
if plugin[type] then
|
or function()
|
||||||
handler:add(plugin)
|
if plugin.cond == nil then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return plugin.cond
|
||||||
|
end
|
||||||
|
|
||||||
|
plugin._.cond = cond()
|
||||||
|
if plugin._.cond then
|
||||||
|
for type, handler in pairs(M.handlers) do
|
||||||
|
if plugin[type] then
|
||||||
|
handler:add(plugin)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -131,7 +131,7 @@ function M.check(opts)
|
||||||
{ "git.log", check = true },
|
{ "git.log", check = true },
|
||||||
},
|
},
|
||||||
plugins = function(plugin)
|
plugins = function(plugin)
|
||||||
return plugin.url and plugin._.installed
|
return plugin.url and plugin._.installed and plugin._.cond
|
||||||
end,
|
end,
|
||||||
}, opts)
|
}, opts)
|
||||||
end
|
end
|
||||||
|
|
|
@ -397,7 +397,7 @@ function M:plugin(plugin)
|
||||||
local plugin_start = self:row()
|
local plugin_start = self:row()
|
||||||
if plugin._.loaded then
|
if plugin._.loaded then
|
||||||
self:reason(plugin._.loaded)
|
self:reason(plugin._.loaded)
|
||||||
else
|
elseif plugin._.cond then
|
||||||
self:append(" ")
|
self:append(" ")
|
||||||
local reason = {}
|
local reason = {}
|
||||||
for handler in pairs(Handler.types) do
|
for handler in pairs(Handler.types) do
|
||||||
|
|
|
@ -13,7 +13,7 @@ end
|
||||||
---@alias LazySection {title:string, filter:fun(plugin:LazyPlugin):boolean?}
|
---@alias LazySection {title:string, filter:fun(plugin:LazyPlugin):boolean?}
|
||||||
|
|
||||||
---@type LazySection[]
|
---@type LazySection[]
|
||||||
return {
|
local sections = {
|
||||||
{
|
{
|
||||||
filter = function(plugin)
|
filter = function(plugin)
|
||||||
return has_task(plugin, function(task)
|
return has_task(plugin, function(task)
|
||||||
|
@ -47,21 +47,18 @@ return {
|
||||||
title = "Breaking Changes",
|
title = "Breaking Changes",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
---@param plugin LazyPlugin
|
|
||||||
filter = function(plugin)
|
filter = function(plugin)
|
||||||
return plugin._.updated and plugin._.updated.from ~= plugin._.updated.to
|
return plugin._.updated and plugin._.updated.from ~= plugin._.updated.to
|
||||||
end,
|
end,
|
||||||
title = "Updated",
|
title = "Updated",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
---@param plugin LazyPlugin
|
|
||||||
filter = function(plugin)
|
filter = function(plugin)
|
||||||
return plugin._.cloned
|
return plugin._.cloned
|
||||||
end,
|
end,
|
||||||
title = "Installed",
|
title = "Installed",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
---@param plugin LazyPlugin
|
|
||||||
filter = function(plugin)
|
filter = function(plugin)
|
||||||
return plugin._.updates
|
return plugin._.updates
|
||||||
end,
|
end,
|
||||||
|
@ -95,14 +92,15 @@ return {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filter = function(plugin)
|
filter = function(plugin)
|
||||||
return plugin._.installed
|
return plugin._.installed and plugin._.cond
|
||||||
end,
|
end,
|
||||||
title = "Not Loaded",
|
title = "Not Loaded",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filter = function(plugin)
|
filter = function(plugin)
|
||||||
return plugin._.kind == "disabled"
|
return plugin._.kind == "disabled" or not plugin._.cond
|
||||||
end,
|
end,
|
||||||
title = "Disabled",
|
title = "Disabled",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
return sections
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue