mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
refactor: moved all plugin state to Plugin._
This commit is contained in:
parent
352dbadcb6
commit
28af1e1ac3
9 changed files with 49 additions and 46 deletions
|
@ -47,8 +47,8 @@ function M:update()
|
|||
}
|
||||
|
||||
for _, plugin in ipairs(self.plugins) do
|
||||
if plugin.tasks then
|
||||
for _, task in ipairs(plugin.tasks) do
|
||||
if plugin._.tasks then
|
||||
for _, task in ipairs(plugin._.tasks) do
|
||||
self.progress.total = self.progress.total + 1
|
||||
if not task:is_running() then
|
||||
self.progress.done = self.progress.done + 1
|
||||
|
@ -144,7 +144,7 @@ end
|
|||
|
||||
---@param plugin LazyPlugin
|
||||
function M:reason(plugin)
|
||||
local reason = vim.deepcopy(plugin.loaded or {})
|
||||
local reason = vim.deepcopy(plugin._.loaded or {})
|
||||
---@type string?
|
||||
local source = reason.source
|
||||
if source then
|
||||
|
@ -203,18 +203,18 @@ end
|
|||
|
||||
---@param plugin LazyPlugin
|
||||
function M:diagnostics(plugin)
|
||||
if plugin.updated then
|
||||
if plugin.updated.from == plugin.updated.to then
|
||||
if plugin._.updated then
|
||||
if plugin._.updated.from == plugin._.updated.to then
|
||||
self:diagnostic({
|
||||
message = "already up to date",
|
||||
})
|
||||
else
|
||||
self:diagnostic({
|
||||
message = "updated from " .. plugin.updated.from:sub(1, 7) .. " to " .. plugin.updated.to:sub(1, 7),
|
||||
message = "updated from " .. plugin._.updated.from:sub(1, 7) .. " to " .. plugin._.updated.to:sub(1, 7),
|
||||
})
|
||||
end
|
||||
end
|
||||
for _, task in ipairs(plugin.tasks or {}) do
|
||||
for _, task in ipairs(plugin._.tasks or {}) do
|
||||
if task:is_running() then
|
||||
self:diagnostic({
|
||||
severity = vim.diagnostic.severity.WARN,
|
||||
|
@ -233,7 +233,7 @@ end
|
|||
function M:plugin(plugin)
|
||||
self:append(" - ", "LazySpecial"):append(plugin.name)
|
||||
local plugin_start = self:row()
|
||||
if plugin.loaded then
|
||||
if plugin._.loaded then
|
||||
self:reason(plugin)
|
||||
end
|
||||
self:diagnostics(plugin)
|
||||
|
@ -248,7 +248,7 @@ end
|
|||
|
||||
---@param plugin LazyPlugin
|
||||
function M:tasks(plugin)
|
||||
for _, task in ipairs(plugin.tasks or {}) do
|
||||
for _, task in ipairs(plugin._.tasks or {}) do
|
||||
if task.type == "log" and not task.error then
|
||||
self:log(task)
|
||||
elseif task.error or self._details == plugin.name then
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
---@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 plugin._.tasks then
|
||||
for _, task in ipairs(plugin._.tasks) do
|
||||
if filter(task) then
|
||||
return true
|
||||
end
|
||||
|
@ -49,7 +49,7 @@ return {
|
|||
{
|
||||
---@param plugin LazyPlugin
|
||||
filter = function(plugin)
|
||||
return plugin.updated and plugin.updated.from ~= plugin.updated.to
|
||||
return plugin._.updated and plugin._.updated.from ~= plugin._.updated.to
|
||||
end,
|
||||
title = "Updated",
|
||||
},
|
||||
|
@ -63,25 +63,25 @@ return {
|
|||
},
|
||||
{
|
||||
filter = function(plugin)
|
||||
return plugin.installed and not plugin.uri
|
||||
return plugin._.installed and not plugin.uri
|
||||
end,
|
||||
title = "Clean",
|
||||
},
|
||||
{
|
||||
filter = function(plugin)
|
||||
return not plugin.installed and not plugin.uri
|
||||
return not plugin._.installed and not plugin.uri
|
||||
end,
|
||||
title = "Cleaned",
|
||||
},
|
||||
{
|
||||
filter = function(plugin)
|
||||
return plugin.loaded
|
||||
return plugin._.loaded
|
||||
end,
|
||||
title = "Loaded",
|
||||
},
|
||||
{
|
||||
filter = function(plugin)
|
||||
return plugin.installed
|
||||
return plugin._.installed
|
||||
end,
|
||||
title = "Installed",
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue