@@ -3,6 +3,7 @@ local Manage = require("lazy.manage")
3
3
local Util = require (" lazy.util" )
4
4
local Plugin = require (" lazy.core.plugin" )
5
5
local Git = require (" lazy.manage.git" )
6
+ local State = require (" lazy.state" )
6
7
7
8
local M = {}
8
9
@@ -12,7 +13,14 @@ M.reported = {}
12
13
13
14
function M .start ()
14
15
M .fast_check ()
15
- M .check ()
16
+ M .schedule ()
17
+ end
18
+
19
+ function M .schedule ()
20
+ State .read () -- update state
21
+ local next_check = State .checker .last_check + Config .options .checker .frequency - os.time ()
22
+ next_check = math.max (next_check , 0 )
23
+ vim .defer_fn (M .check , next_check * 1000 )
16
24
end
17
25
18
26
--- @param opts ? { report : boolean } report defaults to true
@@ -32,6 +40,8 @@ function M.fast_check(opts)
32
40
end
33
41
34
42
function M .check ()
43
+ State .checker .last_check = os.time ()
44
+ State .write () -- update state
35
45
local errors = false
36
46
for _ , plugin in pairs (Config .plugins ) do
37
47
if Plugin .has_errors (plugin ) then
@@ -40,14 +50,14 @@ function M.check()
40
50
end
41
51
end
42
52
if errors then
43
- vim . defer_fn ( M . check , Config . options . checker . frequency * 1000 )
53
+ M . schedule ( )
44
54
else
45
55
Manage .check ({
46
56
show = false ,
47
57
concurrency = Config .options .checker .concurrency ,
48
58
}):wait (function ()
49
59
M .report ()
50
- vim . defer_fn ( M . check , Config . options . checker . frequency * 1000 )
60
+ M . schedule ( )
51
61
end )
52
62
end
53
63
end
0 commit comments