aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/eval.lua')
-rw-r--r--src/nvim/eval.lua946
1 files changed, 568 insertions, 378 deletions
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index 7d4438ded6..50aaf9e03b 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -19,7 +19,9 @@
--- @field returns_desc? string
--- @field signature? string
--- @field desc? string
---- @field params {[1]:string, [2]:string, [3]:string}[]
+--- @field params [string, string, string][]
+--- @field notes? string[]
+--- @field see? string[]
--- @field lua? false Do not render type information
--- @field tags? string[] Extra tags
--- @field data? string Used by gen_eval.lua
@@ -52,7 +54,7 @@ M.funcs = {
]=],
name = 'abs',
- params = { { 'expr', 'any' } },
+ params = { { 'expr', 'number' } },
signature = 'abs({expr})',
returns = 'number',
},
@@ -75,7 +77,7 @@ M.funcs = {
]=],
float_func = 'acos',
name = 'acos',
- params = { { 'expr', 'any' } },
+ params = { { 'expr', 'number' } },
returns = 'number',
signature = 'acos({expr})',
},
@@ -97,6 +99,7 @@ M.funcs = {
name = 'add',
params = { { 'object', 'any' }, { 'expr', 'any' } },
returns = 'any',
+ returns_desc = [=[Resulting |List| or |Blob|, or 1 if {object} is not a |List| or a |Blob|.]=],
signature = 'add({object}, {expr})',
},
['and'] = {
@@ -111,7 +114,7 @@ M.funcs = {
<
]=],
name = 'and',
- params = { { 'expr', 'any' }, { 'expr', 'any' } },
+ params = { { 'expr', 'number' }, { 'expr', 'number' } },
returns = 'integer',
signature = 'and({expr}, {expr})',
},
@@ -149,7 +152,7 @@ M.funcs = {
]=],
name = 'append',
- params = { { 'lnum', 'integer' }, { 'text', 'any' } },
+ params = { { 'lnum', 'integer' }, { 'text', 'string|string[]' } },
returns = '0|1',
signature = 'append({lnum}, {text})',
},
@@ -179,7 +182,7 @@ M.funcs = {
]=],
name = 'appendbufline',
- params = { { 'buf', 'any' }, { 'lnum', 'integer' }, { 'text', 'string' } },
+ params = { { 'buf', 'integer|string' }, { 'lnum', 'integer' }, { 'text', 'string' } },
returns = '0|1',
signature = 'appendbufline({buf}, {lnum}, {text})',
},
@@ -289,7 +292,7 @@ M.funcs = {
]=],
name = 'assert_beeps',
- params = { { 'cmd', 'any' } },
+ params = { { 'cmd', 'string' } },
returns = '0|1',
signature = 'assert_beeps({cmd})',
},
@@ -301,16 +304,17 @@ M.funcs = {
added to |v:errors| and 1 is returned. Otherwise zero is
returned. |assert-return|
The error is in the form "Expected {expected} but got
- {actual}". When {msg} is present it is prefixed to that.
+ {actual}". When {msg} is present it is prefixed to that,
+ along with the location of the assert when run from a script.
There is no automatic conversion, the String "4" is different
from the Number 4. And the number 4 is different from the
Float 4.0. The value of 'ignorecase' is not used here, case
always matters.
Example: >vim
- assert_equal('foo', 'bar')
- <Will result in a string to be added to |v:errors|:
- test.vim line 12: Expected 'foo' but got 'bar' ~
+ call assert_equal('foo', 'bar', 'baz')
+ <Will add the following to |v:errors|:
+ test.vim line 12: baz: Expected 'foo' but got 'bar' ~
]=],
name = 'assert_equal',
@@ -330,7 +334,7 @@ M.funcs = {
]=],
name = 'assert_equalfile',
- params = {},
+ params = { { 'fname-one', 'string' }, { 'fname-two', 'string' } },
returns = '0|1',
signature = 'assert_equalfile({fname-one}, {fname-two})',
},
@@ -366,25 +370,25 @@ M.funcs = {
When {error} is a string it must be found literally in the
first reported error. Most often this will be the error code,
including the colon, e.g. "E123:". >vim
- assert_fails('bad cmd', 'E987:')
+ call assert_fails('bad cmd', 'E987:')
<
When {error} is a |List| with one or two strings, these are
used as patterns. The first pattern is matched against the
first reported error: >vim
- assert_fails('cmd', ['E987:.*expected bool'])
+ call assert_fails('cmd', ['E987:.*expected bool'])
<The second pattern, if present, is matched against the last
reported error. To only match the last error use an empty
string for the first error: >vim
- assert_fails('cmd', ['', 'E987:'])
+ call assert_fails('cmd', ['', 'E987:'])
<
If {msg} is empty then it is not used. Do this to get the
default message when passing the {lnum} argument.
-
+ *E1115*
When {lnum} is present and not negative, and the {error}
argument is present and matches, then this is compared with
the line number at which the error was reported. That can be
the line number in a function or in a script.
-
+ *E1116*
When {context} is present it is used as a pattern and matched
against the context (script name or function name) where
{lnum} is located in.
@@ -395,7 +399,7 @@ M.funcs = {
]=],
name = 'assert_fails',
params = {
- { 'cmd', 'any' },
+ { 'cmd', 'string' },
{ 'error', 'any' },
{ 'msg', 'any' },
{ 'lnum', 'integer' },
@@ -411,7 +415,8 @@ M.funcs = {
When {actual} is not false an error message is added to
|v:errors|, like with |assert_equal()|.
The error is in the form "Expected False but got {actual}".
- When {msg} is present it is prepended to that.
+ When {msg} is present it is prefixed to that, along with the
+ location of the assert when run from a script.
Also see |assert-return|.
A value is false when it is zero. When {actual} is not a
@@ -435,7 +440,12 @@ M.funcs = {
that.
]=],
name = 'assert_inrange',
- params = { { 'lower', 'any' }, { 'upper', 'any' }, { 'actual', 'any' }, { 'msg', 'any' } },
+ params = {
+ { 'lower', 'number' },
+ { 'upper', 'number' },
+ { 'actual', 'number' },
+ { 'msg', 'string' },
+ },
returns = '0|1',
signature = 'assert_inrange({lower}, {upper}, {actual} [, {msg}])',
},
@@ -446,7 +456,8 @@ M.funcs = {
When {pattern} does not match {actual} an error message is
added to |v:errors|. Also see |assert-return|.
The error is in the form "Pattern {pattern} does not match
- {actual}". When {msg} is present it is prefixed to that.
+ {actual}". When {msg} is present it is prefixed to that,
+ along with the location of the assert when run from a script.
{pattern} is used as with |expr-=~|: The matching is always done
like 'magic' was set and 'cpoptions' is empty, no matter what
@@ -457,13 +468,13 @@ M.funcs = {
Use both to match the whole text.
Example: >vim
- assert_match('^f.*o$', 'foobar')
+ call assert_match('^f.*o$', 'foobar')
<Will result in a string to be added to |v:errors|:
test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
]=],
name = 'assert_match',
- params = { { 'pattern', 'any' }, { 'actual', 'any' }, { 'msg', 'any' } },
+ params = { { 'pattern', 'string' }, { 'actual', 'string' }, { 'msg', 'string' } },
returns = '0|1',
signature = 'assert_match({pattern}, {actual} [, {msg}])',
},
@@ -477,7 +488,7 @@ M.funcs = {
]=],
name = 'assert_nobeep',
- params = { { 'cmd', 'any' } },
+ params = { { 'cmd', 'string' } },
returns = '0|1',
signature = 'assert_nobeep({cmd})',
},
@@ -505,7 +516,7 @@ M.funcs = {
]=],
name = 'assert_notmatch',
- params = { { 'pattern', 'any' }, { 'actual', 'any' }, { 'msg', 'any' } },
+ params = { { 'pattern', 'string' }, { 'actual', 'string' }, { 'msg', 'string' } },
returns = '0|1',
signature = 'assert_notmatch({pattern}, {actual} [, {msg}])',
},
@@ -518,7 +529,7 @@ M.funcs = {
]=],
name = 'assert_report',
- params = { { 'msg', 'any' } },
+ params = { { 'msg', 'string' } },
returns = '0|1',
signature = 'assert_report({msg})',
},
@@ -531,11 +542,12 @@ M.funcs = {
Also see |assert-return|.
A value is |TRUE| when it is a non-zero number or |v:true|.
When {actual} is not a number or |v:true| the assert fails.
- When {msg} is given it precedes the default message.
+ When {msg} is given it is prefixed to the default message,
+ along with the location of the assert when run from a script.
]=],
name = 'assert_true',
- params = { { 'actual', 'any' }, { 'msg', 'any' } },
+ params = { { 'actual', 'any' }, { 'msg', 'string' } },
returns = '0|1',
signature = 'assert_true({actual} [, {msg}])',
},
@@ -556,7 +568,7 @@ M.funcs = {
]=],
float_func = 'atan',
name = 'atan',
- params = { { 'expr', 'any' } },
+ params = { { 'expr', 'number' } },
returns = 'number',
signature = 'atan({expr})',
},
@@ -577,7 +589,7 @@ M.funcs = {
]=],
name = 'atan2',
- params = { { 'expr1', 'any' }, { 'expr2', 'any' } },
+ params = { { 'expr1', 'number' }, { 'expr2', 'number' } },
returns = 'number',
signature = 'atan2({expr1}, {expr2})',
},
@@ -612,7 +624,12 @@ M.funcs = {
something went wrong, or browsing is not possible.
]=],
name = 'browse',
- params = { { 'save', 'any' }, { 'title', 'any' }, { 'initdir', 'any' }, { 'default', 'any' } },
+ params = {
+ { 'save', 'any' },
+ { 'title', 'string' },
+ { 'initdir', 'string' },
+ { 'default', 'string' },
+ },
returns = '0|1',
signature = 'browse({save}, {title}, {initdir}, {default})',
},
@@ -631,7 +648,7 @@ M.funcs = {
browsing is not possible, an empty string is returned.
]=],
name = 'browsedir',
- params = { { 'title', 'any' }, { 'initdir', 'any' } },
+ params = { { 'title', 'string' }, { 'initdir', 'string' } },
returns = '0|1',
signature = 'browsedir({title}, {initdir})',
},
@@ -1000,7 +1017,7 @@ M.funcs = {
]=],
float_func = 'ceil',
name = 'ceil',
- params = { { 'expr', 'any' } },
+ params = { { 'expr', 'number' } },
returns = 'number',
signature = 'ceil({expr})',
},
@@ -1017,7 +1034,7 @@ M.funcs = {
omitted.
]=],
name = 'chanclose',
- params = { { 'id', 'any' }, { 'stream', 'any' } },
+ params = { { 'id', 'integer' }, { 'stream', 'string' } },
returns = '0|1',
signature = 'chanclose({id} [, {stream}])',
},
@@ -1057,7 +1074,7 @@ M.funcs = {
messages, use |rpcnotify()| and |rpcrequest()| instead.
]=],
name = 'chansend',
- params = { { 'id', 'any' }, { 'data', 'any' } },
+ params = { { 'id', 'number' }, { 'data', 'string|string[]' } },
returns = '0|1',
signature = 'chansend({id}, {data})',
},
@@ -1116,10 +1133,11 @@ M.funcs = {
With the cursor on '세' in line 5 with text "여보세요": >vim
echo charcol('.') " returns 3
echo col('.') " returns 7
+ <
]=],
name = 'charcol',
- params = { { 'expr', 'any' }, { 'winid', 'integer' } },
+ params = { { 'expr', 'string|integer[]' }, { 'winid', 'integer' } },
returns = 'integer',
signature = 'charcol({expr} [, {winid}])',
},
@@ -1164,8 +1182,8 @@ M.funcs = {
params = {
{ 'string', 'string' },
{ 'idx', 'integer' },
- { 'countcc', 'any' },
- { 'utf16', 'any' },
+ { 'countcc', 'boolean' },
+ { 'utf16', 'boolean' },
},
returns = 'integer',
signature = 'charidx({string}, {idx} [, {countcc} [, {utf16}]])',
@@ -1194,6 +1212,7 @@ M.funcs = {
" ... do some work
call chdir(save_dir)
endif
+ <
]=],
name = 'chdir',
@@ -1229,7 +1248,7 @@ M.funcs = {
]=],
name = 'clearmatches',
- params = { { 'win', 'any' } },
+ params = { { 'win', 'integer' } },
returns = false,
signature = 'clearmatches([{win}])',
},
@@ -1238,33 +1257,33 @@ M.funcs = {
base = 1,
desc = [=[
The result is a Number, which is the byte index of the column
- position given with {expr}. The accepted positions are:
- . the cursor position
- $ the end of the cursor line (the result is the
- number of bytes in the cursor line plus one)
- 'x position of mark x (if the mark is not set, 0 is
- returned)
- v In Visual mode: the start of the Visual area (the
- cursor is the end). When not in Visual mode
- returns the cursor position. Differs from |'<| in
- that it's updated right away.
+ position given with {expr}.
+ For accepted positions see |getpos()|.
+ When {expr} is "$", it means the end of the cursor line, so
+ the result is the number of bytes in the cursor line plus one.
Additionally {expr} can be [lnum, col]: a |List| with the line
and column number. Most useful when the column is "$", to get
the last column of a specific line. When "lnum" or "col" is
out of range then col() returns zero.
+
With the optional {winid} argument the values are obtained for
that window instead of the current window.
+
To get the line number use |line()|. To get both use
|getpos()|.
+
For the screen column position use |virtcol()|. For the
character position use |charcol()|.
+
Note that only marks in the current file can be used.
+
Examples: >vim
echo col(".") " column of cursor
echo col("$") " length of cursor line plus one
echo col("'t") " column of mark t
echo col("'" .. markname) " column of mark markname
- <The first column is 1. Returns 0 if {expr} is invalid or when
+ <
+ The first column is 1. Returns 0 if {expr} is invalid or when
the window with ID {winid} is not found.
For an uppercase mark the column may actually be in another
buffer.
@@ -1273,10 +1292,11 @@ M.funcs = {
line. Also, when using a <Cmd> mapping the cursor isn't
moved, this can be used to obtain the column in Insert mode: >vim
imap <F2> <Cmd>echo col(".").."\n"<CR>
+ <
]=],
name = 'col',
- params = { { 'expr', 'any' }, { 'winid', 'integer' } },
+ params = { { 'expr', 'string|integer[]' }, { 'winid', 'integer' } },
returns = 'integer',
signature = 'col({expr} [, {winid}])',
},
@@ -1315,7 +1335,7 @@ M.funcs = {
]=],
name = 'complete',
- params = { { 'startcol', 'any' }, { 'matches', 'any' } },
+ params = { { 'startcol', 'integer' }, { 'matches', 'any[]' } },
returns = false,
signature = 'complete({startcol}, {matches})',
tags = { 'E785' },
@@ -1414,10 +1434,11 @@ M.funcs = {
call complete_info(['mode'])
" Get only 'mode' and 'pum_visible'
call complete_info(['mode', 'pum_visible'])
+ <
]=],
name = 'complete_info',
- params = { { 'what', 'any' } },
+ params = { { 'what', 'any[]' } },
returns = 'table',
signature = 'complete_info([{what}])',
},
@@ -1478,7 +1499,12 @@ M.funcs = {
]=],
name = 'confirm',
- params = { { 'msg', 'any' }, { 'choices', 'any' }, { 'default', 'any' }, { 'type', 'any' } },
+ params = {
+ { 'msg', 'string' },
+ { 'choices', 'string' },
+ { 'default', 'integer' },
+ { 'type', 'string' },
+ },
returns = 'integer',
signature = 'confirm({msg} [, {choices} [, {default} [, {type}]]])',
},
@@ -1516,7 +1542,7 @@ M.funcs = {
]=],
float_func = 'cos',
name = 'cos',
- params = { { 'expr', 'any' } },
+ params = { { 'expr', 'number' } },
returns = 'number',
signature = 'cos({expr})',
},
@@ -1537,7 +1563,7 @@ M.funcs = {
]=],
float_func = 'cosh',
name = 'cosh',
- params = { { 'expr', 'any' } },
+ params = { { 'expr', 'number' } },
returns = 'number',
signature = 'cosh({expr})',
},
@@ -1560,7 +1586,12 @@ M.funcs = {
]=],
name = 'count',
- params = { { 'comp', 'any' }, { 'expr', 'any' }, { 'ic', 'any' }, { 'start', 'any' } },
+ params = {
+ { 'comp', 'string|table|any[]' },
+ { 'expr', 'any' },
+ { 'ic', 'boolean' },
+ { 'start', 'integer' },
+ },
returns = 'integer',
signature = 'count({comp}, {expr} [, {ic} [, {start}]])',
},
@@ -1572,7 +1603,7 @@ M.funcs = {
If {index} is not given, it is assumed to be 0 (i.e.: top).
]=],
name = 'ctxget',
- params = { { 'index', 'any' } },
+ params = { { 'index', 'integer' } },
returns = 'table',
signature = 'ctxget([{index}])',
},
@@ -1595,7 +1626,7 @@ M.funcs = {
Otherwise, all context types are included.
]=],
name = 'ctxpush',
- params = { { 'types', 'any' } },
+ params = { { 'types', 'string[]' } },
signature = 'ctxpush([{types}])',
},
ctxset = {
@@ -1607,7 +1638,7 @@ M.funcs = {
If {index} is not given, it is assumed to be 0 (i.e.: top).
]=],
name = 'ctxset',
- params = { { 'context', 'any' }, { 'index', 'any' } },
+ params = { { 'context', 'table' }, { 'index', 'integer' } },
signature = 'ctxset({context} [, {index}])',
},
ctxsize = {
@@ -1622,7 +1653,7 @@ M.funcs = {
args = { 1, 3 },
base = 1,
name = 'cursor',
- params = { { 'lnum', 'integer' }, { 'col', 'integer' }, { 'off', 'any' } },
+ params = { { 'lnum', 'integer' }, { 'col', 'integer' }, { 'off', 'integer' } },
signature = 'cursor({lnum}, {col} [, {off}])',
},
cursor__1 = {
@@ -1662,7 +1693,7 @@ M.funcs = {
]=],
name = 'cursor',
- params = { { 'list', 'any' } },
+ params = { { 'list', 'integer[]' } },
signature = 'cursor({list})',
},
debugbreak = {
@@ -1679,7 +1710,7 @@ M.funcs = {
]=],
name = 'debugbreak',
- params = { { 'pid', 'any' } },
+ params = { { 'pid', 'integer' } },
signature = 'debugbreak({pid})',
},
deepcopy = {
@@ -1708,7 +1739,7 @@ M.funcs = {
]=],
name = 'deepcopy',
- params = { { 'expr', 'any' }, { 'noref', 'any' } },
+ params = { { 'expr', 'any' }, { 'noref', 'boolean' } },
signature = 'deepcopy({expr} [, {noref}])',
},
delete = {
@@ -1758,7 +1789,11 @@ M.funcs = {
]=],
name = 'deletebufline',
- params = { { 'buf', 'any' }, { 'first', 'any' }, { 'last', 'any' } },
+ params = {
+ { 'buf', 'integer|string' },
+ { 'first', 'integer|string' },
+ { 'last', 'integer|string' },
+ },
signature = 'deletebufline({buf}, {first} [, {last}])',
},
dictwatcheradd = {
@@ -1804,7 +1839,7 @@ M.funcs = {
validation and parsing logic.
]=],
name = 'dictwatcheradd',
- params = { { 'dict', 'any' }, { 'pattern', 'any' }, { 'callback', 'any' } },
+ params = { { 'dict', 'table' }, { 'pattern', 'string' }, { 'callback', 'function' } },
signature = 'dictwatcheradd({dict}, {pattern}, {callback})',
},
dictwatcherdel = {
@@ -1815,7 +1850,7 @@ M.funcs = {
order for the watcher to be successfully deleted.
]=],
name = 'dictwatcherdel',
- params = { { 'dict', 'any' }, { 'pattern', 'any' }, { 'callback', 'any' } },
+ params = { { 'dict', 'any' }, { 'pattern', 'string' }, { 'callback', 'function' } },
signature = 'dictwatcherdel({dict}, {pattern}, {callback})',
},
did_filetype = {
@@ -1894,7 +1929,7 @@ M.funcs = {
<
]=],
name = 'digraph_get',
- params = { { 'chars', 'any' } },
+ params = { { 'chars', 'string' } },
signature = 'digraph_get({chars})',
},
digraph_getlist = {
@@ -1916,7 +1951,7 @@ M.funcs = {
<
]=],
name = 'digraph_getlist',
- params = { { 'listall', 'any' } },
+ params = { { 'listall', 'boolean' } },
signature = 'digraph_getlist([{listall}])',
},
digraph_set = {
@@ -1939,12 +1974,9 @@ M.funcs = {
Example: >vim
call digraph_set(' ', 'あ')
<
- Can be used as a |method|: >vim
- GetString()->digraph_set('あ')
- <
]=],
name = 'digraph_set',
- params = { { 'chars', 'any' }, { 'digraph', 'any' } },
+ params = { { 'chars', 'string' }, { 'digraph', 'string' } },
signature = 'digraph_set({chars}, {digraph})',
},
digraph_setlist = {
@@ -1964,13 +1996,9 @@ M.funcs = {
endfor
<Except that the function returns after the first error,
following digraphs will not be added.
-
- Can be used as a |method|: >vim
- GetList()->digraph_setlist()
- <
]=],
name = 'digraph_setlist',
- params = { { 'digraphlist', 'any' } },
+ params = { { 'digraphlist', 'table<integer,string[]>' } },
signature = 'digraph_setlist({digraphlist})',
},
empty = {
@@ -2019,7 +2047,7 @@ M.funcs = {
]=],
fast = true,
name = 'escape',
- params = { { 'string', 'string' }, { 'chars', 'any' } },
+ params = { { 'string', 'string' }, { 'chars', 'string' } },
signature = 'escape({string}, {chars})',
},
eval = {
@@ -2055,19 +2083,26 @@ M.funcs = {
This function checks if an executable with the name {expr}
exists. {expr} must be the name of the program without any
arguments.
+
executable() uses the value of $PATH and/or the normal
- searchpath for programs. *PATHEXT*
+ searchpath for programs.
+ *PATHEXT*
On MS-Windows the ".exe", ".bat", etc. can optionally be
included. Then the extensions in $PATHEXT are tried. Thus if
"foo.exe" does not exist, "foo.exe.bat" can be found. If
- $PATHEXT is not set then ".exe;.com;.bat;.cmd" is used. A dot
+ $PATHEXT is not set then ".com;.exe;.bat;.cmd" is used. A dot
by itself can be used in $PATHEXT to try using the name
without an extension. When 'shell' looks like a Unix shell,
then the name is also tried without adding an extension.
On MS-Windows it only checks if the file exists and is not a
directory, not if it's really executable.
- On Windows an executable in the same directory as Vim is
- always found (it is added to $PATH at |startup|).
+ On MS-Windows an executable in the same directory as the Vim
+ executable is always found (it's added to $PATH at |startup|).
+ *NoDefaultCurrentDirectoryInExePath*
+ On MS-Windows an executable in Vim's current working directory
+ is also normally found, but this can be disabled by setting
+ the $NoDefaultCurrentDirectoryInExePath environment variable.
+
The result is a Number:
1 exists
0 does not exist
@@ -2076,7 +2111,7 @@ M.funcs = {
]=],
fast = true,
name = 'executable',
- params = { { 'expr', 'any' } },
+ params = { { 'expr', 'string' } },
returns = '0|1',
signature = 'executable({expr})',
},
@@ -2131,8 +2166,9 @@ M.funcs = {
]=],
name = 'exepath',
- params = { { 'expr', 'any' } },
+ params = { { 'expr', 'string' } },
signature = 'exepath({expr})',
+ returns = 'string',
},
exists = {
args = 1,
@@ -2228,7 +2264,7 @@ M.funcs = {
]=],
name = 'exists',
- params = { { 'expr', 'any' } },
+ params = { { 'expr', 'string' } },
returns = '0|1',
signature = 'exists({expr})',
},
@@ -2249,7 +2285,7 @@ M.funcs = {
]=],
float_func = 'exp',
name = 'exp',
- params = { { 'expr', 'any' } },
+ params = { { 'expr', 'number' } },
signature = 'exp({expr})',
},
expand = {
@@ -2435,7 +2471,7 @@ M.funcs = {
]=],
name = 'extend',
- params = { { 'expr1', 'any' }, { 'expr2', 'any' }, { 'expr3', 'any' } },
+ params = { { 'expr1', 'table' }, { 'expr2', 'table' }, { 'expr3', 'table' } },
signature = 'extend({expr1}, {expr2} [, {expr3}])',
},
extendnew = {
@@ -2447,7 +2483,7 @@ M.funcs = {
unchanged.
]=],
name = 'extendnew',
- params = { { 'expr1', 'any' }, { 'expr2', 'any' }, { 'expr3', 'any' } },
+ params = { { 'expr1', 'table' }, { 'expr2', 'table' }, { 'expr3', 'table' } },
signature = 'extendnew({expr1}, {expr2} [, {expr3}])',
},
feedkeys = {
@@ -2516,6 +2552,23 @@ M.funcs = {
params = { { 'file', 'string' } },
signature = 'file_readable({file})',
},
+ filecopy = {
+ args = 2,
+ base = 1,
+ desc = [[
+ Copy the file pointed to by the name {from} to {to}. The
+ result is a Number, which is |TRUE| if the file was copied
+ successfully, and |FALSE| when it failed.
+ If a file with name {to} already exists, it will fail.
+ Note that it does not handle directories (yet).
+
+ This function is not available in the |sandbox|.
+ ]],
+ name = 'filecopy',
+ params = { { 'from', 'string' }, { 'to', 'string' } },
+ returns = '0|1',
+ signature = 'filecopy({from}, {to})',
+ },
filereadable = {
args = 1,
base = 1,
@@ -2617,7 +2670,7 @@ M.funcs = {
]=],
name = 'filter',
- params = { { 'expr1', 'any' }, { 'expr2', 'any' } },
+ params = { { 'expr1', 'string|table' }, { 'expr2', 'string|function' } },
signature = 'filter({expr1}, {expr2})',
},
finddir = {
@@ -2643,7 +2696,7 @@ M.funcs = {
]=],
name = 'finddir',
- params = { { 'name', 'string' }, { 'path', 'string' }, { 'count', 'any' } },
+ params = { { 'name', 'string' }, { 'path', 'string' }, { 'count', 'integer' } },
signature = 'finddir({name} [, {path} [, {count}]])',
},
findfile = {
@@ -2686,7 +2739,7 @@ M.funcs = {
]=],
name = 'flatten',
- params = { { 'list', 'any' }, { 'maxdepth', 'any' } },
+ params = { { 'list', 'any[]' }, { 'maxdepth', 'integer' } },
returns = 'any[]|0',
signature = 'flatten({list} [, {maxdepth}])',
},
@@ -2697,7 +2750,7 @@ M.funcs = {
Like |flatten()| but first make a copy of {list}.
]=],
name = 'flattennew',
- params = { { 'list', 'any' }, { 'maxdepth', 'any' } },
+ params = { { 'list', 'any[]' }, { 'maxdepth', 'integer' } },
returns = 'any[]|0',
signature = 'flattennew({list} [, {maxdepth}])',
},
@@ -2728,7 +2781,7 @@ M.funcs = {
]=],
name = 'float2nr',
- params = { { 'expr', 'any' } },
+ params = { { 'expr', 'number' } },
signature = 'float2nr({expr})',
},
floor = {
@@ -2750,7 +2803,7 @@ M.funcs = {
]=],
float_func = 'floor',
name = 'floor',
- params = { { 'expr', 'any' } },
+ params = { { 'expr', 'number' } },
signature = 'floor({expr})',
},
fmod = {
@@ -2774,7 +2827,7 @@ M.funcs = {
]=],
name = 'fmod',
- params = { { 'expr1', 'any' }, { 'expr2', 'any' } },
+ params = { { 'expr1', 'number' }, { 'expr2', 'number' } },
signature = 'fmod({expr1}, {expr2})',
},
fnameescape = {
@@ -2963,7 +3016,7 @@ M.funcs = {
unless it was defined with the "abort" flag.
]=],
name = 'foreach',
- params = { { 'expr1', 'any' }, { 'expr2', 'any' } },
+ params = { { 'expr1', 'string|table' }, { 'expr2', 'string|function' } },
signature = 'foreach({expr1}, {expr2})',
},
foreground = {
@@ -3126,7 +3179,7 @@ M.funcs = {
type a character.
]=],
name = 'garbagecollect',
- params = { { 'atexit', 'any' } },
+ params = { { 'atexit', 'boolean' } },
signature = 'garbagecollect([{atexit}])',
},
get = {
@@ -3140,6 +3193,7 @@ M.funcs = {
name = 'get',
params = { { 'list', 'any[]' }, { 'idx', 'integer' }, { 'default', 'any' } },
signature = 'get({list}, {idx} [, {default}])',
+ tags = { 'get()-list' },
},
get__1 = {
args = { 2, 3 },
@@ -3152,6 +3206,7 @@ M.funcs = {
name = 'get',
params = { { 'blob', 'string' }, { 'idx', 'integer' }, { 'default', 'any' } },
signature = 'get({blob}, {idx} [, {default}])',
+ tags = { 'get()-blob' },
},
get__2 = {
args = { 2, 3 },
@@ -3167,23 +3222,38 @@ M.funcs = {
name = 'get',
params = { { 'dict', 'table<string,any>' }, { 'key', 'string' }, { 'default', 'any' } },
signature = 'get({dict}, {key} [, {default}])',
+ tags = { 'get()-dict' },
},
get__3 = {
args = { 2, 3 },
base = 1,
desc = [=[
- Get item {what} from Funcref {func}. Possible values for
+ Get item {what} from |Funcref| {func}. Possible values for
{what} are:
- "name" The function name
- "func" The function
- "dict" The dictionary
- "args" The list with arguments
+ "name" The function name
+ "func" The function
+ "dict" The dictionary
+ "args" The list with arguments
+ "arity" A dictionary with information about the number of
+ arguments accepted by the function (minus the
+ {arglist}) with the following fields:
+ required the number of positional arguments
+ optional the number of optional arguments,
+ in addition to the required ones
+ varargs |TRUE| if the function accepts a
+ variable number of arguments |...|
+
+ Note: There is no error, if the {arglist} of
+ the Funcref contains more arguments than the
+ Funcref expects, it's not validated.
+
Returns zero on error.
]=],
name = 'get',
params = { { 'func', 'function' }, { 'what', 'string' } },
returns = 'any',
signature = 'get({func}, {what})',
+ tags = { 'get()-func' },
},
getbufinfo = {
args = { 0, 1 },
@@ -3296,10 +3366,11 @@ M.funcs = {
Example: >vim
let lines = getbufline(bufnr("myfile"), 1, "$")
+ <
]=],
name = 'getbufline',
- params = { { 'buf', 'any' }, { 'lnum', 'integer' }, { 'end', 'integer' } },
+ params = { { 'buf', 'integer|string' }, { 'lnum', 'integer' }, { 'end', 'integer' } },
signature = 'getbufline({buf}, {lnum} [, {end}])',
},
getbufoneline = {
@@ -3340,7 +3411,7 @@ M.funcs = {
]=],
name = 'getbufvar',
- params = { { 'buf', 'any' }, { 'varname', 'string' }, { 'def', 'any' } },
+ params = { { 'buf', 'integer|string' }, { 'varname', 'string' }, { 'def', 'any' } },
signature = 'getbufvar({buf}, {varname} [, {def}])',
},
getcellwidths = {
@@ -3447,7 +3518,7 @@ M.funcs = {
<
]=],
name = 'getchar',
- params = {},
+ params = { { 'expr', '0|1' } },
returns = 'integer',
signature = 'getchar([{expr}])',
},
@@ -3491,7 +3562,7 @@ M.funcs = {
<
]=],
name = 'getcharpos',
- params = { { 'expr', 'any' } },
+ params = { { 'expr', 'string' } },
returns = 'integer[]',
signature = 'getcharpos({expr})',
},
@@ -3518,7 +3589,7 @@ M.funcs = {
]=],
name = 'getcharsearch',
params = {},
- returns = 'table[]',
+ returns = 'table',
signature = 'getcharsearch()',
},
getcharstr = {
@@ -3536,7 +3607,7 @@ M.funcs = {
result is converted to a string.
]=],
name = 'getcharstr',
- params = {},
+ params = { { 'expr', '0|1' } },
returns = 'string',
signature = 'getcharstr([{expr}])',
},
@@ -3546,8 +3617,8 @@ M.funcs = {
Only works when the command line is being edited, thus
requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
See |:command-completion| for the return string.
- Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()| and
- |setcmdline()|.
+ Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
+ |getcmdprompt()| and |setcmdline()|.
Returns an empty string when completion is not defined.
]=],
name = 'getcmdcompltype',
@@ -3557,13 +3628,13 @@ M.funcs = {
},
getcmdline = {
desc = [=[
- Return the current command-line. Only works when the command
- line is being edited, thus requires use of |c_CTRL-\_e| or
- |c_CTRL-R_=|.
+ Return the current command-line input. Only works when the
+ command line is being edited, thus requires use of
+ |c_CTRL-\_e| or |c_CTRL-R_=|.
Example: >vim
cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR>
- <Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()| and
- |setcmdline()|.
+ <Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()|,
+ |getcmdprompt()| and |setcmdline()|.
Returns an empty string when entering a password or using
|inputsecret()|.
]=],
@@ -3579,14 +3650,28 @@ M.funcs = {
Only works when editing the command line, thus requires use of
|c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
Returns 0 otherwise.
- Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()| and
- |setcmdline()|.
+ Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
+ |getcmdprompt()| and |setcmdline()|.
]=],
name = 'getcmdpos',
params = {},
returns = 'integer',
signature = 'getcmdpos()',
},
+ getcmdprompt = {
+ desc = [=[
+ Return the current command-line prompt when using functions
+ like |input()| or |confirm()|.
+ Only works when the command line is being edited, thus
+ requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
+ Also see |getcmdtype()|, |getcmdline()|, |getcmdpos()|,
+ |setcmdpos()| and |setcmdline()|.
+ ]=],
+ name = 'getcmdprompt',
+ params = {},
+ returns = 'string',
+ signature = 'getcmdprompt()',
+ },
getcmdscreenpos = {
desc = [=[
Return the screen position of the cursor in the command line
@@ -3654,6 +3739,7 @@ M.funcs = {
customlist,{func} custom completion, defined via {func}
diff_buffer |:diffget| and |:diffput| completion
dir directory names
+ dir_in_path directory names in |'cdpath'|
environment environment variable names
event autocommand events
expression Vim expression
@@ -3708,7 +3794,7 @@ M.funcs = {
]=],
name = 'getcompletion',
- params = { { 'pat', 'any' }, { 'type', 'any' }, { 'filtered', 'any' } },
+ params = { { 'pat', 'string' }, { 'type', 'string' }, { 'filtered', 'boolean' } },
returns = 'string[]',
signature = 'getcompletion({pat}, {type} [, {filtered}])',
},
@@ -4019,7 +4105,7 @@ M.funcs = {
<
]=],
name = 'getloclist',
- params = { { 'nr', 'integer' }, { 'what', 'any' } },
+ params = { { 'nr', 'integer' }, { 'what', 'table' } },
signature = 'getloclist({nr} [, {what}])',
},
getmarklist = {
@@ -4046,8 +4132,9 @@ M.funcs = {
]=],
name = 'getmarklist',
- params = { { 'buf', 'any' } },
+ params = { { 'buf', 'integer?' } },
signature = 'getmarklist([{buf}])',
+ returns = 'vim.fn.getmarklist.ret.item[]',
},
getmatches = {
args = { 0, 1 },
@@ -4084,7 +4171,7 @@ M.funcs = {
<
]=],
name = 'getmatches',
- params = { { 'win', 'any' } },
+ params = { { 'win', 'integer' } },
signature = 'getmatches([{win}])',
},
getmousepos = {
@@ -4139,9 +4226,34 @@ M.funcs = {
args = 1,
base = 1,
desc = [=[
- Get the position for String {expr}. For possible values of
- {expr} see |line()|. For getting the cursor position see
- |getcurpos()|.
+ Get the position for String {expr}.
+ The accepted values for {expr} are:
+ . The cursor position.
+ $ The last line in the current buffer.
+ 'x Position of mark x (if the mark is not set, 0 is
+ returned for all values).
+ w0 First line visible in current window (one if the
+ display isn't updated, e.g. in silent Ex mode).
+ w$ Last line visible in current window (this is one
+ less than "w0" if no lines are visible).
+ v When not in Visual mode, returns the