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.lua324
1 files changed, 288 insertions, 36 deletions
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index 55f4721c3a..b7120d5dd5 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -17,7 +17,7 @@
--- @field deprecated? true
--- @field returns? string|false
--- @field returns_desc? string
---- @field signature string
+--- @field signature? string
--- @field desc? string
--- @field params {[1]:string, [2]:string, [3]:string}[]
--- @field lua? false Do not render type information
@@ -809,7 +809,7 @@ M.funcs = {
<
]=],
name = 'bufname',
- params = { { 'buf', 'any' } },
+ params = { { 'buf', 'integer|string' } },
returns = 'string',
signature = 'bufname([{buf}])',
},
@@ -832,7 +832,7 @@ M.funcs = {
]=],
name = 'bufnr',
- params = { { 'buf', 'any' }, { 'create', 'any' } },
+ params = { { 'buf', 'integer|string' }, { 'create', 'any' } },
returns = 'integer',
signature = 'bufnr([{buf} [, {create}]])',
},
@@ -1373,6 +1373,8 @@ M.funcs = {
no item is selected when using the <Up> or
<Down> keys)
inserted Inserted string. [NOT IMPLEMENTED YET]
+ preview_winid Info floating preview window id.
+ preview_bufnr Info floating preview buffer id.
*complete_info_mode*
mode values are:
@@ -2114,7 +2116,7 @@ M.funcs = {
name = 'execute',
params = {
{ 'command', 'string|string[]' },
- { 'silent', "''|'silent'|'silent!'" }
+ { 'silent', "''|'silent'|'silent!'" },
},
returns = 'string',
signature = 'execute({command} [, {silent}])',
@@ -2200,6 +2202,7 @@ M.funcs = {
echo exists("*strftime")
echo exists("*s:MyFunc")
echo exists("*MyFunc")
+ echo exists("*v:lua.Func")
echo exists("bufcount")
echo exists(":Make")
echo exists("#CursorHold")
@@ -2346,9 +2349,20 @@ M.funcs = {
]=],
name = 'expand',
- params = { { 'string', 'string' }, { 'nosuf', 'boolean' }, { 'list', 'any' } },
- returns = 'string|string[]',
+ params = { { 'string', 'string' }, { 'nosuf', 'boolean' }, { 'list', 'nil|false' } },
signature = 'expand({string} [, {nosuf} [, {list}]])',
+ returns = 'string',
+ },
+ expand__1 = {
+ args = { 3 },
+ base = 1,
+ name = 'expand',
+ params = {
+ { 'string', 'string' },
+ { 'nosuf', 'boolean' },
+ { 'list', 'true|number|string|table' },
+ },
+ returns = 'string|string[]',
},
expandcmd = {
args = { 1, 2 },
@@ -2910,10 +2924,51 @@ M.funcs = {
returns = 'string',
signature = 'foldtextresult({lnum})',
},
+ foreach = {
+ args = 2,
+ base = 1,
+ desc = [=[
+ {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
+ For each item in {expr1} execute {expr2}. {expr1} is not
+ modified; its values may be, as with |:lockvar| 1. |E741|
+ See |map()| and |filter()| to modify {expr1}.
+
+ {expr2} must be a |string| or |Funcref|.
+
+ If {expr2} is a |string|, inside {expr2} |v:val| has the value
+ of the current item. For a |Dictionary| |v:key| has the key
+ of the current item and for a |List| |v:key| has the index of
+ the current item. For a |Blob| |v:key| has the index of the
+ current byte. For a |String| |v:key| has the index of the
+ current character.
+ Examples: >vim
+ call foreach(mylist, 'let used[v:val] = v:true')
+ <This records the items that are in the {expr1} list.
+
+ Note that {expr2} is the result of expression and is then used
+ as a command. Often it is good to use a |literal-string| to
+ avoid having to double backslashes.
+
+ If {expr2} is a |Funcref| it must take two arguments:
+ 1. the key or the index of the current item.
+ 2. the value of the current item.
+ With a lambda you don't get an error if it only accepts one
+ argument.
+ If the function returns a value, it is ignored.
+
+ Returns {expr1} in all cases.
+ When an error is encountered while executing {expr2} no
+ further items in {expr1} are processed.
+ When {expr2} is a Funcref errors inside a function are ignored,
+ unless it was defined with the "abort" flag.
+ ]=],
+ name = 'foreach',
+ params = { { 'expr1', 'any' }, { 'expr2', 'any' } },
+ signature = 'foreach({expr1}, {expr2})',
+ },
foreground = {
args = 0,
params = {},
- signature = '',
lua = false,
},
fullcommand = {
@@ -3164,6 +3219,8 @@ M.funcs = {
bufnr Buffer number.
changed TRUE if the buffer is modified.
changedtick Number of changes made to the buffer.
+ command TRUE if the buffer belongs to the
+ command-line window |cmdwin|.
hidden TRUE if the buffer is hidden.
lastused Timestamp in seconds, like
|localtime()|, when the buffer was
@@ -3406,7 +3463,7 @@ M.funcs = {
32 mouse double click
64 mouse triple click
96 mouse quadruple click (== 32 + 64)
- 128 command (Macintosh only)
+ 128 command (Mac) or super
Only the modifiers that have not been included in the
character itself are obtained. Thus Shift-a results in "A"
without a modifier. Returns 0 if no modifiers are used.
@@ -3607,6 +3664,7 @@ M.funcs = {
help help subjects
highlight highlight groups
history |:history| suboptions
+ keymap keyboard mappings
locale locale names (as output of locale -a)
mapclear buffer argument
mapping mapping name
@@ -3915,9 +3973,16 @@ M.funcs = {
|getbufoneline()|
]=],
name = 'getline',
- params = { { 'lnum', 'integer' }, { 'end', 'any' } },
- returns = 'string|string[]',
+ params = { { 'lnum', 'integer|string' }, { 'end', 'nil|false' } },
signature = 'getline({lnum} [, {end}])',
+ returns = 'string',
+ },
+ getline__1 = {
+ args = { 2 },
+ base = 1,
+ name = 'getline',
+ params = { { 'lnum', 'integer' }, { 'end', 'true|number|string|table' } },
+ returns = 'string|string[]',
},
getloclist = {
args = { 1, 2 },
@@ -4246,9 +4311,16 @@ M.funcs = {
]=],
name = 'getreg',
- params = { { 'regname', 'string' }, { 'list', 'any' } },
- returns = 'string|string[]',
+ params = { { 'regname', 'string' }, { 'list', 'nil|false' } },
signature = 'getreg([{regname} [, 1 [, {list}]]])',
+ returns = 'string',
+ },
+ getreg__1 = {
+ args = { 3 },
+ base = 1,
+ name = 'getreg',
+ params = { { 'regname', 'string' }, { 'list', 'true|number|string|table' } },
+ returns = 'string|string[]',
},
getreginfo = {
args = { 0, 1 },
@@ -4283,6 +4355,65 @@ M.funcs = {
returns = 'table',
signature = 'getreginfo([{regname}])',
},
+ getregion = {
+ args = { 2, 3 },
+ base = 1,
+ desc = [=[
+ Returns the list of strings from {pos1} to {pos2} from a
+ buffer.
+
+ {pos1} and {pos2} must both be |List|s with four numbers.
+ See |getpos()| for the format of the list. It's possible
+ to specify positions from a different buffer, but please
+ note the limitations at |getregion-notes|.
+
+ The optional argument {opts} is a Dict and supports the
+ following items:
+
+ type Specify the region's selection type
+ (default: "v"):
+ "v" for |charwise| mode
+ "V" for |linewise| mode
+ "<CTRL-V>" for |blockwise-visual| mode
+
+ exclusive If |TRUE|, use exclusive selection
+ for the end position
+ (default: follow 'selection')
+
+ You can get the last selection type by |visualmode()|.
+ If Visual mode is active, use |mode()| to get the Visual mode
+ (e.g., in a |:vmap|).
+ This function is useful to get text starting and ending in
+ different columns, such as a |charwise-visual| selection.
+
+ *getregion-notes*
+ Note that:
+ - Order of {pos1} and {pos2} doesn't matter, it will always
+ return content from the upper left position to the lower
+ right position.
+ - If 'virtualedit' is enabled and the region is past the end
+ of the lines, resulting lines are padded with spaces.
+ - If the region is blockwise and it starts or ends in the
+ middle of a multi-cell character, it is not included but
+ its selected part is substituted with spaces.
+ - If {pos1} and {pos2} are not in the same buffer, an empty
+ list is returned.
+ - {pos1} and {pos2} must belong to a |bufloaded()| buffer.
+ - It is evaluated in current window context, which makes a
+ difference if the buffer is displayed in a window with
+ different 'virtualedit' or 'list' values.
+
+ Examples: >
+ :xnoremap <CR>
+ \ <Cmd>echom getregion(
+ \ getpos('v'), getpos('.'), #{ type: mode() })<CR>
+ <
+ ]=],
+ name = 'getregion',
+ params = { { 'pos1', 'table' }, { 'pos2', 'table' }, { 'opts', 'table' } },
+ returns = 'string[]',
+ signature = 'getregion({pos1}, {pos2} [, {opts}])',
+ },
getregtype = {
args = { 0, 1 },
base = 1,
@@ -4519,7 +4650,7 @@ M.funcs = {
name = 'getwininfo',
params = { { 'winid', 'integer' } },
signature = 'getwininfo([{winid}])',
- returns = 'vim.fn.getwininfo.ret.item[]'
+ returns = 'vim.fn.getwininfo.ret.item[]',
},
getwinpos = {
args = { 0, 1 },
@@ -5095,7 +5226,7 @@ M.funcs = {
]=],
name = 'indent',
- params = { { 'lnum', 'integer' } },
+ params = { { 'lnum', 'integer|string' } },
returns = 'integer',
signature = 'indent({lnum})',
},
@@ -5735,8 +5866,7 @@ M.funcs = {
Vim value. In the following cases it will output
|msgpack-special-dict|:
1. Dictionary contains duplicate key.
- 2. Dictionary contains empty key.
- 3. String contains NUL byte. Two special dictionaries: for
+ 2. String contains NUL byte. Two special dictionaries: for
dictionary and for string will be emitted in case string
with NUL byte was a dictionary key.
@@ -6216,10 +6346,22 @@ M.funcs = {
{ 'name', 'string' },
{ 'mode', 'string' },
{ 'abbr', 'boolean' },
- { 'dict', 'boolean' },
+ { 'dict', 'false' },
},
- returns = 'string|table<string,any>',
signature = 'maparg({name} [, {mode} [, {abbr} [, {dict}]]])',
+ returns = 'string',
+ },
+ maparg__1 = {
+ args = { 4 },
+ base = 1,
+ name = 'maparg',
+ params = {
+ { 'name', 'string' },
+ { 'mode', 'string' },
+ { 'abbr', 'boolean' },
+ { 'dict', 'true' },
+ },
+ returns = 'string|table<string,any>',
},
mapcheck = {
args = { 1, 3 },
@@ -6297,7 +6439,7 @@ M.funcs = {
]],
name = 'maplist',
params = {},
- signature = 'maplist([{abbr}])'
+ signature = 'maplist([{abbr}])',
},
mapnew = {
args = 2,
@@ -6315,6 +6457,13 @@ M.funcs = {
mapset = {
args = { 1, 3 },
base = 1,
+ name = 'mapset',
+ params = { { 'mode', 'string' }, { 'abbr', 'any' }, { 'dict', 'any' } },
+ signature = 'mapset({mode}, {abbr}, {dict})',
+ },
+ mapset__1 = {
+ args = { 1, 3 },
+ base = 1,
desc = [=[
Restore a mapping from a dictionary, possibly returned by
|maparg()| or |maplist()|. A buffer mapping, when dict.buffer
@@ -6352,8 +6501,8 @@ M.funcs = {
endfor
]=],
name = 'mapset',
- params = { { 'mode', 'string' }, { 'abbr', 'any' }, { 'dict', 'any' } },
- signature = 'mapset({mode}, {abbr}, {dict})',
+ params = { { 'dict', 'any' } },
+ signature = 'mapset({dict})',
},
match = {
args = { 2, 4 },
@@ -6411,6 +6560,7 @@ M.funcs = {
Note that when {count} is added the way {start} works changes,
see above.
+ *match-pattern*
See |pattern| for the patterns that are accepted.
The 'ignorecase' option is used to set the ignore-caseness of
the pattern. 'smartcase' is NOT used. The matching is always
@@ -6569,6 +6719,63 @@ M.funcs = {
params = { { 'nr', 'integer' } },
signature = 'matcharg({nr})',
},
+ matchbufline = {
+ args = { 4, 5 },
+ base = 1,
+ desc = [=[
+ Returns the |List| of matches in lines from {lnum} to {end} in
+ buffer {buf} where {pat} matches.
+
+ {lnum} and {end} can either be a line number or the string "$"
+ to refer to the last line in {buf}.
+
+ The {dict} argument supports following items:
+ submatches include submatch information (|/\(|)
+
+ For each match, a |Dict| with the following items is returned:
+ byteidx starting byte index of the match
+ lnum line number where there is a match
+ text matched string
+ Note that there can be multiple matches in a single line.
+
+ This function works only for loaded buffers. First call
+ |bufload()| if needed.
+
+ See |match-pattern| for information about the effect of some
+ option settings on the pattern.
+
+ When {buf} is not a valid buffer, the buffer is not loaded or
+ {lnum} or {end} is not valid then an error is given and an
+ empty |List| is returned.
+
+ Examples: >vim
+ " Assuming line 3 in buffer 5 contains "a"
+ :echo matchbufline(5, '\<\k\+\>', 3, 3)
+ [{'lnum': 3, 'byteidx': 0, 'text': 'a'}]
+ " Assuming line 4 in buffer 10 contains "tik tok"
+ :echo matchbufline(10, '\<\k\+\>', 1, 4)
+ [{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}]
+ <
+ If {submatch} is present and is v:true, then submatches like
+ "\1", "\2", etc. are also returned. Example: >vim
+ " Assuming line 2 in buffer 2 contains "acd"
+ :echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2
+ \ {'submatches': v:true})
+ [{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]
+ <The "submatches" List always contains 9 items. If a submatch
+ is not found, then an empty string is returned for that
+ submatch.
+ ]=],
+ name = 'matchbufline',
+ params = {
+ { 'buf', 'string|integer' },
+ { 'pat', 'string' },
+ { 'lnum', 'string|integer' },
+ { 'end', 'string|integer' },
+ { 'dict', 'table' },
+ },
+ signature = 'matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}])',
+ },
matchdelete = {
args = { 1, 2 },
base = 1,
@@ -6753,6 +6960,46 @@ M.funcs = {
params = { { 'expr', 'any' }, { 'pat', 'any' }, { 'start', 'any' }, { 'count', 'any' } },
signature = 'matchstr({expr}, {pat} [, {start} [, {count}]])',
},
+ matchstrlist = {
+ args = { 2, 3 },
+ base = 1,
+ desc = [=[
+ Returns the |List| of matches in {list} where {pat} matches.
+ {list} is a |List| of strings. {pat} is matched against each
+ string in {list}.
+
+ The {dict} argument supports following items:
+ submatches include submatch information (|/\(|)
+
+ For each match, a |Dict| with the following items is returned:
+ byteidx starting byte index of the match.
+ idx index in {list} of the match.
+ text matched string
+ submatches a List of submatches. Present only if
+ "submatches" is set to v:true in {dict}.
+
+ See |match-pattern| for information about the effect of some
+ option settings on the pattern.
+
+ Example: >vim
+ :echo matchstrlist(['tik tok'], '\<\k\+\>')
+ [{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}]
+ :echo matchstrlist(['a', 'b'], '\<\k\+\>')
+ [{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}]
+ <
+ If "submatches" is present and is v:true, then submatches like
+ "\1", "\2", etc. are also returned. Example: >vim
+ :echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)',
+ \ #{submatches: v:true})
+ [{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]
+ <The "submatches" List always contains 9 items. If a submatch
+ is not found, then an empty string is returned for that
+ submatch.
+ ]=],
+ name = 'matchstrlist',
+ params = { { 'list', 'string[]' }, { 'pat', 'string' }, { 'dict', 'table' } },
+ signature = 'matchstrlist({list}, {pat} [, {dict}])',
+ },
matchstrpos = {
args = { 2, 4 },
base = 1,
@@ -6790,7 +7037,7 @@ M.funcs = {
it returns the maximum of all values in the Dictionary.
If {expr} is neither a List nor a Dictionary, or one of the
items in {expr} cannot be used as a Number this results in
- an error. An empty |List| or |Dictionary| results in zero.
+ an error. An empty |List| or |Dictionary| results in zero.
]=],
name = 'max',
@@ -7056,7 +7303,7 @@ M.funcs = {
]=],
name = 'mode',
- params = {},
+ params = { { 'expr', 'any' } },
signature = 'mode([expr])',
},
msgpackdump = {
@@ -7155,7 +7402,6 @@ M.funcs = {
are binary strings).
2. String with NUL byte inside.
3. Duplicate key.
- 4. Empty key.
ext |List| with two values: first is a signed integer
representing extension type. Second is
|readfile()|-style list of strings.
@@ -7445,9 +7691,9 @@ M.funcs = {
<This limits the length of the text used from "line" to
"width" bytes.
- If the argument to be formatted is specified using a posional
- argument specifier, and a '*' is used to indicate that a
- number argument is to be used to specify the width or
+ If the argument to be formatted is specified using a
+ positional argument specifier, and a '*' is used to indicate
+ that a number argument is to be used to specify the width or
precision, the argument(s) to be used must also be specified
using a {n$} positional argument specifier. See |printf-$|.
@@ -9524,7 +9770,7 @@ M.funcs = {
]=],
name = 'setreg',
- params = { { 'regname', 'string' }, { 'value', 'any' }, { 'options', 'table' } },
+ params = { { 'regname', 'string' }, { 'value', 'any' }, { 'options', 'string' } },
signature = 'setreg({regname}, {value} [, {options}])',
},
settabvar = {
@@ -9905,7 +10151,7 @@ M.funcs = {
name = 'sign_jump',
params = { { 'id', 'integer' }, { 'group', 'string' }, { 'buf', 'integer|string' } },
signature = 'sign_jump({id}, {group}, {buf})',
- returns = 'integer'
+ returns = 'integer',
},
sign_place = {
args = { 4, 5 },
@@ -9968,7 +10214,7 @@ M.funcs = {
{ 'dict', 'vim.fn.sign_place.dict' },
},
signature = 'sign_place({id}, {group}, {name}, {buf} [, {dict}])',
- returns = 'integer'
+ returns = 'integer',
},
sign_placelist = {
args = 1,
@@ -10035,7 +10281,7 @@ M.funcs = {
name = 'sign_placelist',
params = { { 'list', 'vim.fn.sign_placelist.list.item[]' } },
signature = 'sign_placelist({list})',
- returns = 'integer[]'
+ returns = 'integer[]',
},
sign_undefine = {
args = { 0, 1 },
@@ -10570,7 +10816,7 @@ M.funcs = {
signature = 'stdpath({what})',
},
state = {
- args = {0, 1},
+ args = { 0, 1 },
base = 1,
desc = [=[
Return a string which contains characters indicating the
@@ -11112,9 +11358,16 @@ M.funcs = {
]=],
name = 'submatch',
+ params = { { 'nr', 'integer' }, { 'list', 'nil' } },
+ signature = 'submatch({nr} [, {list}])',
+ returns = 'string',
+ },
+ submatch__1 = {
+ args = { 2 },
+ base = 1,
+ name = 'submatch',
params = { { 'nr', 'integer' }, { 'list', 'integer' } },
returns = 'string|string[]',
- signature = 'submatch({nr} [, {list}])',
},
substitute = {
args = 4,
@@ -11365,7 +11618,7 @@ M.funcs = {
]=],
name = 'synconcealed',
params = { { 'lnum', 'integer' }, { 'col', 'integer' } },
- returns = '{[1]: integer, [2]: string, [3]: integer}[]',
+ returns = '{[1]: integer, [2]: string, [3]: integer}',
signature = 'synconcealed({lnum}, {col})',
},
synstack = {
@@ -11702,7 +11955,6 @@ M.funcs = {
test_write_list_log = {
args = 1,
params = { { 'fname', 'string' } },
- signature = '',
lua = false,
},
timer_info = {
@@ -12698,7 +12950,7 @@ M.funcs = {
name = 'winsaveview',
params = {},
signature = 'winsaveview()',
- returns = 'vim.fn.winsaveview.ret'
+ returns = 'vim.fn.winsaveview.ret',
},
winwidth = {
args = 1,