aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-12-07 01:14:21 -0500
committerGitHub <noreply@github.com>2021-12-07 01:14:21 -0500
commitafaad8b54ebd2ad4ba2145f4069f5017cace3c8f (patch)
tree462cb857957f22fa3f8111d766c27907aebb19b4
parentbf9e8a9df90941320ed898ac4c6351b78366a0a8 (diff)
parent6e3e8c51c0919df4d407b323d0e9237c278e2c23 (diff)
downloadrneovim-afaad8b54ebd2ad4ba2145f4069f5017cace3c8f.tar.gz
rneovim-afaad8b54ebd2ad4ba2145f4069f5017cace3c8f.tar.bz2
rneovim-afaad8b54ebd2ad4ba2145f4069f5017cace3c8f.zip
Merge pull request #16194 from seandewar/vim-8.1.1925
vim-patch:7.4.1777,8.1.{1925,1995,2011,2012,2013,2166},8.2.{0532,0871,1168,1241,3576}
-rw-r--r--runtime/doc/eval.txt303
-rw-r--r--runtime/doc/sign.txt27
-rw-r--r--runtime/doc/testing.txt3
-rw-r--r--src/nvim/eval.lua188
-rw-r--r--src/nvim/eval/funcs.c3
-rw-r--r--src/nvim/testdir/test_autocmd.vim3
-rw-r--r--src/nvim/testdir/test_breakindent.vim2
-rw-r--r--src/nvim/testdir/test_bufwintabinfo.vim5
-rw-r--r--src/nvim/testdir/test_cd.vim2
-rw-r--r--src/nvim/testdir/test_charsearch.vim2
-rw-r--r--src/nvim/testdir/test_clientserver.vim2
-rw-r--r--src/nvim/testdir/test_cmdline.vim2
-rw-r--r--src/nvim/testdir/test_compiler.vim10
-rw-r--r--src/nvim/testdir/test_cursor_func.vim6
-rw-r--r--src/nvim/testdir/test_diffmode.vim2
-rw-r--r--src/nvim/testdir/test_environ.vim2
-rw-r--r--src/nvim/testdir/test_execute_func.vim2
-rw-r--r--src/nvim/testdir/test_expr.vim6
-rw-r--r--src/nvim/testdir/test_fold.vim3
-rw-r--r--src/nvim/testdir/test_functions.vim37
-rw-r--r--src/nvim/testdir/test_listchars.vim2
-rw-r--r--src/nvim/testdir/test_marks.vim4
-rw-r--r--src/nvim/testdir/test_matchadd_conceal_utf8.vim2
-rw-r--r--src/nvim/testdir/test_messages.vim2
-rw-r--r--src/nvim/testdir/test_mksession.vim3
-rw-r--r--src/nvim/testdir/test_options.vim3
-rw-r--r--src/nvim/testdir/test_prompt_buffer.vim4
-rw-r--r--src/nvim/testdir/test_put.vim2
-rw-r--r--src/nvim/testdir/test_quickfix.vim4
-rw-r--r--src/nvim/testdir/test_ruby.vim2
-rw-r--r--src/nvim/testdir/test_search.vim37
-rw-r--r--src/nvim/testdir/test_sha256.vim10
-rw-r--r--src/nvim/testdir/test_signs.vim19
-rw-r--r--src/nvim/testdir/test_spell.vim6
-rw-r--r--src/nvim/testdir/test_spell_utf8.vim6
-rw-r--r--src/nvim/testdir/test_startup.vim6
-rw-r--r--src/nvim/testdir/test_substitute.vim5
-rw-r--r--src/nvim/testdir/test_swap.vim4
-rw-r--r--src/nvim/testdir/test_syntax.vim20
-rw-r--r--src/nvim/testdir/test_system.vim3
-rw-r--r--src/nvim/testdir/test_tabpage.vim4
-rw-r--r--src/nvim/testdir/test_tagjump.vim2
-rw-r--r--src/nvim/testdir/test_taglist.vim2
-rw-r--r--src/nvim/testdir/test_timers.vim10
-rw-r--r--src/nvim/testdir/test_undo.vim2
-rw-r--r--src/nvim/testdir/test_utf8.vim4
-rw-r--r--src/nvim/testdir/test_vartabs.vim2
-rw-r--r--src/nvim/testdir/test_window_cmd.vim29
-rw-r--r--src/nvim/testdir/test_window_id.vim17
-rw-r--r--test/functional/legacy/searchpos_spec.lua2
-rw-r--r--test/functional/vimscript/timer_spec.lua10
51 files changed, 582 insertions, 256 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 44cfffd85c..75b782fbff 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -3011,7 +3011,11 @@ bufadd({name}) *bufadd()*
number. Otherwise return the buffer number of the newly
created buffer. When {name} is an empty string then a new
buffer is always created.
- The buffer will not have' 'buflisted' set.
+ The buffer will not have 'buflisted' set and not be loaded
+ yet. To add some text to the buffer use this: >
+ let bufnr = bufadd('someName')
+ call bufload(bufnr)
+ call setbufline(bufnr, 1, ['some', 'text'])
< Can also be used as a |method|: >
let bufnr = 'somename'->bufadd()
@@ -3277,7 +3281,7 @@ char2nr({string} [, {utf8}]) *char2nr()*
Can also be used as a |method|: >
GetChar()->char2nr()
-
+<
*charidx()*
charidx({string}, {idx} [, {countcc}])
Return the character index of the byte at {idx} in {string}.
@@ -3300,6 +3304,9 @@ charidx({string}, {idx} [, {countcc}])
echo charidx('áb́ć', 3) returns 1
echo charidx('áb́ć', 6, 1) returns 4
echo charidx('áb́ć', 16) returns -1
+<
+ Can also be used as a |method|: >
+ GetName()->charidx(idx)
chdir({dir}) *chdir()*
Change the current working directory to {dir}. The scope of
@@ -3412,8 +3419,8 @@ complete({startcol}, {matches}) *complete()* *E785*
< This isn't very useful, but it shows how it works. Note that
an empty string is returned to avoid a zero being inserted.
- Can also be used as a |method|, the second argument is passed
- in: >
+ Can also be used as a |method|, the base is passed as the
+ second argument: >
GetMatches()->complete(col('.'))
complete_add({expr}) *complete_add()*
@@ -3550,7 +3557,7 @@ confirm({msg} [, {choices} [, {default} [, {type}]]])
Can also be used as a |method|in: >
BuildMessage()->confirm("&Yes\n&No")
-
+<
*copy()*
copy({expr}) Make a copy of {expr}. For Numbers and Strings this isn't
different from using {expr} directly.
@@ -3761,7 +3768,7 @@ deletebufline({buf}, {first}[, {last}]) *deletebufline()*
Can also be used as a |method|: >
GetBuffer()->deletebufline(1)
-
+<
dictwatcheradd({dict}, {pattern}, {callback}) *dictwatcheradd()*
Adds a watcher to a dictionary. A dictionary watcher is
identified by three components:
@@ -4379,6 +4386,9 @@ flatten({list} [, {maxdepth}]) *flatten()*
:echo flatten([1, [2, [3, 4]], 5], 1)
< [1, 2, [3, 4], 5]
+ Can also be used as a |method|: >
+ mylist->flatten()
+<
float2nr({expr}) *float2nr()*
Convert {expr} to a Number by omitting the part after the
decimal point.
@@ -4716,7 +4726,9 @@ getbufinfo([{dict}])
<
To get buffer-local options use: >
getbufvar({bufnr}, '&option_name')
-
+<
+ Can also be used as a |method|: >
+ GetBufnr()->getbufinfo()
<
*getbufline()*
getbufline({buf}, {lnum} [, {end}])
@@ -5218,6 +5230,9 @@ getmarklist([{buf}]) *getmarklist()*
Refer to |getpos()| for getting information about a specific
mark.
+ Can also be used as a |method|: >
+ GetBufnr()->getmarklist()
+
getmatches([{win}]) *getmatches()*
Returns a |List| with all matches previously defined for the
current window by |matchadd()| and the |:match| commands.
@@ -5871,9 +5886,9 @@ histadd({history}, {item}) *histadd()*
:let date=input("Enter date: ")
< This function is not available in the |sandbox|.
- Can also be used as a |method|, the base is used for the
+ Can also be used as a |method|, the base is passed as the
second argument: >
- GetPattern()->histadd('search')
+ GetHistory()->histadd('search')
histdel({history} [, {item}]) *histdel()*
Clear {history}, i.e. delete all its entries. See |hist-names|
@@ -6518,8 +6533,8 @@ libcall({libname}, {funcname}, {argument})
Examples: >
:echo libcall("libc.so", "getenv", "HOME")
-< Can also be used as a |method|, where the base is passed as
- the argument to the called function: >
+< Can also be used as a |method|, the base is passed as the
+ third argument: >
GetValue()->libcall("libc.so", "getenv")
<
*libcallnr()*
@@ -6531,8 +6546,8 @@ libcallnr({libname}, {funcname}, {argument})
:call libcallnr("libc.so", "printf", "Hello World!\n")
:call libcallnr("libc.so", "sleep", 10)
<
- Can also be used as a |method|, where the base is passed as
- the argument to the called function: >
+ Can also be used as a |method|, the base is passed as the
+ third argument: >
GetValue()->libcallnr("libc.so", "printf")
<
line({expr} [, {winid}]) *line()*
@@ -7056,7 +7071,7 @@ matchstrpos({expr}, {pat} [, {start} [, {count}]]) *matchstrpos()*
Can also be used as a |method|: >
GetText()->matchstrpos('word')
-
+<
*max()*
max({expr}) Return the maximum value of all items in {expr}.
{expr} can be a |List| or a |Dictionary|. For a Dictionary,
@@ -7606,6 +7621,9 @@ prompt_getprompt({buf}) *prompt_getprompt()*
If the buffer doesn't exist or isn't a prompt buffer, an empty
string is returned.
+ Can also be used as a |method|: >
+ GetBuffer()->prompt_getprompt()
+
prompt_setcallback({buf}, {expr}) *prompt_setcallback()*
Set prompt callback for buffer {buf} to {expr}. When {expr}
is an empty string the callback is removed. This has only
@@ -8091,6 +8109,9 @@ screenattr({row}, {col}) *screenattr()*
arbitrary number that can only be used to compare to the
attribute at other positions.
+ Can also be used as a |method|: >
+ GetRow()->screenattr(col)
+
screenchar({row}, {col}) *screenchar()*
The result is a Number, which is the character at position
[row, col] on the screen. This works for every possible
@@ -8101,6 +8122,9 @@ screenchar({row}, {col}) *screenchar()*
This is mainly to be used for testing.
Returns -1 when row or col is out of range.
+ Can also be used as a |method|: >
+ GetRow()->screenchar(col)
+
screenchars({row}, {col}) *screenchars()*
The result is a List of Numbers. The first number is the same
as what |screenchar()| returns. Further numbers are
@@ -8108,6 +8132,9 @@ screenchars({row}, {col}) *screenchars()*
This is mainly to be used for testing.
Returns an empty List when row or col is out of range.
+ Can also be used as a |method|: >
+ GetRow()->screenchars(col)
+
screencol() *screencol()*
The result is a Number, which is the current screen column of
the cursor. The leftmost column has number 1.
@@ -8143,6 +8170,9 @@ screenpos({winid}, {lnum}, {col}) *screenpos()*
right position and use |screencol()| to get the value with
|conceal| taken into account.
+ Can also be used as a |method|: >
+ GetWinid()->screenpos(lnum, col)
+
screenrow() *screenrow()*
The result is a Number, which is the current screen row of the
cursor. The top line has number one.
@@ -8159,6 +8189,9 @@ screenstring({row}, {col}) *screenstring()*
This is mainly to be used for testing.
Returns an empty String when row or col is out of range.
+ Can also be used as a |method|: >
+ GetRow()->screenstring(col)
+
search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *search()*
Search for regexp pattern {pattern}. The search starts at the
cursor position (you can use |cursor()| to set it).
@@ -8249,6 +8282,8 @@ search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *search()*
without the 'e' flag if the cursor is on the "f" of "if".
The 'n' flag tells the function not to move the cursor.
+ Can also be used as a |method|: >
+ GetPattern()->search()
searchcount([{options}]) *searchcount()*
Get or update the last search count, like what is displayed
@@ -8369,7 +8404,9 @@ searchcount([{options}]) *searchcount()*
value. see |cursor()|, |getpos()
(default: cursor's position)
-
+ Can also be used as a |method|: >
+ GetSearchOpts()->searchcount()
+<
searchdecl({name} [, {global} [, {thisblock}]]) *searchdecl()*
Search for the declaration of {name}.
@@ -8388,6 +8425,9 @@ searchdecl({name} [, {global} [, {thisblock}]]) *searchdecl()*
echo getline('.')
endif
<
+ Can also be used as a |method|: >
+ GetName()->searchdecl()
+<
*searchpair()*
searchpair({start}, {middle}, {end} [, {flags} [, {skip}
[, {stopline} [, {timeout}]]]])
@@ -8502,6 +8542,9 @@ searchpos({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *searchpos()*
< In this example "submatch" is 2 when a lowercase letter is
found |/\l|, 3 when an uppercase letter is found |/\u|.
+ Can also be used as a |method|: >
+ GetPattern()->searchpos()
+
server2client({clientid}, {string}) *server2client()*
Send a reply string to {clientid}. The most recent {clientid}
that sent a string can be retrieved with expand("<client>").
@@ -8513,6 +8556,9 @@ server2client({clientid}, {string}) *server2client()*
See also |clientserver|.
Example: >
:echo server2client(expand("<client>"), "HELLO")
+
+< Can also be used as a |method|: >
+ GetClientId()->server2client(string)
<
serverlist() *serverlist()*
Returns a list of server addresses, or empty if all servers
@@ -8579,6 +8625,10 @@ setbufline({buf}, {lnum}, {text}) *setbufline()*
If {buf} is not a valid buffer or {lnum} is not valid, an
error message is given.
+ Can also be used as a |method|, the base is passed as the
+ third argument: >
+ GetText()->setbufline(buf, lnum)
+
setbufvar({buf}, {varname}, {val}) *setbufvar()*
Set option or local variable {varname} in buffer {buf} to
{val}.
@@ -8593,6 +8643,10 @@ setbufvar({buf}, {varname}, {val}) *setbufvar()*
:call setbufvar("todo", "myvar", "foobar")
< This function is not available in the |sandbox|.
+ Can also be used as a |method|, the base is passed as the
+ third argument: >
+ GetValue()->setbufvar(buf, varname)
+
setcharsearch({dict}) *setcharsearch()*
Set the current character search information to {dict},
which contains one or more of the following entries:
@@ -8613,6 +8667,9 @@ setcharsearch({dict}) *setcharsearch()*
:call setcharsearch(prevsearch)
< Also see |getcharsearch()|.
+ Can also be used as a |method|: >
+ SavedSearch()->setcharsearch()
+
setcmdpos({pos}) *setcmdpos()*
Set the cursor position in the command line to byte position
{pos}. The first position is 1.
@@ -8628,6 +8685,9 @@ setcmdpos({pos}) *setcmdpos()*
Returns FALSE when successful, TRUE when not editing the
command line.
+ Can also be used as a |method|: >
+ GetPos()->setcmdpos()
+
setenv({name}, {val}) *setenv()*
Set environment variable {name} to {val}. Example: >
call setenv('HOME', '/home/myhome')
@@ -8635,6 +8695,10 @@ setenv({name}, {val}) *setenv()*
< When {val} is |v:null| the environment variable is deleted.
See also |expr-env|.
+ Can also be used as a |method|, the base is passed as the
+ second argument: >
+ GetPath()->setenv('PATH')
+
setfperm({fname}, {mode}) *setfperm()* *chmod*
Set the file permissions for {fname} to {mode}.
{mode} must be a string with 9 characters. It is of the form
@@ -8680,7 +8744,11 @@ setline({lnum}, {text}) *setline()*
< Note: The '[ and '] marks are not set.
-setloclist({nr}, {list}[, {action}[, {what}]]) *setloclist()*
+ Can also be used as a |method|, the base is passed as the
+ second argument: >
+ GetText()->setline(lnum)
+
+setloclist({nr}, {list} [, {action} [, {what}]]) *setloclist()*
Create or replace or add to the location list for window {nr}.
{nr} can be the window number or the |window-ID|.
When {nr} is zero the current window is used.
@@ -8696,6 +8764,10 @@ setloclist({nr}, {list}[, {action}[, {what}]]) *setloclist()*
only the items listed in {what} are set. Refer to |setqflist()|
for the list of supported keys in {what}.
+ Can also be used as a |method|, the base is passed as the
+ second argument: >
+ GetLoclist()->setloclist(winnr)
+
setmatches({list} [, {win}]) *setmatches()*
Restores a list of matches saved by |getmatches() for the
current window|. Returns 0 if successful, otherwise -1. All
@@ -8704,6 +8776,9 @@ setmatches({list} [, {win}]) *setmatches()*
If {win} is specified, use the window with this number or
window ID instead of the current window.
+ Can also be used as a |method|: >
+ GetMatches()->setmatches()
+<
*setpos()*
setpos({expr}, {list})
Set the position for String {expr}. Possible values:
@@ -8753,8 +8828,10 @@ setpos({expr}, {list})
also set the preferred column. Also see the "curswant" key in
|winrestview()|.
+ Can also be used as a |method|: >
+ GetPosition()->setpos('.')
-setqflist({list} [, {action}[, {what}]]) *setqflist()*
+setqflist({list} [, {action} [, {what}]]) *setqflist()*
Create or replace or add to the quickfix list.
If the optional {what} dictionary argument is supplied, then
@@ -8863,7 +8940,10 @@ setqflist({list} [, {action}[, {what}]]) *setqflist()*
independent of the 'errorformat' setting. Use a command like
`:cc 1` to jump to the first position.
-
+ Can also be used as a |method|, the base is passed as the
+ second argument: >
+ GetErrorlist()->setqflist()
+<
*setreg()*
setreg({regname}, {value} [, {options}])
Set the register {regname} to {value}.
@@ -8920,6 +9000,10 @@ setreg({regname}, {value} [, {options}])
nothing: >
:call setreg('a', '', 'al')
+< Can also be used as a |method|, the base is passed as the
+ second argument: >
+ GetText()->setreg('a')
+
settabvar({tabnr}, {varname}, {val}) *settabvar()*
Set tab-local variable {varname} to {val} in tab page {tabnr}.
|t:var|
@@ -8928,6 +9012,10 @@ settabvar({tabnr}, {varname}, {val}) *settabvar()*
Tabs are numbered starting with one.
This function is not available in the |sandbox|.
+ Can also be used as a |method|, the base is passed as the
+ third argument: >
+ GetValue()->settabvar(tab, name)
+
settabwinvar({tabnr}, {winnr}, {varname}, {val}) *settabwinvar()*
Set option or local variable {varname} in window {winnr} to
{val}.
@@ -8944,6 +9032,10 @@ settabwinvar({tabnr}, {winnr}, {varname}, {val}) *settabwinvar()*
:call settabwinvar(3, 2, "myvar", "foobar")
< This function is not available in the |sandbox|.
+ Can also be used as a |method|, the base is passed as the
+ fourth argument: >
+ GetValue()->settabwinvar(tab, winnr, name)
+
settagstack({nr}, {dict} [, {action}]) *settagstack()*
Modify the tag stack of the window {nr} using {dict}.
{nr} can be the window number or the |window-ID|.
@@ -8977,6 +9069,9 @@ settagstack({nr}, {dict} [, {action}]) *settagstack()*
call settagstack(1003, stack)
unlet stack
<
+ Can also be used as a |method|, the base is passed as the
+ second argument: >
+ GetStack()->settagstack(winnr)
setwinvar({nr}, {varname}, {val}) *setwinvar()*
Like |settabwinvar()| for the current tab page.
@@ -8984,10 +9079,17 @@ setwinvar({nr}, {varname}, {val}) *setwinvar()*
:call setwinvar(1, "&list", 0)
:call setwinvar(2, "myvar", "foobar")
+< Can also be used as a |method|, the base is passed as the
+ third argument: >
+ GetValue()->setwinvar(winnr, name)
+
sha256({string}) *sha256()*
Returns a String with 64 hex characters, which is the SHA256
checksum of {string}.
+ Can also be used as a |method|: >
+ GetText()->sha256()
+
shellescape({string} [, {special}]) *shellescape()*
Escape {string} for use as a shell command argument.
@@ -9019,6 +9121,8 @@ shellescape({string} [, {special}]) *shellescape()*
:call system("chmod +w -- " . shellescape(expand("%")))
< See also |::S|.
+ Can also be used as a |method|: >
+ GetCommand()->shellescape()
shiftwidth([{col}]) *shiftwidth()*
Returns the effective value of 'shiftwidth'. This is the
@@ -9041,6 +9145,9 @@ shiftwidth([{col}]) *shiftwidth()*
'vartabstop' feature. If no {col} argument is given, column 1
will be assumed.
+ Can also be used as a |method|: >
+ GetColumn()->shiftwidth()
+
sign_ functions are documented here: |sign-functions-details|
simplify({filename}) *simplify()*
@@ -9060,6 +9167,8 @@ simplify({filename}) *simplify()*
directory. In order to resolve all the involved symbolic
links before simplifying the path name, use |resolve()|.
+ Can also be used as a |method|: >
+ GetName()->simplify()
sin({expr}) *sin()*
Return the sine of {expr}, measured in radians, as a |Float|.
@@ -9191,6 +9300,9 @@ soundfold({word})
This can be used for making spelling suggestions. Note that
the method can be quite slow.
+ Can also be used as a |method|: >
+ GetWord()->soundfold()
+<
*spellbadword()*
spellbadword([{sentence}])
Without argument: The result is the badly spelled word under
@@ -9216,6 +9328,9 @@ spellbadword([{sentence}])
The spelling information for the current window and the value
of 'spelllang' are used.
+ Can also be used as a |method|: >
+ GetText()->spellbadword()
+<
*spellsuggest()*
spellsuggest({word} [, {max} [, {capital}]])
Return a |List| with spelling suggestions to replace {word}.
@@ -9238,6 +9353,8 @@ spellsuggest({word} [, {max} [, {capital}]])
The spelling information for the current window is used. The
values of 'spelllang' and 'spellsuggest' are used.
+ Can also be used as a |method|: >
+ GetWord()->spellsuggest()
split({string} [, {pattern} [, {keepempty}]]) *split()*
Make a |List| out of {string}. When {pattern} is omitted or
@@ -9361,7 +9478,7 @@ str2nr({string} [, {base}]) *str2nr()*
When {base} is omitted base 10 is used. This also means that
a leading zero doesn't cause octal conversion to be used, as
with the default String to Number conversion. Example: >
- let nr = str2nr('123')
+ let nr = str2nr('0123')
<
When {base} is 16 a leading "0x" or "0X" is ignored. With a
different base the result will be zero. Similarly, when
@@ -9369,6 +9486,20 @@ str2nr({string} [, {base}]) *str2nr()*
{base} is 2 a leading "0b" or "0B" is ignored.
Text after the number is silently ignored.
+ Can also be used as a |method|: >
+ GetText()->str2nr()
+
+strcharpart({src}, {start} [, {len}]) *strcharpart()*
+ Like |strpart()| but using character index and length instead
+ of byte index and length. Composing characters are counted
+ separately.
+ When a character index is used where a character does not
+ exist it is assumed to be one character. For example: >
+ strcharpart('abc', -1, 2)
+< results in 'a'.
+
+ Can also be used as a |method|: >
+ GetText()->strcharpart(5)
strchars({string} [, {skipcc}]) *strchars()*
The result is a Number, which is the number of characters
@@ -9394,14 +9525,8 @@ strchars({string} [, {skipcc}]) *strchars()*
endfunction
endif
<
-strcharpart({src}, {start} [, {len}]) *strcharpart()*
- Like |strpart()| but using character index and length instead
- of byte index and length. Composing characters are counted
- separately.
- When a character index is used where a character does not
- exist it is assumed to be one character. For example: >
- strcharpart('abc', -1, 2)
-< results in 'a'.
+ Can also be used as a |method|: >
+ GetText()->strchars()
strdisplaywidth({string} [, {col}]) *strdisplaywidth()*
The result is a Number, which is the number of display cells
@@ -9416,6 +9541,9 @@ strdisplaywidth({string} [, {col}]) *strdisplaywidth()*
Ambiguous, this function's return value depends on 'ambiwidth'.
Also see |strlen()|, |strwidth()| and |strchars()|.
+ Can also be used as a |method|: >
+ GetText()->strdisplaywidth()
+
strftime({format} [, {time}]) *strftime()*
The result is a String, which is a formatted date and time, as
specified by the {format} string. The given {time} is used,
@@ -9433,12 +9561,18 @@ strftime({format} [, {time}]) *strftime()*
:echo strftime("%c", getftime("file.c"))
Show mod time of file.c.
+< Can also be used as a |method|: >
+ GetFormat()->strftime()
+
strgetchar({str}, {index}) *strgetchar()*
Get character {index} from {str}. This uses a character
index, not a byte index. Composing characters are considered
separate characters here.
Also see |strcharpart()| and |strchars()|.
+ Can also be used as a |method|: >
+ GetText()->strgetchar(5)
+
stridx({haystack}, {needle} [, {start}]) *stridx()*
The result is a Number, which gives the byte index in
{haystack} of the first occurrence of the String {needle}.
@@ -9458,6 +9592,9 @@ stridx({haystack}, {needle} [, {start}]) *stridx()*
stridx() works similar to the C function strstr(). When used
with a single character it works similar to strchr().
+ Can also be used as a |method|: >
+ GetHaystack()->stridx(needle)
+
*string()*
string({expr}) Return {expr} converted to a String. If {expr} is a Number,
Float, String, Blob or a composition of them, then the result
@@ -9520,6 +9657,9 @@ strpart({src}, {start} [, {len} [, {chars}]]) *strpart()*
example, to get the character under the cursor: >
strpart(getline("."), col(".") - 1, 1, v:true)
<
+ Can also be used as a |method|: >
+ GetText()->strpart(5)
+
strptime({format}, {timestring}) *strptime()*
The result is a Number, which is a unix timestamp representing
the date and time in {timestring}, which is expected to match
@@ -9544,7 +9684,9 @@ strptime({format}, {timestring}) *strptime()*
:echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600)
< Sun Apr 27 12:53:55 1997
-
+ Can also be used as a |method|: >
+ GetFormat()->strptime(timestring)
+<
strridx({haystack}, {needle} [, {start}]) *strridx()*
The result is a Number, which gives the byte index in
{haystack} of the last occurrence of the String {needle}.
@@ -9563,6 +9705,9 @@ strridx({haystack}, {needle} [, {start}]) *strridx()*
When used with a single character it works similar to the C
function strrchr().
+ Can also be used as a |method|: >
+ GetHaystack()->strridx(needle)
+
strtrans({string}) *strtrans()*
The result is a String, which is {string} with all unprintable
characters translated into printable characters |'isprint'|.
@@ -9611,6 +9756,9 @@ submatch({nr} [, {list}]) *submatch()* *E935*
< This finds the first number in the line and adds one to it.
A line break is included as a newline character.
+ Can also be used as a |method|: >
+ GetNr()->submatch()
+
substitute({string}, {pat}, {sub}, {flags}) *substitute()*
The result is a String, which is a copy of {string}, in which
the first match of {pat} is replaced with {sub}.
@@ -9673,6 +9821,9 @@ swapinfo({fname}) *swapinfo()*
Not a swap file: does not contain correct block ID
Magic number mismatch: Info in first block is invalid
+ Can also be used as a |method|: >
+ GetFilename()->swapinfo()
+
swapname({buf}) *swapname()*
The result is the swap file path of the buffer {buf}.
For the use of {buf}, see |bufname()| above.
@@ -9680,6 +9831,9 @@ swapname({buf}) *swapname()*
|:swapname| (unless there is no swap file).
If buffer {buf} has no swap file, returns an empty string.
+ Can also be used as a |method|: >
+ GetBufname()->swapname()
+
synID({lnum}, {col}, {trans}) *synID()*
The result is a Number, which is the syntax ID at the position
{lnum} and {col} in the current window.
@@ -9876,6 +10030,8 @@ tabpagebuflist([{arg}]) *tabpagebuflist()*
endfor
< Note that a buffer may appear in more than one window.
+ Can also be used as a |method|: >
+ GetTabpage()->tabpagebuflist()
tabpagenr([{arg}]) *tabpagenr()*
The result is a Number, which is the number of the current
@@ -9902,6 +10058,9 @@ tabpagewinnr({tabarg} [, {arg}]) *tabpagewinnr()*
tabpagewinnr(4, '$') " number of windows in tab page 4
< When {tabarg} is invalid zero is returned.
+ Can also be used as a |method|: >
+ GetTabpage()->tabpagewinnr()
+<
*tagfiles()*
tagfiles() Returns a |List| with the file names used to search for tags
for the current buffer. This is the 'tags' option expanded.
@@ -9950,6 +10109,9 @@ taglist({expr} [, {filename}]) *taglist()*
located by Vim. Refer to |tags-file-format| for the format of
the tags file generated by the different ctags tools.
+ Can also be used as a |method|: >
+ GetTagpattern()->taglist()
+
tempname() *tempname()* *temp-file-name*
The result is a String, which is the name of a file that
doesn't exist. It can be used for a temporary file. Example: >
@@ -10017,6 +10179,9 @@ timer_info([{id}])
-1 means forever
"callback" the callback
+ Can also be used as a |method|: >
+ GetTimer()->timer_info()
+<
timer_pause({timer}, {paused}) *timer_pause()*
Pause or unpause a timer. A paused timer does not invoke its
callback when its time expires. Unpausing a timer may cause
@@ -10030,6 +10195,9 @@ timer_pause({timer}, {paused}) *timer_pause()*
String, then the timer is paused, otherwise it is unpaused.
See |non-zero-arg|.
+ Can also be used as a |method|: >
+ GetTimer()->timer_pause(1)
+<
*timer_start()* *timer* *timers*
timer_start({time}, {callback} [, {options}])
Create a timer and return the timer ID.
@@ -10057,11 +10225,19 @@ timer_start({time}, {callback} [, {options}])
\ {'repeat': 3})
< This invokes MyHandler() three times at 500 msec intervals.
+ Can also be used as a |method|: >
+ GetMsec()->timer_start(callback)
+
+< Not available in the |sandbox|.
+
timer_stop({timer}) *timer_stop()*
Stop a timer. The timer callback will no longer be invoked.
{timer} is an ID returned by timer_start(), thus it must be a
Number. If {timer} does not exist there is no error.
+ Can also be used as a |method|: >
+ GetTimer()->timer_stop()
+<
timer_stopall() *timer_stopall()*
Stop all timers. The timer callbacks will no longer be
invoked. Useful if some timers is misbehaving. If there are
@@ -10072,11 +10248,17 @@ tolower({expr}) *tolower()*
characters turned into lowercase (just like applying |gu| to
the string).
+ Can also be used as a |method|: >
+ GetText()->tolower()
+
toupper({expr}) *toupper()*
The result is a copy of the String given, with all lowercase
characters turned into uppercase (just like applying |gU| to
the string).
+ Can also be used as a |method|: >
+ GetText()->toupper()
+
tr({src}, {fromstr}, {tostr}) *tr()*
The result is a copy of the {src} string with all characters
which appear in {fromstr} replaced by the character in that
@@ -10091,6 +10273,9 @@ tr({src}, {fromstr}, {tostr}) *tr()*
echo tr("<blob>", "<>", "{}")
< returns "{blob}"
+ Can also be used as a |method|: >
+ GetText()->tr(from, to)
+
trim({text} [, {mask} [, {dir}]]) *trim()*
Return {text} as a String where any character in {mask} is
removed from the beginning and/or end of {text}.
@@ -10114,6 +10299,9 @@ trim({text} [, {mask} [, {dir}]]) *trim()*
echo trim(" vim ", " ", 2)
< returns " vim"
+ Can also be used as a |method|: >
+ GetText()->trim()
+
trunc({expr}) *trunc()*
Return the largest integral value with magnitude less than or
equal to {expr} as a |Float| (truncate towards zero).
@@ -10170,6 +10358,9 @@ undofile({name}) *undofile()*
buffer without a file name will not write an undo file.
Useful in combination with |:wundo| and |:rundo|.
+ Can also be used as a |method|: >
+ GetFilename()->undofile()
+
undotree() *undotree()*
Return the current state of the undo tree in a dictionary with
the following items:
@@ -10268,8 +10459,10 @@ virtcol({expr}) *virtcol()*
all lines: >
echo max(map(range(1, line('$')), "virtcol([v:val, '$'])"))
+< Can also be used as a |method|: >
+ GetPos()->virtcol()
-visualmode([expr]) *visualmode()*
+visualmode([{expr}]) *visualmode()*
The result is a String, which describes the last Visual mode
used in the current buffer. Initially it returns an empty
string, but once Visual mode has been used, it returns "v",
@@ -10283,7 +10476,7 @@ visualmode([expr]) *visualmode()*
Visual mode that was used.
If Visual mode is active, use |mode()| to get the Visual mode
(e.g., in a |:vmap|).
- If [expr] is supplied and it evaluates to a non-zero Number or
+ If {expr} is supplied and it evaluates to a non-zero Number or
a non-empty String, then the Visual mode will be cleared and
the old value is returned. See |non-zero-arg|.
@@ -10322,11 +10515,18 @@ win_execute({id}, {command} [, {silent}]) *win_execute()*
have unexpected side effects. Use |:noautocmd| if needed.
Example: >
call win_execute(winid, 'syntax enable')
+<
+ Can also be used as a |method|, the base is passed as the
+ second argument: >
+ GetCommand()->win_execute(winid)
win_findbuf({bufnr}) *win_findbuf()*
Returns a |List| with |window-ID|s for windows that contain
buffer {bufnr}. When there is none the list is empty.
+ Can also be used as a |method|: >
+ GetBufnr()->win_findbuf()
+
win_getid([{win} [, {tab}]]) *win_getid()*
Get the |window-ID| for the specified window.
When {win} is missing use the current window.
@@ -10336,6 +10536,9 @@ win_getid([{win} [, {tab}]]) *win_getid()*
number {tab}. The first tab has number one.
Return zero if the window cannot be found.
+ Can also be used as a |method|: >
+ GetWinnr()->win_getid()
+
win_gettype([{nr}]) *win_gettype()*
Return the type of the window:
"autocmd" autocommand window. Temporary window
@@ -10356,20 +10559,32 @@ win_gettype([{nr}]) *win_gettype()*
popup window then 'buftype' is "terminal" and win_gettype()
returns "popup".
+ Can also be used as a |method|: >
+ GetWinid()->win_gettype()
+<
win_gotoid({expr}) *win_gotoid()*
Go to window with ID {expr}. This may also change the current
tabpage.
Return TRUE if successful, FALSE if the window cannot be found.
-win_id2tabwin({expr} *win_id2tabwin()*
+ Can also be used as a |method|: >
+ GetWinid()->win_gotoid()
+
+win_id2tabwin({expr}) *win_id2tabwin()*
Return a list with the tab number and window number of window
with ID {expr}: [tabnr, winnr].
Return [0, 0] if the window cannot be found.
+ Can also be used as a |method|: >
+ GetWinid()->win_id2tabwin()
+
win_id2win({expr}) *win_id2win()*
Return the window number of window with ID {expr}.
Return 0 if the window cannot be found in the current tabpage.
+ Can also be used as a |method|: >
+ GetWinid()->win_id2win()
+
win_screenpos({nr}) *win_screenpos()*
Return the screen position of window {nr} as a list with two
numbers: [row, col]. The first window always has position
@@ -10379,6 +10594,9 @@ win_screenpos({nr}) *win_screenpos()*
Returns [0, 0] if the window cannot be found in the current
tabpage.
+ Can also be used as a |method|: >
+ GetWinid()->win_screenpos()
+<
win_splitmove({nr}, {target} [, {options}]) *win_splitmove()*
Move the window {nr} to a new split of the window {target}.
This is similar to moving to {target}, creating a new window
@@ -10399,6 +10617,9 @@ win_splitmove({nr}, {target} [, {options}]) *win_splitmove()*
present, the values of 'splitbelow' and
'splitright' are used.
+ Can also be used as a |method|: >
+ GetWinid()->win_splitmove(target)
+<
*winbufnr()*
winbufnr({nr}) The result is a Number, which is the number of the buffer
associated with window {nr}. {nr} can be the window number or
@@ -10433,6 +10654,9 @@ winheight({nr}) *winheight()*
This excludes any window toolbar line.
Examples: >
:echo "The current window has " . winheight(0) . " lines."
+
+< Can also be used as a |method|: >
+ GetWinid()->winheight()
<
winlayout([{tabnr}]) *winlayout()*
The result is a nested List containing the layout of windows
@@ -10464,6 +10688,9 @@ winlayout([{tabnr}]) *winlayout()*
['col', [['leaf', 1002], ['row', [['leaf', 1003],
['leaf', 1001]]], ['leaf', 1000]]]
<
+ Can also be used as a |method|: >
+ GetTabnr()->winlayout()
+<
*winline()*
winline() The result is a Number, which is the screen line of the cursor
in the window. This is counting screen lines from the top of
@@ -10498,6 +10725,9 @@ winnr([{arg}]) The result is a Number, which is the number of the current
let window_count = winnr('$')
let prev_window = winnr('#')
let wnum = winnr('3k')
+
+< Can also be used as a |method|: >
+ GetWinval()->winnr()
<
*winrestcmd()*
winrestcmd() Returns a sequence of |:resize| commands that should restore
@@ -10526,6 +10756,9 @@ winrestview({dict})
If you have changed the values the result is unpredictable.
If the window size changed the result won't be the same.
+ Can also be used as a |method|: >
+ GetView()->winrestview()
+<
*winsaveview()*
winsaveview() Returns a |Dictionary| that contains information to restore
the view of the current window. Use |winrestview()| to
@@ -10564,6 +10797,8 @@ winwidth({nr}) *winwidth()*
< For getting the terminal or screen size, see the 'columns'
option.
+ Can also be used as a |method|: >
+ GetWinid()->winwidth()
wordcount() *wordcount()*
The result is a dictionary of byte/chars/word statistics for
@@ -10622,17 +10857,19 @@ writefile({object}, {fname} [, {flags}])
:let fl = readfile("foo", "b")
:call writefile(fl, "foocopy", "b")
+< Can also be used as a |method|: >
+ GetText()->writefile("thefile")
xor({expr}, {expr}) *xor()*
Bitwise XOR on the two arguments. The arguments are converted
to a number. A List, Dict or Float argument causes an error.
Example: >
:let bits = xor(bits, 0x80)
-< Can also be used as a |method|: >
+<
+ Can also be used as a |method|: >
:let bits = bits->xor(0x80)
<
-
*string-match*
Matching a pattern in a String
diff --git a/runtime/doc/sign.txt b/runtime/doc/sign.txt
index c28e9b90ea..895ee5ebef 100644
--- a/runtime/doc/sign.txt
+++ b/runtime/doc/sign.txt
@@ -404,6 +404,9 @@ sign_define({list})
\ 'text' : '!!'}
\ ])
<
+ Can also be used as a |method|: >
+ GetSignList()->sign_define()
+
sign_getdefined([{name}]) *sign_getdefined()*
Get a list of defined signs and their attributes.
This is similar to the |:sign-list| command.
@@ -436,6 +439,9 @@ sign_getdefined([{name}]) *sign_getdefined()*
" Get the attribute of the sign named mySign
echo sign_getdefined("mySign")
<
+ Can also be used as a |method|: >
+ GetSignList()->sign_getdefined()
+
sign_getplaced([{buf} [, {dict}]]) *sign_getplaced()*
Return a list of signs placed in a buffer or all the buffers.
This is similar to the |:sign-place-list| command.
@@ -496,6 +502,9 @@ sign_getplaced([{buf} [, {dict}]]) *sign_getplaced()*
" Get a List of all the placed signs
echo sign_getplaced()
<
+ Can also be used as a |method|: >
+ GetBufname()->sign_getplaced()
+<
*sign_jump()*
sign_jump({id}, {group}, {buf})
Open the buffer {buf} or jump to the window that contains
@@ -511,7 +520,9 @@ sign_jump({id}, {group}, {buf})
" Jump to sign 10 in the current buffer
call sign_jump(10, '', '')
<
-
+ Can also be used as a |method|: >
+ GetSignid()->sign_jump()
+<
*sign_place()*
sign_place({id}, {group}, {name}, {buf} [, {dict}])
Place the sign defined as {name} at line {lnum} in file or
@@ -561,7 +572,9 @@ sign_place({id}, {group}, {name}, {buf} [, {dict}])
call sign_place(10, 'g3', 'sign4', 'json.c',
\ {'lnum' : 40, 'priority' : 90})
<
-
+ Can also be used as a |method|: >
+ GetSignid()->sign_place(group, name, expr)
+<
*sign_placelist()*
sign_placelist({list})
Place one or more signs. This is similar to the
@@ -621,6 +634,8 @@ sign_placelist({list})
\ 'lnum' : 50}
\ ])
<
+ Can also be used as a |method|: >
+ GetSignlist()->sign_placelist()
sign_undefine([{name}]) *sign_undefine()*
sign_undefine({list})
@@ -645,6 +660,8 @@ sign_undefine({list})
" Delete all the signs
call sign_undefine()
<
+ Can also be used as a |method|: >
+ GetSignlist()->sign_undefine()
sign_unplace({group} [, {dict}]) *sign_unplace()*
Remove a previously placed sign in one or more buffers. This
@@ -687,6 +704,9 @@ sign_unplace({group} [, {dict}]) *sign_unplace()*
" Remove all the placed signs from all the buffers
call sign_unplace('*')
+
+< Can also be used as a |method|: >
+ GetSigngroup()->sign_unplace()
<
sign_unplacelist({list}) *sign_unplacelist()*
Remove previously placed signs from one or more buffers. This
@@ -716,5 +736,8 @@ sign_unplacelist({list}) *sign_unplacelist()*
\ {'id' : 20, 'buffer' : 'b.vim'},
\ ])
<
+ Can also be used as a |method|: >
+ GetSignlist()->sign_unplacelist()
+<
vim:tw=78:ts=8:noet:ft=help:norl:
diff --git a/runtime/doc/testing.txt b/runtime/doc/testing.txt
index f0bda5aaf8..8ec66d26a4 100644
--- a/runtime/doc/testing.txt
+++ b/runtime/doc/testing.txt
@@ -157,6 +157,9 @@ assert_nobeep({cmd}) *assert_nobeep()*
produces a beep or visual bell.
Also see |assert_beeps()|.
+ Can also be used as a |method|: >
+ GetCmd()->assert_nobeep()
+<
*assert_notequal()*
assert_notequal({expected}, {actual} [, {msg}])
The opposite of `assert_equal()`: add an error message to
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index dfc51d80af..9a76b67de6 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -17,7 +17,7 @@ end
-- Usable with the base key: use the last function argument as the method base.
-- Value is from funcs.h file. "BASE_" prefix is omitted.
-local LAST = "BASE_LAST"
+-- local LAST = "BASE_LAST" (currently unused after port of v8.2.1168)
return {
funcs={
@@ -26,14 +26,14 @@ return {
add={args=2, base=1},
['and']={args=2, base=1},
api_info={},
- append={args=2, base=LAST},
- appendbufline={args=3, base=LAST},
+ append={args=2, base=2},
+ appendbufline={args=3, base=3},
argc={args={0, 1}},
argidx={},
arglistid={args={0, 2}},
argv={args={0, 2}},
asin={args=1, base=1, func="float_op_wrapper", data="&asin"}, -- WJMc
- assert_beeps={args={1}, base=1},
+ assert_beeps={args=1, base=1},
assert_equal={args={2, 3}, base=2},
assert_equalfile={args={2, 3}, base=1},
assert_exception={args={1, 2}},
@@ -41,7 +41,7 @@ return {
assert_false={args={1, 2}, base=1},
assert_inrange={args={3, 4}, base=3},
assert_match={args={2, 3}, base=2},
- assert_nobeep={args={1}},
+ assert_nobeep={args=1, base=1},
assert_notequal={args={2, 3}, base=2},
assert_notmatch={args={2, 3}, base=2},
assert_report={args=1, base=1},
@@ -53,8 +53,8 @@ return {
bufadd={args=1, base=1},
bufexists={args=1, base=1},
buffer_exists={args=1, base=1, func='f_bufexists'}, -- obsolete
- buffer_name={args={0, 1}, func='f_bufname'}, -- obsolete
- buffer_number={args={0, 1}, func='f_bufnr'}, -- obsolete
+ buffer_name={args={0, 1}, base=1, func='f_bufname'}, -- obsolete
+ buffer_number={args={0, 1}, base=1, func='f_bufnr'}, -- obsolete
buflisted={args=1, base=1},
bufload={args=1, base=1},
bufloaded={args=1, base=1},
@@ -71,7 +71,7 @@ return {
chanclose={args={1, 2}},
chansend={args=2},
char2nr={args={1, 2}, base=1},
- charidx={args={2, 3}},
+ charidx={args={2, 3}, base=1},
chdir={args=1, base=1},
cindent={args=1, base=1},
clearmatches={args={0, 1}, base=1},
@@ -121,7 +121,7 @@ return {
filter={args=2, base=1},
finddir={args={1, 3}, base=1},
findfile={args={1, 3}, base=1},
- flatten={args={1, 2}},
+ flatten={args={1, 2}, base=1},
float2nr={args=1, base=1},
floor={args=1, base=1, func="float_op_wrapper", data="&floor"},
fmod={args=2, base=1},
@@ -137,7 +137,7 @@ return {
['function']={args={1, 3}, base=1},
garbagecollect={args={0, 1}},
get={args={2, 3}, base=1},
- getbufinfo={args={0, 1}},
+ getbufinfo={args={0, 1}, base=1},
getbufline={args={2, 3}, base=1},
getbufvar={args={2, 3}, base=1},
getchangelist={args={0, 1}, base=1},
@@ -152,7 +152,7 @@ return {
getcompletion={args={2, 3}, base=1},
getcurpos={},
getcwd={args={0, 2}, base=1},
- getenv={args={1}, base=1},
+ getenv={args=1, base=1},
getfontname={args={0, 1}},
getfperm={args=1, base=1},
getfsize={args=1, base=1},
@@ -161,7 +161,7 @@ return {
getjumplist={args={0, 2}, base=1},
getline={args={1, 2}, base=1},
getloclist={args={1, 2}},
- getmarklist={args={0, 1}},
+ getmarklist={args={0, 1}, base=1},
getmatches={args={0, 1}},
getmousepos={},
getpid={},
@@ -262,7 +262,7 @@ return {
pow={args=2, base=1},
prevnonblank={args=1, base=1},
printf={args=varargs(1), base=2},
- prompt_getprompt={args=1},
+ prompt_getprompt={args=1, base=1},
prompt_setcallback={args={2, 2}, base=1},
prompt_setinterrupt={args={2, 2}, base=1},
prompt_setprompt={args={2, 2}, base=1},
@@ -291,82 +291,82 @@ return {
rpcstart={args={1, 2}},
rpcstop={args=1},
rubyeval={args=1, base=1},
- screenattr={args=2},
- screenchar={args=2},
- screenchars={args=2},
+ screenattr={args=2, base=1},
+ screenchar={args=2, base=1},
+ screenchars={args=2, base=1},
screencol={},
- screenpos={args=3},
+ screenpos={args=3, base=1},
screenrow={},
- screenstring={args=2},
- search={args={1, 4}},
- searchcount={args={0,1}},
- searchdecl={args={1, 3}},
+ screenstring={args=2, base=1},
+ search={args={1, 4}, base=1},
+ searchcount={args={0, 1}, base=1},
+ searchdecl={args={1, 3}, base=1},
searchpair={args={3, 7}},
searchpairpos={args={3, 7}},
- searchpos={args={1, 4}},
+ searchpos={args={1, 4}, base=1},
serverlist={},
serverstart={args={0, 1}},
serverstop={args=1},
- setbufline={args=3},
- setbufvar={args=3},
- setcharsearch={args=1},
- setcmdpos={args=1},
- setenv={args=2},
+ setbufline={args=3, base=3},
+ setbufvar={args=3, base=3},
+ setcharsearch={args=1, base=1},
+ setcmdpos={args=1, base=1},
+ setenv={args=2, base=2},
setfperm={args=2, base=1},
- setline={args=2},
- setloclist={args={2, 4}},
- setmatches={args={1, 2}},
- setpos={args=2},
- setqflist={args={1, 3}},
- setreg={args={2, 3}},
- settabvar={args=3},
- settabwinvar={args=4},
- settagstack={args={2, 3}},
- setwinvar={args=3},
- sha256={args=1},
- shellescape={args={1, 2}},
- shiftwidth={args={0, 1}},
- sign_define={args={1, 2}},
- sign_getdefined={args={0, 1}},
- sign_getplaced={args={0, 2}},
- sign_jump={args={3, 3}},
- sign_place={args={4, 5}},
- sign_placelist={args={1}},
- sign_undefine={args={0, 1}},
- sign_unplace={args={1, 2}},
- sign_unplacelist={args={1}},
- simplify={args=1},
+ setline={args=2, base=2},
+ setloclist={args={2, 4}, base=2},
+ setmatches={args={1, 2}, base=1},
+ setpos={args=2, base=2},
+ setqflist={args={1, 3}, base=1},
+ setreg={args={2, 3}, base=2},
+ settabvar={args=3, base=3},
+ settabwinvar={args=4, base=4},
+ settagstack={args={2, 3}, base=2},
+ setwinvar={args=3, base=3},
+ sha256={args=1, base=1},
+ shellescape={args={1, 2}, base=1},
+ shiftwidth={args={0, 1}, base=1},
+ sign_define={args={1, 2}, base=1},
+ sign_getdefined={args={0, 1}, base=1},
+ sign_getplaced={args={0, 2}, base=1},
+ sign_jump={args=3, base=1},
+ sign_place={args={4, 5}, base=1},
+ sign_placelist={args=1, base=1},
+ sign_undefine={args={0, 1}, base=1},
+ sign_unplace={args={1, 2}, base=1},
+ sign_unplacelist={args=1, base=1},
+ simplify={args=1, base=1},
sin={args=1, base=1, func="float_op_wrapper", data="&sin"},
sinh={args=1, base=1, func="float_op_wrapper", data="&sinh"},
sockconnect={args={2,3}},
sort={args={1, 3}, base=1},
- soundfold={args=1},
+ soundfold={args=1, base=1},
stdioopen={args=1},
- spellbadword={args={0, 1}},
- spellsuggest={args={1, 3}},
+ spellbadword={args={0, 1}, base=1},
+ spellsuggest={args={1, 3}, base=1},
split={args={1, 3}, base=1},
sqrt={args=1, base=1, func="float_op_wrapper", data="&sqrt"},
stdpath={args=1},
str2float={args=1, base=1},
str2list={args={1, 2}, base=1},
- str2nr={args={1, 3}},
- strcharpart={args={2, 3}},
- strchars={args={1,2}},
- strdisplaywidth={args={1, 2}},
- strftime={args={1, 2}},
- strgetchar={args={2, 2}},
- stridx={args={2, 3}},
+ str2nr={args={1, 3}, base=1},
+ strcharpart={args={2, 3}, base=1},
+ strchars={args={1, 2}, base=1},
+ strdisplaywidth={args={1, 2}, base=1},
+ strftime={args={1, 2}, base=1},
+ strgetchar={args=2, base=1},
+ stridx={args={2, 3}, base=1},
string={args=1, base=1},
strlen={args=1, base=1},
- strpart={args={2, 4}},
- strptime={args=2},
- strridx={args={2, 3}},
+ strpart={args={2, 4}, base=1},
+ strptime={args=2, base=1},
+ strridx={args={2, 3}, base=1},
strtrans={args=1, base=1},
strwidth={args=1, base=1},
- submatch={args={1, 2}},
+ submatch={args={1, 2}, base=1},
substitute={args=4, base=1},
- swapinfo={args={1}},
- swapname={args={1}},
+ swapinfo={args=1, base=1},
+ swapname={args=1, base=1},
synID={args=3},
synIDattr={args={2, 3}, base=1},
synIDtrans={args=1, base=1},
@@ -374,58 +374,58 @@ return {
synstack={args=2},
system={args={1, 2}, base=1},
systemlist={args={1, 3}, base=1},
- tabpagebuflist={args={0, 1}},
+ tabpagebuflist={args={0, 1}, base=1},
tabpagenr={args={0, 1}},
- tabpagewinnr={args={1, 2}},
+ tabpagewinnr={args={1, 2}, base=1},
tagfiles={},
- taglist={args={1, 2}},
+ taglist={args={1, 2}, base=1},
tan={args=1, base=1, func="float_op_wrapper", data="&tan"},
tanh={args=1, base=1, func="float_op_wrapper", data="&tanh"},
tempname={},
termopen={args={1, 2}},
test_garbagecollect_now={},
test_write_list_log={args=1},
- timer_info={args={0,1}},
- timer_pause={args=2},
- timer_start={args={2,3}},
- timer_stop={args=1},
+ timer_info={args={0, 1}, base=1},
+ timer_pause={args=2, base=1},
+ timer_start={args={2, 3}, base=1},
+ timer_stop={args=1, base=1},
timer_stopall={args=0},
- tolower={args=1},
- toupper={args=1},
- tr={args=3},
- trim={args={1,3}},
+ tolower={args=1, base=1},
+ toupper={args=1, base=1},
+ tr={args=3, base=1},
+ trim={args={1, 3}, base=1},
trunc={args=1, base=1, func="float_op_wrapper", data="&trunc"},
type={args=1, base=1},
- undofile={args=1},
+ undofile={args=1, base=1},
undotree={},
uniq={args={1, 3}, base=1},
values={args=1, base=1},
- virtcol={args=1},
+ virtcol={args=1, base=1},
visualmode={args={0, 1}},
wait={args={2,3}},
wildmenumode={},
- win_execute={args={2, 3}},
- win_findbuf={args=1},
- win_getid={args={0,2}},
- win_gettype={args={0,1}},
- win_gotoid={args=1},
- win_id2tabwin={args=1},
- win_id2win={args=1},
- win_screenpos={args=1},
- win_splitmove={args={2, 3}},
+ win_execute={args={2, 3}, base=2},
+ win_findbuf={args=1, base=1},
+ win_getid={args={0, 2}, base=1},
+ win_gettype={args={0, 1}, base=1},
+ win_gotoid={args=1, base=1},
+ win_id2tabwin={args=1, base=1},
+ win_id2win={args=1, base=1},
+ win_screenpos={args=1, base=1},
+ win_splitmove={args={2, 3}, base=1},
winbufnr={args=1, base=1},
wincol={},
windowsversion={},
- winheight={args=1},
- winlayout={args={0, 1}},
+ winheight={args=1, base=1},
+ winlayout={args={0, 1}, base=1},
winline={},
- winnr={args={0, 1}},
+ winnr={args={0, 1}, base=1},
winrestcmd={},
- winrestview={args=1},
+ winrestview={args=1, base=1},
winsaveview={},
- winwidth={args=1},
+ winwidth={args=1, base=1},
wordcount={},
- writefile={args={2, 3}},
+ writefile={args={2, 3}, base=1},
xor={args=2, base=1},
},
}
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index dfadd28ebe..33ca4016cf 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -11551,6 +11551,9 @@ static void f_timer_start(typval_T *argvars, typval_T *rettv, FunPtr fptr)
dict_T *dict;
rettv->vval.v_number = -1;
+ if (check_secure()) {
+ return;
+ }
if (argvars[2].v_type != VAR_UNKNOWN) {
if (argvars[2].v_type != VAR_DICT
diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim
index 5b145dd1d2..4e1a24af61 100644
--- a/src/nvim/testdir/test_autocmd.vim
+++ b/src/nvim/testdir/test_autocmd.vim
@@ -526,8 +526,7 @@ func Test_autocmd_blast_badd()
call writefile(content, 'XblastBall')
call system(GetVimCommand() .. ' --clean -S XblastBall')
- " call assert_match('OK', readfile('Xerrors')->join())
- call assert_match('OK', join(readfile('Xerrors')))
+ call assert_match('OK', readfile('Xerrors')->join())
call delete('XblastBall')
call delete('Xerrors')
diff --git a/src/nvim/testdir/test_breakindent.vim b/src/nvim/testdir/test_breakindent.vim
index 277050876e..8d592f21ea 100644
--- a/src/nvim/testdir/test_breakindent.vim
+++ b/src/nvim/testdir/test_breakindent.vim
@@ -432,7 +432,7 @@ func Test_breakindent11_vartabs()
call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4 vts=4')
let text = getline(2)
let width = strlen(text[1:]) + 2->indent() + strlen(&sbr) * 3 " text wraps 3 times
- call assert_equal(width, strdisplaywidth(text))
+ call assert_equal(width, text->strdisplaywidth())
call s:close_windows('set sbr= vts&')
endfunc
diff --git a/src/nvim/testdir/test_bufwintabinfo.vim b/src/nvim/testdir/test_bufwintabinfo.vim
index c04c8fbf60..a6eb93b4be 100644
--- a/src/nvim/testdir/test_bufwintabinfo.vim
+++ b/src/nvim/testdir/test_bufwintabinfo.vim
@@ -20,6 +20,9 @@ function Test_getbufwintabinfo()
call assert_equal('vim', l[0].variables.editor)
call assert_notequal(-1, index(l[0].windows, '%'->bufwinid()))
+ let l = '%'->getbufinfo()
+ call assert_equal(bufnr('%'), l[0].bufnr)
+
" Test for getbufinfo() with 'bufmodified'
call assert_equal(0, len(getbufinfo({'bufmodified' : 1})))
call setbufline('Xtestfile1', 1, ["Line1"])
@@ -48,7 +51,7 @@ function Test_getbufwintabinfo()
tabnew | let w3_id = win_getid()
new | let w4_id = win_getid()
vert new | let w5_id = win_getid()
- call setwinvar(0, 'signal', 'green')
+ eval 'green'->setwinvar(0, 'signal')
tabfirst
let winlist = getwininfo()
call assert_equal(5, len(winlist))
diff --git a/src/nvim/testdir/test_cd.vim b/src/nvim/testdir/test_cd.vim
index 57db0a2544..76a2620be0 100644
--- a/src/nvim/testdir/test_cd.vim
+++ b/src/nvim/testdir/test_cd.vim
@@ -101,7 +101,7 @@ func Test_chdir_func()
call assert_match('^\[global\] .*/Xdir$', trim(execute('verbose pwd')))
call chdir('..')
call assert_equal('y', fnamemodify(getcwd(1, 2), ':t'))
- call assert_equal('z', fnamemodify(getcwd(3, 2), ':t'))
+ call assert_equal('z', fnamemodify(3->getcwd(2), ':t'))
tabnext | wincmd t
call assert_match('^\[tabpage\] .*/y$', trim(execute('verbose pwd')))
call chdir('..')
diff --git a/src/nvim/testdir/test_charsearch.vim b/src/nvim/testdir/test_charsearch.vim
index 17a49e02be..6f09e85a42 100644
--- a/src/nvim/testdir/test_charsearch.vim
+++ b/src/nvim/testdir/test_charsearch.vim
@@ -20,7 +20,7 @@ func Test_charsearch()
" check that setcharsearch() changes the settings.
3
normal! ylfep
- call setcharsearch({'char': 'k'})
+ eval {'char': 'k'}->setcharsearch()
normal! ;p
call setcharsearch({'forward': 0})
normal! $;p
diff --git a/src/nvim/testdir/test_clientserver.vim b/src/nvim/testdir/test_clientserver.vim
index f3db472b03..922803438f 100644
--- a/src/nvim/testdir/test_clientserver.vim
+++ b/src/nvim/testdir/test_clientserver.vim
@@ -82,7 +82,7 @@ func Test_client_server()
call remote_send(name, ":call server2client(expand('<client>'), 'got it')\<CR>", 'g:myserverid')
call assert_equal('got it', g:myserverid->remote_read(2))
- call remote_send(name, ":call server2client(expand('<client>'), 'another')\<CR>", 'g:myserverid')
+ call remote_send(name, ":eval expand('<client>')->server2client('another')\<CR>", 'g:myserverid')
let peek_result = 'nothing'
let r = g:myserverid->remote_peek('peek_result')
" unpredictable whether the result is already available.
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index 75e17b47b8..49a5386337 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -905,7 +905,7 @@ func Test_setcmdpos()
call assert_equal('"12ab', @:)
" setcmdpos() returns 1 when not editing the command line.
- call assert_equal(1, setcmdpos(3))
+ call assert_equal(1, 3->setcmdpos())
endfunc
func Test_cmdline_overstrike()
diff --git a/src/nvim/testdir/test_compiler.vim b/src/nvim/testdir/test_compiler.vim
index c3de7d0050..aaa2301bca 100644
--- a/src/nvim/testdir/test_compiler.vim
+++ b/src/nvim/testdir/test_compiler.vim
@@ -38,10 +38,9 @@ func Test_compiler()
endfunc
func GetCompilerNames()
- " return glob('$VIMRUNTIME/compiler/*.vim', 0, 1)
- " \ ->map({i, v -> substitute(v, '.*[\\/]\([a-zA-Z0-9_\-]*\).vim', '\1', '')})
- " \ ->sort()
- return sort(map(glob('$VIMRUNTIME/compiler/*.vim', 0, 1), {i, v -> substitute(v, '.*[\\/]\([a-zA-Z0-9_\-]*\).vim', '\1', '')}))
+ return glob('$VIMRUNTIME/compiler/*.vim', 0, 1)
+ \ ->map({i, v -> substitute(v, '.*[\\/]\([a-zA-Z0-9_\-]*\).vim', '\1', '')})
+ \ ->sort()
endfunc
func Test_compiler_without_arg()
@@ -54,8 +53,7 @@ func Test_compiler_without_arg()
endfunc
func Test_compiler_completion()
- " let clist = GetCompilerNames()->join(' ')
- let clist = join(GetCompilerNames(), ' ')
+ let clist = GetCompilerNames()->join(' ')
call feedkeys(":compiler \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_match('^"compiler ' .. clist .. '$', @:)
diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim
index 46847e0663..e8c4a952ee 100644
--- a/src/nvim/testdir/test_cursor_func.vim
+++ b/src/nvim/testdir/test_cursor_func.vim
@@ -37,7 +37,7 @@ endfunc
" Very short version of what matchparen does.
function s:Highlight_Matching_Pair()
let save_cursor = getcurpos()
- call setpos('.', save_cursor)
+ eval save_cursor->setpos('.')
endfunc
func Test_curswant_with_autocommand()
@@ -82,11 +82,11 @@ func Test_screenpos()
call assert_equal({'row': winrow,
\ 'col': wincol + 0,
\ 'curscol': wincol + 7,
- \ 'endcol': wincol + 7}, screenpos(winid, 1, 1))
+ \ 'endcol': wincol + 7}, winid->screenpos(1, 1))
call assert_equal({'row': winrow,
\ 'col': wincol + 13,
\ 'curscol': wincol + 13,
- \ 'endcol': wincol + 13}, screenpos(winid, 1, 7))
+ \ 'endcol': wincol + 13}, winid->screenpos(1, 7))
call assert_equal({'row': winrow + 2,
\ 'col': wincol + 1,
\ 'curscol': wincol + 1,
diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim
index 61da3cbcaa..3a0c615cf6 100644
--- a/src/nvim/testdir/test_diffmode.vim
+++ b/src/nvim/testdir/test_diffmode.vim
@@ -387,7 +387,7 @@ func Test_diffoff()
call setline(1, ['One', '', 'Two', 'Three'])
diffthis
redraw
- call assert_notequal(normattr, screenattr(1, 1))
+ call assert_notequal(normattr, 1->screenattr(1))
diffoff!
redraw
call assert_equal(normattr, screenattr(1, 1))
diff --git a/src/nvim/testdir/test_environ.vim b/src/nvim/testdir/test_environ.vim
index cc15b63824..dd34983ee5 100644
--- a/src/nvim/testdir/test_environ.vim
+++ b/src/nvim/testdir/test_environ.vim
@@ -22,7 +22,7 @@ endfunc
func Test_setenv()
unlet! $TESTENV
- call setenv('TEST ENV', 'foo')
+ eval 'foo'->setenv('TEST ENV')
call assert_equal('foo', getenv('TEST ENV'))
call setenv('TEST ENV', v:null)
call assert_equal(v:null, getenv('TEST ENV'))
diff --git a/src/nvim/testdir/test_execute_func.vim b/src/nvim/testdir/test_execute_func.vim
index f2c7da0aa9..2cb6d73407 100644
--- a/src/nvim/testdir/test_execute_func.vim
+++ b/src/nvim/testdir/test_execute_func.vim
@@ -99,7 +99,7 @@ func Test_win_execute()
if has('textprop')
let popupwin = popup_create('the popup win', {'line': 2, 'col': 3})
redraw
- let line = win_execute(popupwin, 'echo getline(1)')
+ let line = 'echo getline(1)'->win_execute(popupwin)
call assert_match('the popup win', line)
call popup_close(popupwin)
diff --git a/src/nvim/testdir/test_expr.vim b/src/nvim/testdir/test_expr.vim
index 6343c47fde..1d7fd3e385 100644
--- a/src/nvim/testdir/test_expr.vim
+++ b/src/nvim/testdir/test_expr.vim
@@ -56,7 +56,7 @@ endfunc
func Test_strgetchar()
call assert_equal(char2nr('a'), strgetchar('axb', 0))
- call assert_equal(char2nr('x'), strgetchar('axb', 1))
+ call assert_equal(char2nr('x'), 'axb'->strgetchar(1))
call assert_equal(char2nr('b'), strgetchar('axb', 2))
call assert_equal(-1, strgetchar('axb', -1))
@@ -66,7 +66,7 @@ endfunc
func Test_strcharpart()
call assert_equal('a', strcharpart('axb', 0, 1))
- call assert_equal('x', strcharpart('axb', 1, 1))
+ call assert_equal('x', 'axb'->strcharpart(1, 1))
call assert_equal('b', strcharpart('axb', 2, 1))
call assert_equal('xb', strcharpart('axb', 1))
@@ -493,7 +493,7 @@ func Test_setmatches()
let set[0]['conceal'] = 5
let exp[0]['conceal'] = '5'
endif
- call setmatches(set)
+ eval set->setmatches()
call assert_equal(exp, getmatches())
endfunc
diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim
index 5586fe2151..6da1b3d4a0 100644
--- a/src/nvim/testdir/test_fold.vim
+++ b/src/nvim/testdir/test_fold.vim
@@ -809,8 +809,7 @@ func Test_undo_fold_deletion()
g/"/d
undo
redo
- " eval getline(1, '$')->assert_equal([''])
- eval assert_equal(getline(1, '$'), [''])
+ eval getline(1, '$')->assert_equal([''])
set fdm&vim
bwipe!
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim
index 4a2ade5afa..0edbeb420a 100644
--- a/src/nvim/testdir/test_functions.vim
+++ b/src/nvim/testdir/test_functions.vim
@@ -143,7 +143,7 @@ func Test_str2nr()
call assert_equal(-123456789, str2nr('-123456789'))
call assert_equal(5, str2nr('101', 2))
- call assert_equal(5, str2nr('0b101', 2))
+ call assert_equal(5, '0b101'->str2nr(2))
call assert_equal(5, str2nr('0B101', 2))
call assert_equal(-5, str2nr('-101', 2))
call assert_equal(-5, str2nr('-0b101', 2))
@@ -200,7 +200,7 @@ func Test_strftime()
" of strftime() can be 17 or 18, depending on timezone.
call assert_match('^2017-01-1[78]$', strftime('%Y-%m-%d', 1484695512))
"
- call assert_match('^\d\d\d\d-\(0\d\|1[012]\)-\([012]\d\|3[01]\) \([01]\d\|2[0-3]\):[0-5]\d:\([0-5]\d\|60\)$', strftime('%Y-%m-%d %H:%M:%S'))
+ call assert_match('^\d\d\d\d-\(0\d\|1[012]\)-\([012]\d\|3[01]\) \([01]\d\|2[0-3]\):[0-5]\d:\([0-5]\d\|60\)$', '%Y-%m-%d %H:%M:%S'->strftime())
call assert_fails('call strftime([])', 'E730:')
call assert_fails('call strftime("%Y", [])', 'E745:')
@@ -307,13 +307,19 @@ func Test_resolve_unix()
call assert_equal('/', resolve('/'))
endfunc
+func s:normalize_fname(fname)
+ let ret = substitute(a:fname, '\', '/', 'g')
+ let ret = substitute(ret, '//', '/', 'g')
+ return ret->tolower()
+endfunc
+
func Test_simplify()
call assert_equal('', simplify(''))
call assert_equal('/', simplify('/'))
call assert_equal('/', simplify('/.'))
call assert_equal('/', simplify('/..'))
call assert_equal('/...', simplify('/...'))
- call assert_equal('./dir/file', simplify('./dir/file'))
+ call assert_equal('./dir/file', './dir/file'->simplify())
call assert_equal('./dir/file', simplify('.///dir//file'))
call assert_equal('./dir/file', simplify('./dir/./file'))
call assert_equal('./file', simplify('./dir/../file'))
@@ -346,7 +352,7 @@ func Test_setbufvar_options()
wincmd h
let wh = winheight(0)
let dummy_buf = bufnr('dummy_buf2', v:true)
- call setbufvar(dummy_buf, '&buftype', 'nofile')
+ eval 'nofile'->setbufvar(dummy_buf, '&buftype')
execute 'belowright vertical split #' . dummy_buf
call assert_equal(wh, winheight(0))
@@ -375,7 +381,7 @@ endfunc
func Test_strpart()
call assert_equal('de', strpart('abcdefg', 3, 2))
call assert_equal('ab', strpart('abcdefg', -2, 4))
- call assert_equal('abcdefg', strpart('abcdefg', -2))
+ call assert_equal('abcdefg', 'abcdefg'->strpart(-2))
call assert_equal('fg', strpart('abcdefg', 5, 4))
call assert_equal('defg', strpart('abcdefg', 3))
@@ -469,7 +475,7 @@ func Test_toupper()
\ toupper(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'))
" Test with a few lowercase diacritics.
- call assert_equal("AÀÁÂÃÄÅĀĂĄǍǞǠẢ", toupper("aàáâãäåāăąǎǟǡả"))
+ call assert_equal("AÀÁÂÃÄÅĀĂĄǍǞǠẢ", "aàáâãäåāăąǎǟǡả"->toupper())
call assert_equal("BḂḆ", toupper("bḃḇ"))
call assert_equal("CÇĆĈĊČ", toupper("cçćĉċč"))
call assert_equal("DĎĐḊḎḐ", toupper("dďđḋḏḑ"))
@@ -532,6 +538,11 @@ func Test_toupper()
call toupper("123\xC0\x80\xC0")
endfunc
+func Test_tr()
+ call assert_equal('foo', tr('bar', 'bar', 'foo'))
+ call assert_equal('zxy', 'cab'->tr('abc', 'xyz'))
+endfunc
+
" Tests for the mode() function
let current_modes = ''
func Save_mode()
@@ -809,11 +820,11 @@ endfunc
func Test_stridx()
call assert_equal(-1, stridx('', 'l'))
call assert_equal(0, stridx('', ''))
- call assert_equal(0, stridx('hello', ''))
+ call assert_equal(0, 'hello'->stridx(''))
call assert_equal(-1, stridx('hello', 'L'))
call assert_equal(2, stridx('hello', 'l', -1))
call assert_equal(2, stridx('hello', 'l', 0))
- call assert_equal(2, stridx('hello', 'l', 1))
+ call assert_equal(2, 'hello'->stridx('l', 1))
call assert_equal(3, stridx('hello', 'l', 3))
call assert_equal(-1, stridx('hello', 'l', 4))
call assert_equal(-1, stridx('hello', 'l', 10))
@@ -826,7 +837,7 @@ func Test_strridx()
call assert_equal(0, strridx('', ''))
call assert_equal(5, strridx('hello', ''))
call assert_equal(-1, strridx('hello', 'L'))
- call assert_equal(3, strridx('hello', 'l'))
+ call assert_equal(3, 'hello'->strridx('l'))
call assert_equal(3, strridx('hello', 'l', 10))
call assert_equal(3, strridx('hello', 'l', 3))
call assert_equal(2, strridx('hello', 'l', 2))
@@ -1219,7 +1230,7 @@ func Test_shellescape()
let save_shell = &shell
set shell=bash
call assert_equal("'text'", shellescape('text'))
- call assert_equal("'te\"xt'", shellescape('te"xt'))
+ call assert_equal("'te\"xt'", 'te"xt'->shellescape())
call assert_equal("'te'\\''xt'", shellescape("te'xt"))
call assert_equal("'te%xt'", shellescape("te%xt"))
@@ -1293,7 +1304,7 @@ endfunc
func Test_trim()
call assert_equal("Testing", trim(" \t\r\r\x0BTesting \t\n\r\n\t\x0B\x0B"))
- call assert_equal("Testing", trim(" \t \r\r\n\n\x0BTesting \t\n\r\n\t\x0B\x0B"))
+ call assert_equal("Testing", " \t \r\r\n\n\x0BTesting \t\n\r\n\t\x0B\x0B"->trim())
call assert_equal("RESERVE", trim("xyz \twwRESERVEzyww \t\t", " wxyz\t"))
call assert_equal("wRE \tSERVEzyww", trim("wRE \tSERVEzyww"))
call assert_equal("abcd\t xxxx tail", trim(" \tabcd\t xxxx tail"))
@@ -1330,7 +1341,7 @@ func Test_func_range_with_edit()
" is invalid in that buffer.
call writefile(['just one line'], 'Xfuncrange2')
new
- call setline(1, 10->range())
+ eval 10->range()->setline(1)
write Xfuncrange1
call assert_fails('5,8call EditAnotherFile()', 'E16:')
@@ -1560,7 +1571,7 @@ func Test_bufadd_bufload()
call assert_equal([''], getbufline(buf, 1, '$'))
let curbuf = bufnr('')
- call writefile(['some', 'text'], 'XotherName')
+ eval ['some', 'text']->writefile('XotherName')
let buf = 'XotherName'->bufadd()
call assert_notequal(0, buf)
eval 'XotherName'->bufexists()->assert_equal(1)
diff --git a/src/nvim/testdir/test_listchars.vim b/src/nvim/testdir/test_listchars.vim
index 9906b00222..f4ee539803 100644
--- a/src/nvim/testdir/test_listchars.vim
+++ b/src/nvim/testdir/test_listchars.vim
@@ -25,7 +25,7 @@ func Test_listchars()
redraw!
for i in range(1, 5)
call cursor(i, 1)
- call assert_equal([expected[i - 1]], ScreenLines(i, virtcol('$')))
+ call assert_equal([expected[i - 1]], ScreenLines(i, '$'->virtcol()))
endfor
set listchars-=trail:<
diff --git a/src/nvim/testdir/test_marks.vim b/src/nvim/testdir/test_marks.vim
index 2fd82a4b6d..b3035d73ce 100644
--- a/src/nvim/testdir/test_marks.vim
+++ b/src/nvim/testdir/test_marks.vim
@@ -227,7 +227,7 @@ func Test_getmarklist()
call cursor(2, 2)
normal mr
call assert_equal({'mark' : "'r", 'pos' : [bufnr(), 2, 2, 0]},
- \ getmarklist(bufnr())[0])
- call assert_equal([], getmarklist({}))
+ \ bufnr()->getmarklist()[0])
+ call assert_equal([], {}->getmarklist())
close!
endfunc
diff --git a/src/nvim/testdir/test_matchadd_conceal_utf8.vim b/src/nvim/testdir/test_matchadd_conceal_utf8.vim
index 34c8c49dd5..7bfac13ad8 100644
--- a/src/nvim/testdir/test_matchadd_conceal_utf8.vim
+++ b/src/nvim/testdir/test_matchadd_conceal_utf8.vim
@@ -6,7 +6,7 @@ endif
function! s:screenline(lnum) abort
let line = []
for c in range(1, winwidth(0))
- call add(line, nr2char(screenchar(a:lnum, c)))
+ call add(line, nr2char(a:lnum->screenchar(c)))
endfor
return s:trim(join(line, ''))
endfunction
diff --git a/src/nvim/testdir/test_messages.vim b/src/nvim/testdir/test_messages.vim
index 08586dffe1..2140fe21ea 100644
--- a/src/nvim/testdir/test_messages.vim
+++ b/src/nvim/testdir/test_messages.vim
@@ -87,7 +87,7 @@ func Test_echoerr()
if has('float')
call assert_equal("\n1.23 IgNoRe", execute(':echoerr 1.23 "IgNoRe"'))
endif
- call test_ignore_error('<lambda>')
+ eval '<lambda>'->test_ignore_error()
call assert_match("function('<lambda>\\d*')", execute(':echoerr {-> 1234}'))
call test_ignore_error('RESET')
endfunc
diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim
index c96c6a9678..057895047d 100644
--- a/src/nvim/testdir/test_mksession.vim
+++ b/src/nvim/testdir/test_mksession.vim
@@ -156,8 +156,7 @@ func Test_mksession_zero_winheight()
wincmd _
mksession! Xtest_mks_zero
set winminheight&
- " let text = readfile('Xtest_mks_zero')->join()
- let text = join(readfile('Xtest_mks_zero'))
+ let text = readfile('Xtest_mks_zero')->join()
call delete('Xtest_mks_zero')
close
" check there is no divide by zero
diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim
index 41c689849b..7d9cada074 100644
--- a/src/nvim/testdir/test_options.vim
+++ b/src/nvim/testdir/test_options.vim
@@ -235,8 +235,7 @@ func Test_set_completion()
call feedkeys(":set filetype=sshdconfi\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set filetype=sshdconfig', @:)
call feedkeys(":set filetype=a\<C-A>\<C-B>\"\<CR>", 'xt')
- " call assert_equal('"set filetype=' .. getcompletion('a*', 'filetype')->join(), @:)
- call assert_equal('"set filetype=' .. join(getcompletion('a*', 'filetype')), @:)
+ call assert_equal('"set filetype=' .. getcompletion('a*', 'filetype')->join(), @:)
endfunc
func Test_set_errors()
diff --git a/src/nvim/testdir/test_prompt_buffer.vim b/src/nvim/testdir/test_prompt_buffer.vim
index 3da46eb1a6..c59a00afcc 100644
--- a/src/nvim/testdir/test_prompt_buffer.vim
+++ b/src/nvim/testdir/test_prompt_buffer.vim
@@ -165,9 +165,7 @@ func Test_prompt_buffer_getbufinfo()
call assert_equal('This is a test: ', prompt_getprompt('%'))
call prompt_setprompt( bufnr( '%' ), '' )
- " Nvim doesn't support method call syntax yet.
- " call assert_equal('', '%'->prompt_getprompt())
- call assert_equal('', prompt_getprompt('%'))
+ call assert_equal('', '%'->prompt_getprompt())
call prompt_setprompt( bufnr( '%' ), 'Another: ' )
call assert_equal('Another: ', prompt_getprompt('%'))
diff --git a/src/nvim/testdir/test_put.vim b/src/nvim/testdir/test_put.vim
index 8d8cc77025..f42b177c50 100644
--- a/src/nvim/testdir/test_put.vim
+++ b/src/nvim/testdir/test_put.vim
@@ -39,7 +39,7 @@ func Test_put_lines()
call assert_equal(['Line 3', '', 'Line 1', 'Line2'], getline(1, '$'))
" clean up
bw!
- call setreg('a', a[0], a[1])
+ eval a[0]->setreg('a', a[1])
endfunc
func Test_put_expr()
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index b38a59e98f..6db679c5f9 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -811,7 +811,7 @@ func Test_locationlist()
" NOTE: problem 1:
" intentionally not setting 'lnum' so that the quickfix entries are not
" valid
- call setloclist(0, qflist, ' ')
+ eval qflist->setloclist(0, ' ')
endfor
" Test A
@@ -1699,7 +1699,7 @@ endfunc
func Test_setqflist_invalid_nr()
" The following command used to crash Vim
- call setqflist([], ' ', {'nr' : $XXX_DOES_NOT_EXIST})
+ eval []->setqflist(' ', {'nr' : $XXX_DOES_NOT_EXIST})
endfunc
func Test_setqflist_user_sets_buftype()
diff --git a/src/nvim/testdir/test_ruby.vim b/src/nvim/testdir/test_ruby.vim
index 1a274d1fec..1fbf3392d9 100644
--- a/src/nvim/testdir/test_ruby.vim
+++ b/src/nvim/testdir/test_ruby.vim
@@ -60,7 +60,7 @@ func Test_ruby_set_cursor()
" Check that movement after setting cursor position keeps current column.
normal j
call assert_equal([2, 6], [line('.'), col('.')])
- call assert_equal([2, 5], rubyeval('$curwin.cursor'))
+ call assert_equal([2, 5], '$curwin.cursor'->rubyeval())
" call assert_fails('ruby $curwin.cursor = [1]',
" \ 'ArgumentError: array length must be 2')
diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim
index 7570049e7c..c796f1f676 100644
--- a/src/nvim/testdir/test_search.vim
+++ b/src/nvim/testdir/test_search.vim
@@ -1315,7 +1315,7 @@ func Test_search_match_at_curpos()
normal gg
- call search('foobar', 'c')
+ eval 'foobar'->search('c')
call assert_equal([1, 1], [line('.'), col('.')])
normal j
@@ -1354,6 +1354,41 @@ func Test_search_display_pattern()
endif
endfunc
+func Test_searchdecl()
+ let lines =<< trim END
+ int global;
+
+ func()
+ {
+ int global;
+ if (cond) {
+ int local;
+ }
+ int local;
+ // comment
+ }
+ END
+ new
+ call setline(1, lines)
+ 10
+ call assert_equal(0, searchdecl('local', 0, 0))
+ call assert_equal(7, getcurpos()[1])
+
+ 10
+ call assert_equal(0, 'local'->searchdecl(0, 1))
+ call assert_equal(9, getcurpos()[1])
+
+ 10
+ call assert_equal(0, searchdecl('global'))
+ call assert_equal(5, getcurpos()[1])
+
+ 10
+ call assert_equal(0, searchdecl('global', 1))
+ call assert_equal(1, getcurpos()[1])
+
+ bwipe!
+endfunc
+
func Test_search_special()
" this was causing illegal memory access and an endless loop
set t_PE=
diff --git a/src/nvim/testdir/test_sha256.vim b/src/nvim/testdir/test_sha256.vim
index dd4707977e..76d1306836 100644
--- a/src/nvim/testdir/test_sha256.vim
+++ b/src/nvim/testdir/test_sha256.vim
@@ -6,17 +6,17 @@ endif
function Test_sha256()
" test for empty string:
- call assert_equal(sha256(""), 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855')
+ call assert_equal('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', sha256(""))
"'test for 1 char:
- call assert_equal(sha256("a"), 'ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb')
+ call assert_equal('ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb', sha256("a"))
"
"test for 3 chars:
- call assert_equal(sha256("abc"), 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad')
+ call assert_equal('ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad', "abc"->sha256())
" test for contains meta char:
- call assert_equal(sha256("foo\nbar"), '807eff6267f3f926a21d234f7b0cf867a86f47e07a532f15e8cc39ed110ca776')
+ call assert_equal('807eff6267f3f926a21d234f7b0cf867a86f47e07a532f15e8cc39ed110ca776', sha256("foo\nbar"))
" test for contains non-ascii char:
- call assert_equal(sha256("\xde\xad\xbe\xef"), '5f78c33274e43fa9de5659265c1d917e25c03722dcb0b8d27db8d5feaa813953')
+ call assert_equal('5f78c33274e43fa9de5659265c1d917e25c03722dcb0b8d27db8d5feaa813953', sha256("\xde\xad\xbe\xef"))
endfunction
diff --git a/src/nvim/testdir/test_signs.vim b/src/nvim/testdir/test_signs.vim
index 9753100375..f287256396 100644
--- a/src/nvim/testdir/test_signs.vim
+++ b/src/nvim/testdir/test_signs.vim
@@ -393,7 +393,7 @@ func Test_sign_funcs()
" Tests for sign_define()
let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'}
- call assert_equal(0, sign_define("sign1", attr))
+ call assert_equal(0, "sign1"->sign_define(attr))
call assert_equal([{'name' : 'sign1', 'texthl' : 'Error',
\ 'linehl' : 'Search', 'text' : '=>'}], sign_getdefined())
@@ -404,13 +404,13 @@ func Test_sign_funcs()
call Sign_define_ignore_error("sign2", attr)
call assert_equal([{'name' : 'sign2', 'texthl' : 'DiffChange',
\ 'linehl' : 'DiffAdd', 'text' : '!!', 'icon' : 'sign2.ico'}],
- \ sign_getdefined("sign2"))
+ \ "sign2"->sign_getdefined())
" Test for a sign name with digits
call assert_equal(0, sign_define(0002, {'linehl' : 'StatusLine'}))
call assert_equal([{'name' : '2', 'linehl' : 'StatusLine'}],
\ sign_getdefined(0002))
- call sign_undefine(0002)
+ eval 0002->sign_undefine()
" Tests for invalid arguments to sign_define()
call assert_fails('call sign_define("sign4", {"text" : "===>"})', 'E239:')
@@ -434,7 +434,7 @@ func Test_sign_funcs()
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
\ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1',
\ 'priority' : 10}]}],
- \ sign_getplaced('%', {'lnum' : 20}))
+ \ '%'->sign_getplaced({'lnum' : 20}))
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
\ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1',
\ 'priority' : 10}]}],
@@ -490,10 +490,10 @@ func Test_sign_funcs()
\ 'E745:')
" Tests for sign_unplace()
- call sign_place(20, '', 'sign2', 'Xsign', {"lnum" : 30})
+ eval 20->sign_place('', 'sign2', 'Xsign', {"lnum" : 30})
call assert_equal(0, sign_unplace('',
\ {'id' : 20, 'buffer' : 'Xsign'}))
- call assert_equal(-1, sign_unplace('',
+ call assert_equal(-1, ''->sign_unplace(
\ {'id' : 30, 'buffer' : 'Xsign'}))
call sign_place(20, '', 'sign2', 'Xsign', {"lnum" : 30})
call assert_fails("call sign_unplace('',
@@ -1693,7 +1693,7 @@ func Test_sign_jump_func()
let r = sign_jump(5, '', 'foo')
call assert_equal(2, r)
call assert_equal(2, line('.'))
- let r = sign_jump(6, 'g1', 'foo')
+ let r = 6->sign_jump('g1', 'foo')
call assert_equal(5, r)
call assert_equal(5, line('.'))
let r = sign_jump(5, '', 'bar')
@@ -1921,8 +1921,7 @@ func Test_sign_funcs_multi()
\ 'group' : 'g1', 'priority' : 10}], s[0].signs)
" Change an existing sign without specifying the group
- call assert_equal([5], sign_placelist([
- \ {'id' : 5, 'name' : 'sign1', 'buffer' : 'Xsign'}]))
+ call assert_equal([5], [{'id' : 5, 'name' : 'sign1', 'buffer' : 'Xsign'}]->sign_placelist())
let s = sign_getplaced('Xsign', {'id' : 5, 'group' : ''})
call assert_equal([{'id' : 5, 'name' : 'sign1', 'lnum' : 11,
\ 'group' : '', 'priority' : 10}], s[0].signs)
@@ -1955,7 +1954,7 @@ func Test_sign_funcs_multi()
\ {'id' : 1, 'group' : 'g1'}, {'id' : 1, 'group' : 'g2'}]))
" Invalid arguments
- call assert_equal([], sign_unplacelist([]))
+ call assert_equal([], []->sign_unplacelist())
call assert_fails('call sign_unplacelist({})', "E714:")
call assert_fails('call sign_unplacelist([[]])', "E715:")
call assert_fails('call sign_unplacelist(["abc"])', "E715:")
diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim
index e525d06ea2..cf0faeee31 100644
--- a/src/nvim/testdir/test_spell.vim
+++ b/src/nvim/testdir/test_spell.vim
@@ -77,7 +77,7 @@ func Test_spellbadword()
set spell
call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.'))
- call assert_equal(['another', 'caps'], spellbadword('A sentence. another sentence'))
+ call assert_equal(['another', 'caps'], 'A sentence. another sentence'->spellbadword())
call assert_equal(['TheCamelWord', 'bad'], spellbadword('TheCamelWord asdf'))
set spelloptions=camel
@@ -407,7 +407,7 @@ func Test_zz_basic()
\ )
call assert_equal("gebletegek", soundfold('goobledygoook'))
- call assert_equal("kepereneven", soundfold('kóopërÿnôven'))
+ call assert_equal("kepereneven", 'kóopërÿnôven'->soundfold())
call assert_equal("everles gesvets etele", soundfold('oeverloos gezwets edale'))
endfunc
@@ -711,7 +711,7 @@ func TestGoodBadBase()
break
endif
let prevbad = bad
- let lst = spellsuggest(bad, 3)
+ let lst = bad->spellsuggest(3)
normal mm
call add(result, [bad, lst])
diff --git a/src/nvim/testdir/test_spell_utf8.vim b/src/nvim/testdir/test_spell_utf8.vim
index cafdb97f28..3d159f3352 100644
--- a/src/nvim/testdir/test_spell_utf8.vim
+++ b/src/nvim/testdir/test_spell_utf8.vim
@@ -512,8 +512,7 @@ func TestGoodBadBase()
break
endif
let prevbad = bad
- " let lst = bad->spellsuggest(3)
- let lst = spellsuggest(bad, 3)
+ let lst = bad->spellsuggest(3)
normal mm
call add(result, [bad, lst])
@@ -552,8 +551,7 @@ func Test_spell_basic()
\ )
call assert_equal("gebletegek", soundfold('goobledygoook'))
- " call assert_equal("kepereneven", 'kóopërÿnôven'->soundfold())
- call assert_equal("kepereneven", soundfold('kóopërÿnôven'))
+ call assert_equal("kepereneven", 'kóopërÿnôven'->soundfold())
call assert_equal("everles gesvets etele", soundfold('oeverloos gezwets edale'))
endfunc
diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim
index b140077111..d830f5216d 100644
--- a/src/nvim/testdir/test_startup.vim
+++ b/src/nvim/testdir/test_startup.vim
@@ -905,15 +905,13 @@ func Test_not_a_term()
" This will take 2 seconds because of the missing --not-a-term
let cmd = GetVimProg() .. ' --cmd quit ' .. redir
exe "silent !" . cmd
- " call assert_match("\<Esc>", readfile('Xvimout')->join())
- call assert_match("\<Esc>", join(readfile('Xvimout')))
+ call assert_match("\<Esc>", readfile('Xvimout')->join())
call delete('Xvimout')
" With --not-a-term there are no escape sequences.
let cmd = GetVimProg() .. ' --not-a-term --cmd quit ' .. redir
exe "silent !" . cmd
- " call assert_notmatch("\<Esc>", readfile('Xvimout')->join())
- call assert_notmatch("\<Esc>", join(readfile('Xvimout')))
+ call assert_notmatch("\<Esc>", readfile('Xvimout')->join())
call delete('Xvimout')
endfunc
diff --git a/src/nvim/testdir/test_substitute.vim b/src/nvim/testdir/test_substitute.vim
index e7f9bb76f2..113c85acef 100644
--- a/src/nvim/testdir/test_substitute.vim
+++ b/src/nvim/testdir/test_substitute.vim
@@ -547,7 +547,7 @@ func Test_sub_replace_5()
\ substitute('A123456789',
\ 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)',
\ '\=string([submatch(0, 1), submatch(9, 1), ' .
- \ 'submatch(8, 1), submatch(7, 1), submatch(6, 1), ' .
+ \ 'submatch(8, 1), 7->submatch(1), submatch(6, 1), ' .
\ 'submatch(5, 1), submatch(4, 1), submatch(3, 1), ' .
\ 'submatch(2, 1), submatch(1, 1)])',
\ ''))
@@ -752,8 +752,7 @@ endfunc
func Test_submatch_list_concatenate()
let pat = 'A\(.\)'
let Rep = {-> string([submatch(0, 1)] + [[submatch(1)]])}
- " call substitute('A1', pat, Rep, '')->assert_equal("[['A1'], ['1']]")
- call assert_equal(substitute('A1', pat, Rep, ''), "[['A1'], ['1']]")
+ call substitute('A1', pat, Rep, '')->assert_equal("[['A1'], ['1']]")
endfunc
func Test_substitute_skipped_range()
diff --git a/src/nvim/testdir/test_swap.vim b/src/nvim/testdir/test_swap.vim
index e3101d4e44..b3018b2b0d 100644
--- a/src/nvim/testdir/test_swap.vim
+++ b/src/nvim/testdir/test_swap.vim
@@ -113,7 +113,7 @@ func Test_swapinfo()
w
let fname = s:swapname()
call assert_match('Xswapinfo', fname)
- let info = swapinfo(fname)
+ let info = fname->swapinfo()
let ver = printf('VIM %d.%d', v:version / 100, v:version % 100)
call assert_equal(ver, info.version)
@@ -155,7 +155,7 @@ func Test_swapname()
let buf = bufnr('%')
let expected = s:swapname()
wincmd p
- call assert_equal(expected, swapname(buf))
+ call assert_equal(expected, buf->swapname())
new Xtest3
setlocal noswapfile
diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim
index 914d9c2782..757866f5dc 100644
--- a/src/nvim/testdir/test_syntax.vim
+++ b/src/nvim/testdir/test_syntax.vim
@@ -30,23 +30,17 @@ func AssertHighlightGroups(lnum, startcol, expected, trans = 1, msg = "")
" If groups are provided as a string, each character is assumed to be a
" group and spaces represent no group, useful for visually describing tests.
let l:expectedGroups = type(a:expected) == v:t_string
- "\ ? a:expected->split('\zs')->map({_, v -> trim(v)})
- \ ? map(split(a:expected, '\zs'), {_, v -> trim(v)})
+ \ ? a:expected->split('\zs')->map({_, v -> trim(v)})
\ : a:expected
let l:errors = 0
- " let l:msg = (a:msg->empty() ? "" : a:msg .. ": ")
- let l:msg = (empty(a:msg) ? "" : a:msg .. ": ")
+ let l:msg = (a:msg->empty() ? "" : a:msg .. ": ")
\ .. "Wrong highlight group at " .. a:lnum .. ","
- " for l:i in range(a:startcol, a:startcol + l:expectedGroups->len() - 1)
- " let l:errors += synID(a:lnum, l:i, a:trans)
- " \ ->synIDattr("name")
- " \ ->assert_equal(l:expectedGroups[l:i - 1],
- for l:i in range(a:startcol, a:startcol + len(l:expectedGroups) - 1)
- let l:errors +=
- \ assert_equal(synIDattr(synID(a:lnum, l:i, a:trans), "name"),
- \ l:expectedGroups[l:i - 1],
- \ l:msg .. l:i)
+ for l:i in range(a:startcol, a:startcol + l:expectedGroups->len() - 1)
+ let l:errors += synID(a:lnum, l:i, a:trans)
+ \ ->synIDattr("name")
+ \ ->assert_equal(l:expectedGroups[l:i - 1],
+ \ l:msg .. l:i)
endfor
endfunc
diff --git a/src/nvim/testdir/test_system.vim b/src/nvim/testdir/test_system.vim
index 7b8ee778cc..1858b48807 100644
--- a/src/nvim/testdir/test_system.vim
+++ b/src/nvim/testdir/test_system.vim
@@ -121,8 +121,7 @@ func Test_system_with_shell_quote()
let msg = printf('shell=%s shellxquote=%s', &shell, &shellxquote)
try
- " let out = 'echo 123'->system()
- let out = system('echo 123')
+ let out = 'echo 123'->system()
catch
call assert_report(printf('%s: %s', msg, v:exception))
continue
diff --git a/src/nvim/testdir/test_tabpage.vim b/src/nvim/testdir/test_tabpage.vim
index b261b96c3b..9869dc7590 100644
--- a/src/nvim/testdir/test_tabpage.vim
+++ b/src/nvim/testdir/test_tabpage.vim
@@ -35,7 +35,7 @@ function Test_tabpage()
tabnew
tabfirst
call settabvar(2, 'val_num', 100)
- call settabvar(2, 'val_str', 'SetTabVar test')
+ eval 'SetTabVar test'->settabvar(2, 'val_str')
call settabvar(2, 'val_list', ['red', 'blue', 'green'])
"
call assert_true(gettabvar(2, 'val_num') == 100 && gettabvar(2, 'val_str') == 'SetTabVar test' && gettabvar(2, 'val_list') == ['red', 'blue', 'green'])
@@ -184,7 +184,7 @@ function Test_tabpage_with_autocmd()
let s:li = split(join(map(copy(winr), 'gettabwinvar('.tabn.', v:val, "a")')), '\s\+')
call assert_equal(['a', 'a'], s:li)
let s:li = []
- C call map(copy(winr), 'settabwinvar('.tabn.', v:val, ''a'', v:val*2)')
+ C call map(copy(winr), '(v:val*2)->settabwinvar(' .. tabn .. ', v:val, ''a'')')
let s:li = split(join(map(copy(winr), 'gettabwinvar('.tabn.', v:val, "a")')), '\s\+')
call assert_equal(['2', '4'], s:li)
diff --git a/src/nvim/testdir/test_tagjump.vim b/src/nvim/testdir/test_tagjump.vim
index 15182893e9..2aa04df42a 100644
--- a/src/nvim/testdir/test_tagjump.vim
+++ b/src/nvim/testdir/test_tagjump.vim
@@ -351,7 +351,7 @@ func Test_getsettagstack()
" Try to set current index to invalid values
call settagstack(1, {'curidx' : -1})
call assert_equal(1, gettagstack().curidx)
- call settagstack(1, {'curidx' : 50})
+ eval {'curidx' : 50}->settagstack(1)
call assert_equal(4, gettagstack().curidx)
" Try pushing invalid items onto the stack
diff --git a/src/nvim/testdir/test_taglist.vim b/src/nvim/testdir/test_taglist.vim
index e830813081..e11815ff33 100644
--- a/src/nvim/testdir/test_taglist.vim
+++ b/src/nvim/testdir/test_taglist.vim
@@ -14,7 +14,7 @@ func Test_taglist()
split Xtext
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo"), {i, v -> v.name}))
- call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xtext"), {i, v -> v.name}))
+ call assert_equal(['FFoo', 'BFoo'], map("Foo"->taglist("Xtext"), {i, v -> v.name}))
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xfoo"), {i, v -> v.name}))
call assert_equal(['BFoo', 'FFoo'], map(taglist("Foo", "Xbar"), {i, v -> v.name}))
diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim
index ceaa5de92b..5cc0da2586 100644
--- a/src/nvim/testdir/test_timers.vim
+++ b/src/nvim/testdir/test_timers.vim
@@ -77,7 +77,7 @@ endfunc
func Test_info()
let id = timer_start(1000, 'MyHandler')
- let info = timer_info(id)
+ let info = id->timer_info()
call assert_equal(id, info[0]['id'])
call assert_equal(1000, info[0]['time'])
call assert_equal("function('MyHandler')", string(info[0]['callback']))
@@ -113,7 +113,7 @@ func Test_paused()
let info = timer_info(id)
call assert_equal(0, info[0]['paused'])
- call timer_pause(id, 1)
+ eval id->timer_pause(1)
let info = timer_info(id)
call assert_equal(1, info[0]['paused'])
sleep 200m
@@ -148,7 +148,7 @@ func Test_delete_myself()
endfunc
func StopTimer1(timer)
- let g:timer2 = timer_start(10, 'StopTimer2')
+ let g:timer2 = 10->timer_start('StopTimer2')
" avoid maxfuncdepth error
call timer_pause(g:timer1, 1)
sleep 40m
@@ -239,7 +239,7 @@ func FeedAndPeek(timer)
endfunc
func Interrupt(timer)
- " call test_feedinput("\<C-C>")
+ " eval "\<C-C>"->test_feedinput()
call nvim_input("\<C-C>")
endfunc
@@ -251,7 +251,7 @@ func Test_peek_and_get_char()
let intr = timer_start(100, 'Interrupt')
let c = getchar()
call assert_equal(char2nr('a'), c)
- call timer_stop(intr)
+ eval intr->timer_stop()
endfunc
func Test_getchar_zero()
diff --git a/src/nvim/testdir/test_undo.vim b/src/nvim/testdir/test_undo.vim
index c7dcaa0f36..30e00e7ad4 100644
--- a/src/nvim/testdir/test_undo.vim
+++ b/src/nvim/testdir/test_undo.vim
@@ -490,7 +490,7 @@ funct Test_undofile()
call delete('Xundodir', 'd')
" Test undofile() with 'undodir' set to a non-existing directory.
- " call assert_equal('', undofile('Xundofoo'))
+ " call assert_equal('', 'Xundofoo'->undofile())
if isdirectory('/tmp')
set undodir=/tmp
diff --git a/src/nvim/testdir/test_utf8.vim b/src/nvim/testdir/test_utf8.vim
index da72da087f..0818c2e4b0 100644
--- a/src/nvim/testdir/test_utf8.vim
+++ b/src/nvim/testdir/test_utf8.vim
@@ -17,7 +17,7 @@ func Test_strchars()
let exp = [[1, 1, 1], [3, 3, 3], [2, 2, 1], [3, 3, 1], [1, 1, 1]]
for i in range(len(inp))
call assert_equal(exp[i][0], strchars(inp[i]))
- call assert_equal(exp[i][1], strchars(inp[i], 0))
+ call assert_equal(exp[i][1], inp[i]->strchars(0))
call assert_equal(exp[i][2], strchars(inp[i], 1))
endfor
endfunc
@@ -69,7 +69,7 @@ func Test_screenchar_utf8()
call setline(1, ["ABC\u0308"])
redraw
call assert_equal([0x0041], screenchars(1, 1))
- call assert_equal([0x0042], screenchars(1, 2))
+ call assert_equal([0x0042], 1->screenchars(2))
call assert_equal([0x0043, 0x0308], screenchars(1, 3))
call assert_equal("A", screenstring(1, 1))
call assert_equal("B", screenstring(1, 2))
diff --git a/src/nvim/testdir/test_vartabs.vim b/src/nvim/testdir/test_vartabs.vim
index 2fbf130345..46e0d62313 100644
--- a/src/nvim/testdir/test_vartabs.vim
+++ b/src/nvim/testdir/test_vartabs.vim
@@ -330,7 +330,7 @@ func Test_vartabs_shiftwidth()
let lines = ScreenLines([1, 2], winwidth(0))
call s:compare_lines(expect2, lines)
call assert_equal(20, shiftwidth(virtcol('.')-2))
- call assert_equal(30, shiftwidth(virtcol('.')))
+ call assert_equal(30, virtcol('.')->shiftwidth())
norm! $>>
let expect3 = [' ', ' x ', '~ ']
let lines = ScreenLines([1, 3], winwidth(0))
diff --git a/src/nvim/testdir/test_window_cmd.vim b/src/nvim/testdir/test_window_cmd.vim
index 039de0c623..a200bf7d42 100644
--- a/src/nvim/testdir/test_window_cmd.vim
+++ b/src/nvim/testdir/test_window_cmd.vim
@@ -72,7 +72,7 @@ endfunc
func Test_window_quit()
e Xa
split Xb
- call assert_equal(2, winnr('$'))
+ call assert_equal(2, '$'->winnr())
call assert_equal('Xb', bufname(winbufnr(1)))
call assert_equal('Xa', bufname(winbufnr(2)))
@@ -88,7 +88,7 @@ func Test_window_horizontal_split()
3wincmd s
call assert_equal(2, winnr('$'))
call assert_equal(3, winheight(0))
- call assert_equal(winwidth(1), winwidth(2))
+ call assert_equal(winwidth(1), 2->winwidth())
call assert_fails('botright topleft wincmd s', 'E442:')
bw
@@ -267,7 +267,7 @@ func Test_window_height()
wincmd +
call assert_equal(wh1, winheight(1))
- call assert_equal(wh2, winheight(2))
+ call assert_equal(wh2, 2->winheight())
2wincmd _
call assert_equal(2, winheight(1))
@@ -452,7 +452,7 @@ func Test_window_newtab()
wincmd T
call assert_equal(2, tabpagenr('$'))
call assert_equal(['Xb', 'Xa'], map(tabpagebuflist(1), 'bufname(v:val)'))
- call assert_equal(['Xc' ], map(tabpagebuflist(2), 'bufname(v:val)'))
+ call assert_equal(['Xc' ], map(2->tabpagebuflist(), 'bufname(v:val)'))
%bw!
endfunc
@@ -577,8 +577,11 @@ endfunc
function! Fun_RenewFile()
" Need to wait a bit for the timestamp to be older.
- sleep 2
- silent execute '!echo "1" > tmp.txt'
+ let old_ftime = getftime("tmp.txt")
+ while getftime("tmp.txt") == old_ftime
+ sleep 100m
+ silent execute '!echo "1" > tmp.txt'
+ endwhile
sp
wincmd p
edit! tmp.txt
@@ -814,13 +817,25 @@ func Test_winnr()
tabnew
call assert_equal(8, tabpagewinnr(1, 'j'))
- call assert_equal(2, tabpagewinnr(1, 'k'))
+ call assert_equal(2, 1->tabpagewinnr('k'))
call assert_equal(4, tabpagewinnr(1, 'h'))
call assert_equal(6, tabpagewinnr(1, 'l'))
only | tabonly
endfunc
+func Test_winrestview()
+ split runtest.vim
+ normal 50%
+ let view = winsaveview()
+ close
+ split runtest.vim
+ eval view->winrestview()
+ call assert_equal(view, winsaveview())
+
+ bwipe!
+endfunc
+
func Test_win_splitmove()
edit a
leftabove split b
diff --git a/src/nvim/testdir/test_window_id.vim b/src/nvim/testdir/test_window_id.vim
index d10d831650..8bf4ede350 100644
--- a/src/nvim/testdir/test_window_id.vim
+++ b/src/nvim/testdir/test_window_id.vim
@@ -67,7 +67,7 @@ func Test_win_getid()
call win_gotoid(id2)
call assert_equal("two", expand("%"))
- call win_gotoid(id4)
+ eval id4->win_gotoid()
call assert_equal("four", expand("%"))
call win_gotoid(id1)
call assert_equal("one", expand("%"))
@@ -75,17 +75,17 @@ func Test_win_getid()
call assert_equal("five", expand("%"))
call assert_equal(0, win_id2win(9999))
- call assert_equal(nr5, win_id2win(id5))
+ call assert_equal(nr5, id5->win_id2win())
call assert_equal(0, win_id2win(id1))
tabnext
call assert_equal(nr1, win_id2win(id1))
call assert_equal([0, 0], win_id2tabwin(9999))
- call assert_equal([1, nr2], win_id2tabwin(id2))
+ call assert_equal([1, nr2], id2->win_id2tabwin())
call assert_equal([2, nr4], win_id2tabwin(id4))
call assert_equal([], win_findbuf(9999))
- call assert_equal([id2], win_findbuf(bufnr2))
+ call assert_equal([id2], bufnr2->win_findbuf())
call win_gotoid(id5)
split
call assert_equal(sort([id5, win_getid()]), sort(win_findbuf(bufnr5)))
@@ -98,7 +98,7 @@ func Test_win_getid_curtab()
tabfirst
copen
only
- call assert_equal(win_getid(1), win_getid(1, 1))
+ call assert_equal(win_getid(1), 1->win_getid( 1))
tabclose!
endfunc
@@ -120,4 +120,11 @@ func Test_winlayout()
call assert_equal(['col', [['leaf', w3], ['row', [['leaf', w4], ['leaf', w2]]], ['leaf', w1]]], winlayout())
only!
+
+ let w1 = win_getid()
+ call assert_equal(['leaf', w1], winlayout(1))
+ tabnew
+ let w2 = win_getid()
+ call assert_equal(['leaf', w2], 2->winlayout())
+ tabclose
endfunc
diff --git a/test/functional/legacy/searchpos_spec.lua b/test/functional/legacy/searchpos_spec.lua
index 60f1edcd3f..fc18341c38 100644
--- a/test/functional/legacy/searchpos_spec.lua
+++ b/test/functional/legacy/searchpos_spec.lua
@@ -17,7 +17,7 @@ describe('searchpos', function()
call('cursor', 1, 1)
eq({1, 1, 2}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]]))
call('cursor', 1, 2)
- eq({2, 1, 1}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]]))
+ eq({2, 1, 1}, eval([['\%(\([a-z]\)\|\_.\)\{-}xyz'->searchpos('pcW')]]))
command('set cpo-=c')
call('cursor', 1, 2)
diff --git a/test/functional/vimscript/timer_spec.lua b/test/functional/vimscript/timer_spec.lua
index 9ee0735e40..e45b64422f 100644
--- a/test/functional/vimscript/timer_spec.lua
+++ b/test/functional/vimscript/timer_spec.lua
@@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen')
local feed, eq, eval, ok = helpers.feed, helpers.eq, helpers.eval, helpers.ok
local source, nvim_async, run = helpers.source, helpers.nvim_async, helpers.run
local clear, command, funcs = helpers.clear, helpers.command, helpers.funcs
+local exc_exec = helpers.exc_exec
local curbufmeths = helpers.curbufmeths
local load_adjust = helpers.load_adjust
local retry = helpers.retry
@@ -262,4 +263,13 @@ describe('timers', function()
eq(2, eval('g:val'))
end)
+
+ it("timer_start can't be used in the sandbox", function()
+ source [[
+ function! Scary(timer) abort
+ call execute('echo ''execute() should be disallowed''', '')
+ endfunction
+ ]]
+ eq("Vim(call):E48: Not allowed in sandbox", exc_exec("sandbox call timer_start(0, 'Scary')"))
+ end)
end)