File tree 3 files changed +20
-1
lines changed
3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ M.defaults = {
41
41
rate = 2 ,
42
42
duration = 5 * 1000 , -- in ms
43
43
},
44
+ -- Time in seconds to wait before running fetch again for a plugin.
45
+ -- Repeated update/check operations will not run again until this
46
+ -- cooldown period has passed.
47
+ cooldown = 0 ,
44
48
},
45
49
pkg = {
46
50
enabled = true ,
Original file line number Diff line number Diff line change @@ -40,6 +40,15 @@ function throttle.wait()
40
40
end
41
41
end
42
42
43
+ --- @param plugin LazyPlugin
44
+ local function cooldown (plugin )
45
+ if not plugin ._ .last_check then
46
+ return false
47
+ end
48
+ local delta = (vim .uv .now () - plugin ._ .last_check ) / 1000
49
+ return delta < Config .options .git .cooldown
50
+ end
51
+
43
52
--- @type table<string , LazyTaskDef>
44
53
local M = {}
45
54
@@ -266,7 +275,7 @@ M.status = {
266
275
-- fetches all needed origin branches
267
276
M .fetch = {
268
277
skip = function (plugin )
269
- return not plugin ._ .installed or plugin ._ .is_local
278
+ return not plugin ._ .installed or plugin ._ .is_local or cooldown ( plugin )
270
279
end ,
271
280
272
281
--- @async
@@ -287,6 +296,11 @@ M.fetch = {
287
296
self :spawn (" git" , {
288
297
args = args ,
289
298
cwd = self .plugin .dir ,
299
+ on_exit = function (ok )
300
+ if ok then
301
+ self .plugin ._ .last_check = vim .uv .now ()
302
+ end
303
+ end ,
290
304
})
291
305
end ,
292
306
}
Original file line number Diff line number Diff line change 20
20
--- @field tasks ? LazyTask[]
21
21
--- @field updated ? { from : string , to : string }
22
22
--- @field updates ? { from : GitInfo , to : GitInfo }
23
+ --- @field last_check ? number
23
24
--- @field working ? boolean
24
25
--- @field pkg ? LazyPkg
25
26
You can’t perform that action at this time.
0 commit comments