lazy.nvim/lua/lazy/view/sections.lua
Will Leinweber cafe0b06e5 feat: Move Update section above Updated
Before, the list of plugins that were just updated would appear above
the list of plugins that are still to be updated. So if you are trying
to update each plugin one at a time, you would have to keep going down
farther and farther to get back to the list of pending updates.

By switching the order of the two sections, the list of pending updates
stays first and makes it easier to read the changes of each plugin
before updating them.
2023-01-05 18:43:36 +01:00

108 lines
2.3 KiB
Lua

---@param plugin LazyPlugin
---@param filter fun(task:LazyTask):boolean?
local function has_task(plugin, filter)
if plugin._.tasks then
for _, task in ipairs(plugin._.tasks) do
if filter(task) then
return true
end
end
end
end
---@alias LazySection {title:string, filter:fun(plugin:LazyPlugin):boolean?}
---@type LazySection[]
return {
{
filter = function(plugin)
return has_task(plugin, function(task)
return task.error ~= nil
end)
end,
title = "Failed",
},
{
filter = function(plugin)
return has_task(plugin, function(task)
return task:is_running()
end)
end,
title = "Working",
},
{
filter = function(plugin)
return has_task(plugin, function(task)
if task.name ~= "log" then
return
end
local lines = vim.split(task.output, "\n")
for _, line in ipairs(lines) do
if line:find("^%w+ %S+!:") then
return true
end
end
end)
end,
title = "Breaking Changes",
},
{
---@param plugin LazyPlugin
filter = function(plugin)
return plugin._.updates
end,
title = "Updates",
},
{
---@param plugin LazyPlugin
filter = function(plugin)
return plugin._.updated and plugin._.updated.from ~= plugin._.updated.to
end,
title = "Updated",
},
{
---@param plugin LazyPlugin
filter = function(plugin)
return plugin._.cloned
end,
title = "Installed",
},
{
filter = function(plugin)
return has_task(plugin, function(task)
return task.name == "log" and vim.trim(task.output) ~= ""
end)
end,
title = "Log",
},
{
filter = function(plugin)
return plugin._.kind == "clean" and plugin._.installed
end,
title = "Clean",
},
{
filter = function(plugin)
return not plugin._.installed and plugin._.kind ~= "disabled"
end,
title = "Not Installed",
},
{
filter = function(plugin)
return plugin._.loaded
end,
title = "Loaded",
},
{
filter = function(plugin)
return plugin._.installed
end,
title = "Not Loaded",
},
{
filter = function(plugin)
return plugin._.kind == "disabled"
end,
title = "Disabled",
},
}