Files
neovim/runtime/lua/vim/async/_runtime.lua
Lewis Russell 65ef6fdaee build: replace LuaLS with EmmyLua
Problem: LuaLS struggles with the generics used in Nvim's runtime,
requiring broad diagnostic suppressions. Indexing is also slow.

Solution: Use EmmyLua for type checks in the build and CI. It offers
more sophisticated type checking, substantially better support for
generics, and much better flow analysis.

Correct the affected annotations. Use `@internal`, supported directly by
EmmyLua, instead of `@nodoc` for shared internal declarations, and
support it in the help parser.

AI-assisted
2026-09-07 15:33:22 +01:00

44 lines
1.5 KiB
Lua

local validate = vim.validate
--- @class vim.async.Timer: vim.async.Closable
--- @nodoc
--- @field start fun(self, timeout: integer, repeat_interval: integer, callback: fun())
--- @alias vim.async.TimerFactory fun(): vim.async.Timer
--- @nodoc
--- @class vim.async.ConfigOpts
--- @nodoc
--- @field wait? fun(timeout: integer, predicate: fun(): boolean): boolean Run the event loop until the predicate succeeds or the timeout expires.
--- @field schedule? fun(callback: fun()) Queue a callback to run once on a later event-loop turn.
--- @field new_timer? vim.async.TimerFactory Create libuv-compatible timers for `sleep()` and `timeout()`.
--- @field debug? boolean Capture task creation metadata for debugging.
--- @class vim.async.Runtime
--- @nodoc
--- @field wait fun(timeout: integer, predicate: fun(): boolean): boolean
--- @field schedule fun(callback: fun())
--- @field new_timer vim.async.TimerFactory
--- @field debug boolean
local M = {}
M.debug = false
--- @nodoc
--- @param opts vim.async.ConfigOpts
function M.config(opts)
validate('opts', opts, 'table')
validate('opts.wait', opts.wait, 'callable', true)
validate('opts.schedule', opts.schedule, 'callable', true)
validate('opts.new_timer', opts.new_timer, 'callable', true)
validate('opts.debug', opts.debug, 'boolean', true)
M.wait = opts.wait or M.wait
M.schedule = opts.schedule or M.schedule
M.new_timer = opts.new_timer or M.new_timer
if opts.debug ~= nil then
M.debug = opts.debug
end
end
return M