refactor: async processes

This commit is contained in:
Folke Lemaitre 2024-06-28 16:08:26 +02:00
parent 4319846b8c
commit a36ebd2a75
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
12 changed files with 394 additions and 379 deletions

View file

@ -76,6 +76,13 @@ function M.throttle(ms, fn)
local timer = vim.uv.new_timer()
local pending = false
---@type Async
local async
local function running()
return async and async:running()
end
return function()
if timer:is_active() then
pending = true
@ -85,7 +92,10 @@ function M.throttle(ms, fn)
0,
ms,
vim.schedule_wrap(function()
fn()
if running() then
return
end
async = require("lazy.async").new(fn)
if pending then
pending = false
else