robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

robinmerge: 1dc9728daa1d8a2702

master
1.5 KiB43 linesraw
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)
29  validate('opts', opts, 'table')
30  validate('opts.wait', opts.wait, 'callable', true)
31  validate('opts.schedule', opts.schedule, 'callable', true)
32  validate('opts.new_timer', opts.new_timer, 'callable', true)
33  validate('opts.debug', opts.debug, 'boolean', true)
34
35  M.wait = opts.wait or M.wait
36  M.schedule = opts.schedule or M.schedule
37  M.new_timer = opts.new_timer or M.new_timer
38  if opts.debug ~= nil then
39    M.debug = opts.debug
40  end
41end
42
43return M