lazy.nvim/lua/lazy/view/sections.lua

121 lines
2.4 KiB
Lua
Raw Permalink Normal View History

2022-11-20 22:25:21 +00:00
---@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
2022-11-20 22:25:21 +00:00
if filter(task) then
return true
end
end
end
end
---@alias LazySection {title:string, filter:fun(plugin:LazyPlugin):boolean?}
---@type LazySection[]
2022-11-20 22:25:21 +00:00
return {
{
filter = function(plugin)
return has_task(plugin, function(task)
2024-06-26 17:31:31 +01:00
return task:has_errors()
2022-11-20 22:25:21 +00:00
end)
end,
title = "Failed",
},
{
filter = function(plugin)
if plugin._.working then
return true
end
2022-11-20 22:25:21 +00:00
return has_task(plugin, function(task)
2024-06-28 15:08:26 +01:00
return task:running()
2022-11-20 22:25:21 +00:00
end)
end,
title = "Working",
},
{
filter = function(plugin)
return plugin._.build
end,
title = "Build",
},
{
filter = function(plugin)
return has_task(plugin, function(task)
if task.name ~= "log" then
return
end
2024-06-26 17:31:31 +01:00
for _, line in ipairs(vim.split(task:output(), "\n")) do
if line:find("^%w+ %S+!:") then
return true
end
end
end)
end,
title = "Breaking Changes",
},
{
filter = function(plugin)
return plugin._.updated and plugin._.updated.from ~= plugin._.updated.to
end,
title = "Updated",
},
{
filter = function(plugin)
return plugin._.cloned
end,
title = "Installed",
},
{
---@param plugin LazyPlugin
filter = function(plugin)
return plugin._.updates ~= nil
end,
title = "Updates",
},
2022-11-22 20:12:50 +00:00
{
filter = function(plugin)
return has_task(plugin, function(task)
2024-06-26 17:31:31 +01:00
return task.name == "log" and vim.trim(task:output()) ~= ""
2022-11-22 20:12:50 +00:00
end)
end,
title = "Log",
},
2022-11-20 22:25:21 +00:00
{
filter = function(plugin)
return plugin._.kind == "clean" and plugin._.installed
2022-11-20 22:25:21 +00:00
end,
title = "Clean",
},
{
filter = function(plugin)
return not plugin._.installed and plugin._.kind ~= "disabled"
2022-11-20 22:25:21 +00:00
end,
title = "Not Installed",
2022-11-20 22:25:21 +00:00
},
{
2024-06-26 17:31:31 +01:00
filter = function(plugin)
return plugin._.outdated
end,
title = "Outdated",
},
2022-11-20 22:25:21 +00:00
{
filter = function(plugin)
return plugin._.loaded ~= nil
2022-11-20 22:25:21 +00:00
end,
title = "Loaded",
},
{
filter = function(plugin)
return plugin._.installed
2022-11-20 22:25:21 +00:00
end,
2022-12-23 13:58:11 +00:00
title = "Not Loaded",
2022-11-20 22:25:21 +00:00
},
{
filter = function(plugin)
return plugin._.kind == "disabled"
end,
title = "Disabled",
},
2022-11-20 22:25:21 +00:00
}