mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-19 21:06:46 +00:00
refactor: cleanup
This commit is contained in:
parent
37c7163f8d
commit
461552474c
4 changed files with 15 additions and 34 deletions
|
@ -9,7 +9,6 @@ local M = {}
|
|||
M._queue = {}
|
||||
M._executor = assert(vim.loop.new_check())
|
||||
M._running = false
|
||||
M.SLEEP = "sleep"
|
||||
---@type Async
|
||||
M.current = nil
|
||||
|
||||
|
@ -62,9 +61,7 @@ function Async:step()
|
|||
self.opts.on_error(tostring(res))
|
||||
end
|
||||
elseif res then
|
||||
if res == M.SLEEP then
|
||||
self.sleeping = true
|
||||
elseif self.opts.on_yield then
|
||||
if self.opts.on_yield then
|
||||
self.opts.on_yield(res)
|
||||
end
|
||||
end
|
||||
|
@ -130,4 +127,11 @@ function M.wrap(fn, opts)
|
|||
end
|
||||
end
|
||||
|
||||
---@async
|
||||
---@param ms number
|
||||
function M.sleep(ms)
|
||||
assert(M.current, "Not in an async context")
|
||||
M.current:sleep(ms)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue