mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
feat(checker): checker will now save last check time and only check at configured frequency even after restarting Neovim
This commit is contained in:
parent
835731f102
commit
813fc944d7
3 changed files with 59 additions and 3 deletions
|
@ -3,6 +3,7 @@ local Manage = require("lazy.manage")
|
|||
local Util = require("lazy.util")
|
||||
local Plugin = require("lazy.core.plugin")
|
||||
local Git = require("lazy.manage.git")
|
||||
local State = require("lazy.state")
|
||||
|
||||
local M = {}
|
||||
|
||||
|
@ -12,7 +13,14 @@ M.reported = {}
|
|||
|
||||
function M.start()
|
||||
M.fast_check()
|
||||
M.check()
|
||||
M.schedule()
|
||||
end
|
||||
|
||||
function M.schedule()
|
||||
State.read() -- update state
|
||||
local next_check = State.checker.last_check + Config.options.checker.frequency - os.time()
|
||||
next_check = math.max(next_check, 0)
|
||||
vim.defer_fn(M.check, next_check * 1000)
|
||||
end
|
||||
|
||||
---@param opts? {report:boolean} report defaults to true
|
||||
|
@ -32,6 +40,8 @@ function M.fast_check(opts)
|
|||
end
|
||||
|
||||
function M.check()
|
||||
State.checker.last_check = os.time()
|
||||
State.write() -- update state
|
||||
local errors = false
|
||||
for _, plugin in pairs(Config.plugins) do
|
||||
if Plugin.has_errors(plugin) then
|
||||
|
@ -40,14 +50,14 @@ function M.check()
|
|||
end
|
||||
end
|
||||
if errors then
|
||||
vim.defer_fn(M.check, Config.options.checker.frequency * 1000)
|
||||
M.schedule()
|
||||
else
|
||||
Manage.check({
|
||||
show = false,
|
||||
concurrency = Config.options.checker.concurrency,
|
||||
}):wait(function()
|
||||
M.report()
|
||||
vim.defer_fn(M.check, Config.options.checker.frequency * 1000)
|
||||
M.schedule()
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue