fix(types): add more annotations to eval.lua

This commit is contained in:
Lewis Russell 2023-08-17 11:10:06 +01:00 committed by Lewis Russell
parent c2341df64a
commit 21152f7905
2 changed files with 159 additions and 98 deletions

View File

@ -1600,7 +1600,7 @@ function vim.fn.eventhandler() end
--- |exepath()| can be used to get the full path of an executable.
---
--- @param expr any
--- @return any
--- @return 0|1|-1
function vim.fn.executable(expr) end
--- Execute {command} and capture its output.
@ -8957,7 +8957,7 @@ function vim.fn.strcharpart(src, start, len, skipcc) end
---
--- @param string string
--- @param skipcc? any
--- @return any
--- @return integer
function vim.fn.strchars(string, skipcc) end
--- The result is a Number, which is the number of display cells
@ -8975,7 +8975,7 @@ function vim.fn.strchars(string, skipcc) end
---
--- @param string string
--- @param col? integer
--- @return any
--- @return integer
function vim.fn.strdisplaywidth(string, col) end
--- The result is a String, which is a formatted date and time, as
@ -8996,7 +8996,7 @@ function vim.fn.strdisplaywidth(string, col) end
---
--- @param format any
--- @param time? any
--- @return any
--- @return string
function vim.fn.strftime(format, time) end
--- Get a Number corresponding to the character at {index} in
@ -9007,9 +9007,9 @@ function vim.fn.strftime(format, time) end
--- Returns -1 if {index} is invalid.
--- Also see |strcharpart()| and |strchars()|.
---
--- @param str any
--- @param index any
--- @return any
--- @param str string
--- @param index integer
--- @return integer
function vim.fn.strgetchar(str, index) end
--- The result is a Number, which gives the byte index in
@ -9030,10 +9030,10 @@ function vim.fn.strgetchar(str, index) end
--- stridx() works similar to the C function strstr(). When used
--- with a single character it works similar to strchr().
---
--- @param haystack any
--- @param needle any
--- @param start? any
--- @return any
--- @param haystack string
--- @param needle string
--- @param start? integer
--- @return integer
function vim.fn.stridx(haystack, needle, start) end
--- Return {expr} converted to a String. If {expr} is a Number,
@ -9060,7 +9060,7 @@ function vim.fn.stridx(haystack, needle, start) end
--- share data with other application.
---
--- @param expr any
--- @return any
--- @return string
function vim.fn.string(expr) end
--- The result is a Number, which is the length of the String
@ -9072,7 +9072,7 @@ function vim.fn.string(expr) end
--- Also see |len()|, |strdisplaywidth()| and |strwidth()|.
---
--- @param string string
--- @return any
--- @return integer
function vim.fn.strlen(string) end
--- The result is a String, which is part of {src}, starting from
@ -9099,11 +9099,11 @@ function vim.fn.strlen(string) end
--- <
--- Returns an empty string on error.
---
--- @param src any
--- @param start any
--- @param len? any
--- @param chars? any
--- @return any
--- @param src string
--- @param start integer
--- @param len? integer
--- @param chars? 0|1
--- @return string
function vim.fn.strpart(src, start, len, chars) end
--- The result is a Number, which is a unix timestamp representing
@ -9129,9 +9129,9 @@ function vim.fn.strpart(src, start, len, chars) end
--- echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600)
--- < Sun Apr 27 12:53:55 1997
---
--- @param format any
--- @param timestring any
--- @return any
--- @param format string
--- @param timestring string
--- @return integer
function vim.fn.strptime(format, timestring) end
--- The result is a Number, which gives the byte index in
@ -9151,10 +9151,10 @@ function vim.fn.strptime(format, timestring) end
--- When used with a single character it works similar to the C
--- function strrchr().
---
--- @param haystack any
--- @param needle any
--- @param start? any
--- @return any
--- @param haystack string
--- @param needle string
--- @param start? integer
--- @return integer
function vim.fn.strridx(haystack, needle, start) end
--- The result is a String, which is {string} with all unprintable
@ -9167,7 +9167,7 @@ function vim.fn.strridx(haystack, needle, start) end
--- Returns an empty string on error.
---
--- @param string string
--- @return any
--- @return string
function vim.fn.strtrans(string) end
--- The result is a Number, which is the number of UTF-16 code
@ -9189,8 +9189,8 @@ function vim.fn.strtrans(string) end
--- echo strutf16len('ą́', v:true) " returns 3
---
--- @param string string
--- @param countcc? any
--- @return any
--- @param countcc? 0|1
--- @return integer
function vim.fn.strutf16len(string, countcc) end
--- The result is a Number, which is the number of display cells
@ -9202,7 +9202,7 @@ function vim.fn.strutf16len(string, countcc) end
--- Also see |strlen()|, |strdisplaywidth()| and |strchars()|.
---
--- @param string string
--- @return any
--- @return integer
function vim.fn.strwidth(string) end
--- Only for an expression in a |:substitute| command or
@ -9233,8 +9233,8 @@ function vim.fn.strwidth(string) end
--- A line break is included as a newline character.
---
--- @param nr integer
--- @param list? any
--- @return any
--- @param list? integer
--- @return string|string[]
function vim.fn.submatch(nr, list) end
--- The result is a String, which is a copy of {string}, in which
@ -9280,10 +9280,10 @@ function vim.fn.submatch(nr, list) end
--- <Returns an empty string on error.
---
--- @param string string
--- @param pat any
--- @param sub any
--- @param pat string
--- @param sub string
--- @param flags string
--- @return any
--- @return string
function vim.fn.substitute(string, pat, sub, flags) end
--- Returns a list of swap file names, like what "vim -r" shows.
@ -9296,7 +9296,7 @@ function vim.fn.substitute(string, pat, sub, flags) end
--- let swapfiles = swapfilelist()
--- let &directory = save_dir
---
--- @return any
--- @return string[]
function vim.fn.swapfilelist() end
--- The result is a dictionary, which holds information about the
@ -9326,8 +9326,8 @@ function vim.fn.swapinfo(fname) end
--- |:swapname| (unless there is no swap file).
--- If buffer {buf} has no swap file, returns an empty string.
---
--- @param buf any
--- @return any
--- @param buf integer|string
--- @return string
function vim.fn.swapname(buf) end
--- The result is a Number, which is the syntax ID at the position
@ -9357,8 +9357,8 @@ function vim.fn.swapname(buf) end
---
--- @param lnum integer
--- @param col integer
--- @param trans any
--- @return any
--- @param trans 0|1
--- @return integer
function vim.fn.synID(lnum, col, trans) end
--- The result is a String, which is the {what} attribute of
@ -9406,10 +9406,10 @@ function vim.fn.synID(lnum, col, trans) end
--- echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
--- <
---
--- @param synID any
--- @param what any
--- @param synID integer
--- @param what string
--- @param mode? string
--- @return any
--- @return string
function vim.fn.synIDattr(synID, what, mode) end
--- The result is a Number, which is the translated syntax ID of
@ -9419,8 +9419,8 @@ function vim.fn.synIDattr(synID, what, mode) end
---
--- Returns zero on error.
---
--- @param synID any
--- @return any
--- @param synID integer
--- @return integer
function vim.fn.synIDtrans(synID) end
--- The result is a |List| with currently three items:
@ -9450,7 +9450,7 @@ function vim.fn.synIDtrans(synID) end
---
--- @param lnum integer
--- @param col integer
--- @return any
--- @return {[1]: integer, [2]: string, [3]: integer}[]
function vim.fn.synconcealed(lnum, col) end
--- Return a |List|, which is the stack of syntax items at the
@ -9473,7 +9473,7 @@ function vim.fn.synconcealed(lnum, col) end
---
--- @param lnum integer
--- @param col integer
--- @return any
--- @return integer[]
function vim.fn.synstack(lnum, col) end
--- Note: Prefer |vim.system()| in Lua.
@ -9524,9 +9524,9 @@ function vim.fn.synstack(lnum, col) end
--- <Unlike ":!cmd" there is no automatic check for changed files.
--- Use |:checktime| to force a check.
---
--- @param cmd any
--- @param input? any
--- @return any
--- @param cmd string|string[]
--- @param input? string|string[]|integer
--- @return string
function vim.fn.system(cmd, input) end
--- Same as |system()|, but returns a |List| with lines (parts of
@ -9542,10 +9542,10 @@ function vim.fn.system(cmd, input) end
--- <
--- Returns an empty string on error.
---
--- @param cmd any
--- @param input? any
--- @param keepempty? any
--- @return any
--- @param cmd string|string[]
--- @param input? string|string[]|integer
--- @param keepempty? integer
--- @return string[]
function vim.fn.systemlist(cmd, input, keepempty) end
--- The result is a |List|, where each item is the number of the
@ -9577,8 +9577,8 @@ function vim.fn.tabpagebuflist(arg) end
---
--- Returns zero on error.
---
--- @param arg? any
--- @return any
--- @param arg? '$'|'#'
--- @return integer
function vim.fn.tabpagenr(arg) end
--- Like |winnr()| but for tab page {tabarg}.
@ -9593,15 +9593,15 @@ function vim.fn.tabpagenr(arg) end
--- tabpagewinnr(4, '$') " number of windows in tab page 4
--- <When {tabarg} is invalid zero is returned.
---
--- @param tabarg any
--- @param arg? any
--- @return any
--- @param tabarg integer
--- @param arg? '$'|'#'
--- @return integer
function vim.fn.tabpagewinnr(tabarg, arg) end
--- Returns a |List| with the file names used to search for tags
--- for the current buffer. This is the 'tags' option expanded.
---
--- @return any
--- @return string[]
function vim.fn.tagfiles() end
--- Returns a |List| of tags matching the regular expression {expr}.
@ -9647,7 +9647,7 @@ function vim.fn.tagfiles() end
--- the tags file generated by the different ctags tools.
---
--- @param expr any
--- @param filename? any
--- @param filename? string
--- @return any
function vim.fn.taglist(expr, filename) end
@ -9661,8 +9661,8 @@ function vim.fn.taglist(expr, filename) end
--- echo tan(-4.01)
--- < -1.181502
---
--- @param expr any
--- @return any
--- @param expr number
--- @return number
function vim.fn.tan(expr) end
--- Return the hyperbolic tangent of {expr} as a |Float| in the
@ -9675,8 +9675,8 @@ function vim.fn.tan(expr) end
--- echo tanh(-1)
--- < -0.761594
---
--- @param expr any
--- @return any
--- @param expr number
--- @return number
function vim.fn.tanh(expr) end
--- Generates a (non-existent) filename located in the Nvim root
@ -9824,10 +9824,10 @@ function vim.fn.toupper(expr) end
--- echo tr("<blob>", "<>", "{}")
--- <returns "{blob}"
---
--- @param src any
--- @param fromstr any
--- @param tostr any
--- @return any
--- @param src string
--- @param fromstr string
--- @param tostr string
--- @return string
function vim.fn.tr(src, fromstr, tostr) end
--- Return {text} as a String where any character in {mask} is
@ -9855,8 +9855,8 @@ function vim.fn.tr(src, fromstr, tostr) end
--- <returns " vim"
---
--- @param text any
--- @param mask? any
--- @param dir? string
--- @param mask? string
--- @param dir? 0|1|2
--- @return string
function vim.fn.trim(text, mask, dir) end
@ -9873,7 +9873,7 @@ function vim.fn.trim(text, mask, dir) end
--- < 4.0
---
--- @param expr any
--- @return any
--- @return integer
function vim.fn.trunc(expr) end
--- The result is a Number representing the type of {expr}.
@ -9903,7 +9903,7 @@ function vim.fn.trunc(expr) end
--- if exists('v:t_number') | endif
---
--- @param expr any
--- @return any
--- @return integer
function vim.fn.type(expr) end
--- Return the name of the undo file that would be used for a file
@ -9963,7 +9963,7 @@ function vim.fn.undofile(name) end
--- blocks. Each item may again have an "alt"
--- item.
---
--- @param buf? any
--- @param buf? integer|string
--- @return any
function vim.fn.undotree(buf) end

View File

@ -54,7 +54,7 @@ M.funcs = {
name = 'abs',
params = { { 'expr', 'any' } },
signature = 'abs({expr})',
returns = 'number'
returns = 'number',
},
acos = {
args = 1,
@ -2075,6 +2075,7 @@ M.funcs = {
fast = true,
name = 'executable',
params = { { 'expr', 'any' } },
returns = '0|1|-1',
signature = 'executable({expr})',
},
execute = {
@ -6189,7 +6190,12 @@ M.funcs = {
]=],
name = 'maparg',
params = { { 'name', 'string' }, { 'mode', 'string' }, { 'abbr', 'boolean' }, { 'dict', 'boolean' } },
params = {
{ 'name', 'string' },
{ 'mode', 'string' },
{ 'abbr', 'boolean' },
{ 'dict', 'boolean' },
},
returns = 'string|table<string,any>',
signature = 'maparg({name} [, {mode} [, {abbr} [, {dict}]]])',
},
@ -10644,6 +10650,7 @@ M.funcs = {
]=],
name = 'strchars',
params = { { 'string', 'string' }, { 'skipcc', 'any' } },
returns = 'integer',
signature = 'strchars({string} [, {skipcc}])',
},
strdisplaywidth = {
@ -10666,6 +10673,7 @@ M.funcs = {
]=],
name = 'strdisplaywidth',
params = { { 'string', 'string' }, { 'col', 'integer' } },
returns = 'integer',
signature = 'strdisplaywidth({string} [, {col}])',
},
strftime = {
@ -10691,6 +10699,7 @@ M.funcs = {
]=],
name = 'strftime',
params = { { 'format', 'any' }, { 'time', 'any' } },
returns = 'string',
signature = 'strftime({format} [, {time}])',
},
strgetchar = {
@ -10707,7 +10716,8 @@ M.funcs = {
]=],
name = 'strgetchar',
params = { { 'str', 'any' }, { 'index', 'any' } },
params = { { 'str', 'string' }, { 'index', 'integer' } },
returns = 'integer',
signature = 'strgetchar({str}, {index})',
},
stridx = {
@ -10735,7 +10745,8 @@ M.funcs = {
]=],
fast = true,
name = 'stridx',
params = { { 'haystack', 'any' }, { 'needle', 'any' }, { 'start', 'any' } },
params = { { 'haystack', 'string' }, { 'needle', 'string' }, { 'start', 'integer' } },
returns = 'integer',
signature = 'stridx({haystack}, {needle} [, {start}])',
},
string = {
@ -10768,6 +10779,7 @@ M.funcs = {
]=],
name = 'string',
params = { { 'expr', 'any' } },
returns = 'string',
signature = 'string({expr})',
},
strlen = {
@ -10785,6 +10797,7 @@ M.funcs = {
]=],
name = 'strlen',
params = { { 'string', 'string' } },
returns = 'integer',
signature = 'strlen({string})',
},
strpart = {
@ -10818,7 +10831,13 @@ M.funcs = {
]=],
fast = true,
name = 'strpart',
params = { { 'src', 'any' }, { 'start', 'any' }, { 'len', 'any' }, { 'chars', 'any' } },
params = {
{ 'src', 'string' },
{ 'start', 'integer' },
{ 'len', 'integer' },
{ 'chars', '0|1' },
},
returns = 'string',
signature = 'strpart({src}, {start} [, {len} [, {chars}]])',
},
strptime = {
@ -10850,7 +10869,8 @@ M.funcs = {
]=],
name = 'strptime',
params = { { 'format', 'any' }, { 'timestring', 'any' } },
params = { { 'format', 'string' }, { 'timestring', 'string' } },
returns = 'integer',
signature = 'strptime({format}, {timestring})',
},
strridx = {
@ -10876,7 +10896,12 @@ M.funcs = {
]=],
name = 'strridx',
params = { { 'haystack', 'any' }, { 'needle', 'any' }, { 'start', 'any' } },
params = {
{ 'haystack', 'string' },
{ 'needle', 'string' },
{ 'start', 'integer' },
},
returns = 'integer',
signature = 'strridx({haystack}, {needle} [, {start}])',
},
strtrans = {
@ -10896,6 +10921,7 @@ M.funcs = {
fast = true,
name = 'strtrans',
params = { { 'string', 'string' } },
returns = 'string',
signature = 'strtrans({string})',
},
strutf16len = {
@ -10922,7 +10948,8 @@ M.funcs = {
]=],
name = 'strutf16len',
params = { { 'string', 'string' }, { 'countcc', 'any' } },
params = { { 'string', 'string' }, { 'countcc', '0|1' } },
returns = 'integer',
signature = 'strutf16len({string} [, {countcc}])',
},
strwidth = {
@ -10941,6 +10968,7 @@ M.funcs = {
fast = true,
name = 'strwidth',
params = { { 'string', 'string' } },
returns = 'integer',
signature = 'strwidth({string})',
},
submatch = {
@ -10977,7 +11005,8 @@ M.funcs = {
]=],
name = 'submatch',
params = { { 'nr', 'integer' }, { 'list', 'any' } },
params = { { 'nr', 'integer' }, { 'list', 'integer' } },
returns = 'string|string[]',
signature = 'submatch({nr} [, {list}])',
},
substitute = {
@ -11028,7 +11057,13 @@ M.funcs = {
]=],
name = 'substitute',
params = { { 'string', 'string' }, { 'pat', 'any' }, { 'sub', 'any' }, { 'flags', 'string' } },
params = {
{ 'string', 'string' },
{ 'pat', 'string' },
{ 'sub', 'string' },
{ 'flags', 'string' },
},
returns = 'string',
signature = 'substitute({string}, {pat}, {sub}, {flags})',
},
swapfilelist = {
@ -11045,6 +11080,7 @@ M.funcs = {
]=],
name = 'swapfilelist',
params = {},
returns = 'string[]',
signature = 'swapfilelist()',
},
swapinfo = {
@ -11085,7 +11121,8 @@ M.funcs = {
]=],
name = 'swapname',
params = { { 'buf', 'any' } },
params = { { 'buf', 'integer|string' } },
returns = 'string',
signature = 'swapname({buf})',
},
synID = {
@ -11117,7 +11154,8 @@ M.funcs = {
<
]=],
name = 'synID',
params = { { 'lnum', 'integer' }, { 'col', 'integer' }, { 'trans', 'any' } },
params = { { 'lnum', 'integer' }, { 'col', 'integer' }, { 'trans', '0|1' } },
returns = 'integer',
signature = 'synID({lnum}, {col}, {trans})',
},
synIDattr = {
@ -11170,7 +11208,8 @@ M.funcs = {
<
]=],
name = 'synIDattr',
params = { { 'synID', 'any' }, { 'what', 'any' }, { 'mode', 'string' } },
params = { { 'synID', 'integer' }, { 'what', 'string' }, { 'mode', 'string' } },
returns = 'string',
signature = 'synIDattr({synID}, {what} [, {mode}])',
},
synIDtrans = {
@ -11186,7 +11225,8 @@ M.funcs = {
]=],
name = 'synIDtrans',
params = { { 'synID', 'any' } },
params = { { 'synID', 'integer' } },
returns = 'integer',
signature = 'synIDtrans({synID})',
},
synconcealed = {
@ -11219,6 +11259,7 @@ M.funcs = {
]=],
name = 'synconcealed',
params = { { 'lnum', 'integer' }, { 'col', 'integer' } },
returns = '{[1]: integer, [2]: string, [3]: integer}[]',
signature = 'synconcealed({lnum}, {col})',
},
synstack = {
@ -11244,6 +11285,7 @@ M.funcs = {
]=],
name = 'synstack',
params = { { 'lnum', 'integer' }, { 'col', 'integer' } },
returns = 'integer[]',
signature = 'synstack({lnum}, {col})',
},
system = {
@ -11301,7 +11343,11 @@ M.funcs = {
]=],
name = 'system',
params = { { 'cmd', 'any' }, { 'input', 'any' } },
params = {
{ 'cmd', 'string|string[]' },
{ 'input', 'string|string[]|integer' },
},
returns = 'string',
signature = 'system({cmd} [, {input}])',
},
systemlist = {
@ -11323,7 +11369,14 @@ M.funcs = {
]=],
name = 'systemlist',
params = { { 'cmd', 'any' }, { 'input', 'any' }, { 'keepempty', 'any' } },
params = {
{ 'cmd', 'string|string[]' },
{ 'input', 'string|string[]|integer' },
{ 'keepempty', 'integer' },
},
-- TODO(lewis6991): Not sure the '' return case is possible via vim.fn
-- returns = "string[]|''",
returns = 'string[]',
signature = 'systemlist({cmd} [, {input} [, {keepempty}]])',
},
tabpagebuflist = {
@ -11364,7 +11417,8 @@ M.funcs = {
Returns zero on error.
]=],
name = 'tabpagenr',
params = { { 'arg', 'any' } },
params = { { 'arg', "'$'|'#'" } },
returns = 'integer',
signature = 'tabpagenr([{arg}])',
},
tabpagewinnr = {
@ -11385,7 +11439,8 @@ M.funcs = {
]=],
name = 'tabpagewinnr',
params = { { 'tabarg', 'any' }, { 'arg', 'any' } },
params = { { 'tabarg', 'integer' }, { 'arg', "'$'|'#'" } },
returns = 'integer',
signature = 'tabpagewinnr({tabarg} [, {arg}])',
},
tagfiles = {
@ -11395,6 +11450,7 @@ M.funcs = {
]=],
name = 'tagfiles',
params = {},
returns = 'string[]',
signature = 'tagfiles()',
},
taglist = {
@ -11445,7 +11501,7 @@ M.funcs = {
]=],
name = 'taglist',
params = { { 'expr', 'any' }, { 'filename', 'any' } },
params = { { 'expr', 'any' }, { 'filename', 'string' } },
signature = 'taglist({expr} [, {filename}])',
},
tan = {
@ -11465,7 +11521,8 @@ M.funcs = {
]=],
float_func = 'tan',
name = 'tan',
params = { { 'expr', 'any' } },
params = { { 'expr', 'number' } },
returns = 'number',
signature = 'tan({expr})',
},
tanh = {
@ -11485,7 +11542,8 @@ M.funcs = {
]=],
float_func = 'tanh',
name = 'tanh',
params = { { 'expr', 'any' } },
params = { { 'expr', 'number' } },
returns = 'number',
signature = 'tanh({expr})',
},
tempname = {
@ -11537,7 +11595,7 @@ M.funcs = {
},
test_write_list_log = {
args = 1,
params = { { 'fname' } },
params = { { 'fname', 'string' } },
signature = '',
lua = false,
},
@ -11699,7 +11757,8 @@ M.funcs = {
]=],
name = 'tr',
params = { { 'src', 'any' }, { 'fromstr', 'any' }, { 'tostr', 'any' } },
params = { { 'src', 'string' }, { 'fromstr', 'string' }, { 'tostr', 'string' } },
returns = 'string',
signature = 'tr({src}, {fromstr}, {tostr})',
},
trim = {
@ -11732,7 +11791,7 @@ M.funcs = {
]=],
name = 'trim',
params = { { 'text', 'any' }, { 'mask', 'any' }, { 'dir', 'string' } },
params = { { 'text', 'any' }, { 'mask', 'string' }, { 'dir', '0|1|2' } },
returns = 'string',
signature = 'trim({text} [, {mask} [, {dir}]])',
},
@ -11756,6 +11815,7 @@ M.funcs = {
float_func = 'trunc',
name = 'trunc',
params = { { 'expr', 'any' } },
returns = 'integer',
signature = 'trunc({expr})',
},
type = {
@ -11792,6 +11852,7 @@ M.funcs = {
fast = true,
name = 'type',
params = { { 'expr', 'any' } },
returns = 'integer',
signature = 'type({expr})',
},
undofile = {
@ -11862,7 +11923,7 @@ M.funcs = {
item.
]=],
name = 'undotree',
params = { { 'buf', 'any' } },
params = { { 'buf', 'integer|string' } },
signature = 'undotree([{buf}])',
},
uniq = {