mirror of https://github.com/folke/lazy.nvim.git
feat(checker): only report an update once and do a fast update check after each manage operation
This commit is contained in:
parent
f24c055fe9
commit
2a7466abad
|
@ -54,7 +54,7 @@ M.defaults = {
|
||||||
checker = {
|
checker = {
|
||||||
-- lazy can automatically check for updates
|
-- lazy can automatically check for updates
|
||||||
enabled = false,
|
enabled = false,
|
||||||
concurrency = 10, -- set to 1 to very slowly check for updates
|
concurrency = nil, ---@type number? set to 1 to very slowly check for updates
|
||||||
notify = true, -- get a notification if new updates are found
|
notify = true, -- get a notification if new updates are found
|
||||||
frequency = 3600, -- every hour
|
frequency = 3600, -- every hour
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,6 +7,7 @@ local M = {}
|
||||||
|
|
||||||
M.running = false
|
M.running = false
|
||||||
M.updated = {}
|
M.updated = {}
|
||||||
|
M.reported = {}
|
||||||
|
|
||||||
function M.start()
|
function M.start()
|
||||||
M.fast_check()
|
M.fast_check()
|
||||||
|
@ -15,6 +16,7 @@ end
|
||||||
|
|
||||||
function M.fast_check()
|
function M.fast_check()
|
||||||
for _, plugin in pairs(Config.plugins) do
|
for _, plugin in pairs(Config.plugins) do
|
||||||
|
plugin._.has_updates = nil
|
||||||
local info = Git.info(plugin.dir)
|
local info = Git.info(plugin.dir)
|
||||||
local target = Git.get_target(plugin)
|
local target = Git.get_target(plugin)
|
||||||
if info and target and info.commit ~= target.commit then
|
if info and target and info.commit ~= target.commit then
|
||||||
|
@ -36,10 +38,14 @@ end
|
||||||
|
|
||||||
function M.report()
|
function M.report()
|
||||||
local lines = {}
|
local lines = {}
|
||||||
|
M.updated = {}
|
||||||
for _, plugin in pairs(Config.plugins) do
|
for _, plugin in pairs(Config.plugins) do
|
||||||
if plugin._.has_updates and not vim.tbl_contains(M.updated, plugin.name) then
|
if plugin._.has_updates then
|
||||||
table.insert(lines, "- **" .. plugin.name .. "**")
|
|
||||||
table.insert(M.updated, plugin.name)
|
table.insert(M.updated, plugin.name)
|
||||||
|
if not vim.tbl_contains(M.reported, plugin.name) then
|
||||||
|
table.insert(lines, "- **" .. plugin.name .. "**")
|
||||||
|
table.insert(M.reported, plugin.name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #lines > 0 and Config.options.checker.notify then
|
if #lines > 0 and Config.options.checker.notify then
|
||||||
|
|
|
@ -43,6 +43,7 @@ function M.run(ropts, opts)
|
||||||
runner:wait(function()
|
runner:wait(function()
|
||||||
vim.cmd([[do User LazyRender]])
|
vim.cmd([[do User LazyRender]])
|
||||||
Plugin.update_state()
|
Plugin.update_state()
|
||||||
|
require("lazy.manage.checker").fast_check()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if opts.wait then
|
if opts.wait then
|
||||||
|
|
Loading…
Reference in New Issue