diff options
| author | Lewis Russell <lewis6991@gmail.com> | 2026-09-07 11:43:51 +0100 |
|---|---|---|
| committer | Lewis Russell <me@lewisr.dev> | 2026-09-07 15:33:22 +0100 |
| commit | 65ef6fdaeef86f8341293942c076b320acf03fd1 (patch) | |
| tree | 8cc53d5edb74640ba17e3c2bf0a3d9c9b959071b /runtime/lua/vim/async/_future.lua | |
| parent | cd52c77cd5ad87ab4950946e0a51a8e13b53b4f5 (diff) | |
| download | rneovim-65ef6fdaeef86f8341293942c076b320acf03fd1.tar.gz rneovim-65ef6fdaeef86f8341293942c076b320acf03fd1.tar.bz2 rneovim-65ef6fdaeef86f8341293942c076b320acf03fd1.zip | |
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
Diffstat (limited to 'runtime/lua/vim/async/_future.lua')
| -rw-r--r-- | runtime/lua/vim/async/_future.lua | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/runtime/lua/vim/async/_future.lua b/runtime/lua/vim/async/_future.lua index 46b036b88c..b0d51433aa 100644 --- a/runtime/lua/vim/async/_future.lua +++ b/runtime/lua/vim/async/_future.lua @@ -1,9 +1,11 @@ --- LuaLS cannot model the generic annotations used by this vendored implementation. ----@diagnostic disable: no-unknown, undefined-doc-name, luadoc-miss-symbol, missing-return, missing-return-value, param-type-mismatch, return-type-mismatch, redundant-return-value, undefined-field, need-check-nil, await-in-sync - local F = vim.F local util = require('vim._core.util') +--- @class (internal) vim.async.Future<R> +--- @field private _callbacks table<integer, fun(err?: any, ...: R...)> +--- @field private _callback_pos integer +--- @field private _err? any +--- @field private _result? R[] & { n: integer } local Future = {} Future.__index = Future @@ -22,6 +24,8 @@ function Future:result() end end +--- @param callback fun(err?: any, ...: R...) +--- @return fun() function Future:on_complete(callback) if self:completed() then -- Already completed or closed @@ -42,6 +46,8 @@ function Future:on_complete(callback) end end +--- @param err? any +--- @param ... R... function Future:complete(err, ...) if self:completed() then error('Future is already completed', 2) @@ -69,6 +75,7 @@ function Future:complete(err, ...) end end +--- @return vim.async.Future<any> return function() return setmetatable({ _callbacks = {}, |