robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1local validate =vim . validate 2 3--- @class vim.async.Timer: vim.async.Closable 4--- @nodoc 5--- @field start fun(self, timeout: integer, repeat_interval: integer, callback: fun()) 6 7--- @alias vim.async.TimerFactory fun(): vim.async.Timer 8--- @nodoc 9 10--- @class vim.async.ConfigOpts 11--- @nodoc 12--- @field wait? fun(timeout: integer, predicate: fun(): boolean): boolean Run the event loop until the predicate succeeds or the timeout expires. 13--- @field schedule? fun(callback: fun()) Queue a callback to run once on a later event-loop turn. 14--- @field new_timer? vim.async.TimerFactory Create libuv-compatible timers for `sleep()` and `timeout()`. 15--- @field debug? boolean Capture task creation metadata for debugging. 16 17--- @class vim.async.Runtime 18--- @nodoc 19--- @field wait fun(timeout: integer, predicate: fun(): boolean): boolean 20--- @field schedule fun(callback: fun()) 21--- @field new_timer vim.async.TimerFactory 22--- @field debug boolean 23local M ={} 24M . debug =false 25 26--- @nodoc 27--- @param opts vim.async.ConfigOpts 28function M . config ( opts ) 29validate ( 'opts' , opts , 'table' ) 30validate ( 'opts.wait' , opts . wait , 'callable' , true ) 31validate ( 'opts.schedule' , opts . schedule , 'callable' , true ) 32validate ( 'opts.new_timer' , opts . new_timer , 'callable' , true ) 33validate ( 'opts.debug' , opts . debug , 'boolean' , true ) 34 35M . wait =opts . wait or M . wait 36M . schedule =opts . schedule or M . schedule 37M . new_timer =opts . new_timer or M . new_timer 38if opts . debug ~= nil then 39M . debug =opts . debug 40end 41end 42 43return M