mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-19 21:06:46 +00:00
feat: added opts.git.cooldown
to allow updating plugins on slow connections. Fixes #1656
This commit is contained in:
parent
839f9e78e7
commit
d5686efbd0
3 changed files with 20 additions and 1 deletions
|
@ -40,6 +40,15 @@ function throttle.wait()
|
|||
end
|
||||
end
|
||||
|
||||
---@param plugin LazyPlugin
|
||||
local function cooldown(plugin)
|
||||
if not plugin._.last_check then
|
||||
return false
|
||||
end
|
||||
local delta = (vim.uv.now() - plugin._.last_check) / 1000
|
||||
return delta < Config.options.git.cooldown
|
||||
end
|
||||
|
||||
---@type table<string, LazyTaskDef>
|
||||
local M = {}
|
||||
|
||||
|
@ -266,7 +275,7 @@ M.status = {
|
|||
-- fetches all needed origin branches
|
||||
M.fetch = {
|
||||
skip = function(plugin)
|
||||
return not plugin._.installed or plugin._.is_local
|
||||
return not plugin._.installed or plugin._.is_local or cooldown(plugin)
|
||||
end,
|
||||
|
||||
---@async
|
||||
|
@ -287,6 +296,11 @@ M.fetch = {
|
|||
self:spawn("git", {
|
||||
args = args,
|
||||
cwd = self.plugin.dir,
|
||||
on_exit = function(ok)
|
||||
if ok then
|
||||
self.plugin._.last_check = vim.uv.now()
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue