diff options
| author | Lewis Russell <lewis6991@gmail.com> | 2026-09-15 14:14:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-15 14:14:21 +0100 |
| commit | c171a697cbee36c4f36535e14f1407909733ca4b (patch) | |
| tree | 945a337b27aa3f15b26250d40b5535a5ead33181 /runtime/lua/vim/F.lua | |
| parent | 3f21132a65a9c1f9ae5307bb59a5c730240c4a34 (diff) | |
| download | rneovim-c171a697cbee36c4f36535e14f1407909733ca4b.tar.gz rneovim-c171a697cbee36c4f36535e14f1407909733ca4b.tar.bz2 rneovim-c171a697cbee36c4f36535e14f1407909733ca4b.zip | |
fix(lua): add missing param annotations (#41911)
Diffstat (limited to 'runtime/lua/vim/F.lua')
| -rw-r--r-- | runtime/lua/vim/F.lua | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/runtime/lua/vim/F.lua b/runtime/lua/vim/F.lua index e16003880c..6087aee14d 100644 --- a/runtime/lua/vim/F.lua +++ b/runtime/lua/vim/F.lua @@ -1,5 +1,9 @@ local F = {} +-- Failure returns no values, so every result becomes optional. +--- @nodoc +--- @alias vim.F.OptionalReturns<T> { [K in keyof T]: T[K]|nil } + --- Returns the first argument which is not nil. --- --- If all arguments are nil, returns nil. @@ -25,6 +29,10 @@ end -- Use in combination with pcall --- @deprecated +--- @generic T... +--- @param status boolean +--- @param ... T... +--- @return vim.F.OptionalReturns<T>... function F.ok_or_nil(status, ...) vim.deprecate('vim.F.ok_or_nil', 'actual error handling', '0.15') if not status then @@ -46,6 +54,9 @@ end --- Wrap a function to return nil if it fails, otherwise the value --- @deprecated +--- @generic A..., R... +--- @param fn fun(...: A...): R... +--- @return fun(...: A...): vim.F.OptionalReturns<R>... function F.nil_wrap(fn) vim.deprecate('vim.F.nil_wrap', 'vim.npcall', '0.15') return function(...) @@ -56,13 +67,17 @@ end -- TODO: deprecate `F.pack_len` and `F.unpack_len` --- like {...} except preserve the length explicitly +--- @param ... any +--- @return { [integer]: any, n: integer } function F.pack_len(...) return { n = select('#', ...), ... } end --- like unpack() but use the length set by F.pack_len if present +--- @param t { [integer]: any, n?: integer } +--- @return any... function F.unpack_len(t) - return unpack(t, 1, t.n) + return unpack(t, 1, t.n or #t) end return F |