aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/eval.txt40
-rw-r--r--src/nvim/eval.lua18
-rw-r--r--src/nvim/testdir/test_clientserver.vim12
-rw-r--r--src/nvim/testdir/test_functions.vim6
-rw-r--r--src/nvim/testdir/test_reltime.vim6
-rw-r--r--src/nvim/testdir/test_rename.vim2
6 files changed, 58 insertions, 26 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 1878913311..8305cbf0d5 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -2505,7 +2505,7 @@ keys({dict}) List keys in {dict}
len({expr}) Number the length of {expr}
libcall({lib}, {func}, {arg}) String call {func} in library {lib} with {arg}
libcallnr({lib}, {func}, {arg}) Number idem, but return a Number
-line({expr}) Number line nr of cursor, last line or mark
+line({expr} [, {winid}]) Number line nr of cursor, last line or mark
line2byte({lnum}) Number byte count of line {lnum}
lispindent({lnum}) Number Lisp indent for line {lnum}
list2str({list} [, {utf8}]) String turn numbers in {list} into a String
@@ -5780,7 +5780,9 @@ hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
If no matching mapping is found FALSE is returned.
The following characters are recognized in {mode}:
n Normal mode
- v Visual mode
+ v Visual and Select mode
+ x Visual mode
+ s Select mode
o Operator-pending mode
i Insert mode
l Language-Argument ("r", "f", "t", etc.)
@@ -6483,8 +6485,8 @@ libcallnr({libname}, {funcname}, {argument})
the argument to the called function: >
GetValue()->libcallnr("libc.so", "printf")
<
- *line()*
-line({expr}) The result is a Number, which is the line number of the file
+line({expr} [, {winid}]) *line()*
+ The result is a Number, which is the line number of the file
position given with {expr}. The {expr} argument is a string.
The accepted positions are:
. the cursor position
@@ -6503,8 +6505,11 @@ line({expr}) The result is a Number, which is the line number of the file
then applies to another buffer.
To get the column number use |col()|. To get both use
|getpos()|.
+ With the optional {winid} argument the values are obtained for
+ that window instead of the current window.
Examples: >
line(".") line number of the cursor
+ line(".", winid) idem, in window "winid"
line("'t") line number of mark t
line("'" . marker) line number of mark marker
<
@@ -7670,6 +7675,9 @@ range({expr} [, {max} [, {stride}]]) *range()*
range(0) " []
range(2, 0) " error!
<
+ Can also be used as a |method|: >
+ GetExpr()->range()
+<
*readdir()*
readdir({directory} [, {expr}])
Return a list with file and directory names in {directory}.
@@ -7697,6 +7705,9 @@ readdir({directory} [, {expr}])
endfunction
echo s:tree(".")
<
+ Can also be used as a |method|: >
+ GetDirName()->readdir()
+<
*readfile()*
readfile({fname} [, {type} [, {max}]])
Read file {fname} and return a |List|, each line of the file
@@ -7730,6 +7741,9 @@ readfile({fname} [, {type} [, {max}]])
the result is an empty list.
Also see |writefile()|.
+ Can also be used as a |method|: >
+ GetFileName()->readfile()
+
reg_executing() *reg_executing()*
Returns the single letter name of the register being executed.
Returns an empty string when no register is being executed.
@@ -7757,6 +7771,9 @@ reltime([{start} [, {end}]]) *reltime()*
The {start} and {end} arguments must be values returned by
reltime().
+ Can also be used as a |method|: >
+ GetStart()->reltime()
+<
Note: |localtime()| returns the current (non-relative) time.
reltimefloat({time}) *reltimefloat()*
@@ -7770,6 +7787,9 @@ reltimefloat({time}) *reltimefloat()*
Also see |profiling|.
If there is an error an empty string is returned
+ Can also be used as a |method|: >
+ reltime(start)->reltimefloat()
+
reltimestr({time}) *reltimestr()*
Return a String that represents the time value of {time}.
This is the number of seconds, a dot and the number of
@@ -7784,6 +7804,9 @@ reltimestr({time}) *reltimestr()*
< Also see |profiling|.
If there is an error an empty string is returned
+ Can also be used as a |method|: >
+ reltime(start)->reltimestr()
+<
*remote_expr()* *E449*
remote_expr({server}, {string} [, {idvar} [, {timeout}]])
Send the {string} to {server}. The string is sent as an
@@ -7916,6 +7939,9 @@ rename({from}, {to}) *rename()*
NOTE: If {to} exists it is overwritten without warning.
This function is not available in the |sandbox|.
+ Can also be used as a |method|: >
+ GetOldName()->rename(newname)
+
repeat({expr}, {count}) *repeat()*
Repeat {expr} {count} times and return the concatenated
result. Example: >
@@ -7942,6 +7968,9 @@ resolve({filename}) *resolve()* *E655*
current directory (provided the result is still a relative
path name) and also keeps a trailing path separator.
+ Can also be used as a |method|: >
+ GetName()->resolve()
+<
*reverse()*
reverse({object})
Reverse the order of items in {object} in-place.
@@ -7996,6 +8025,9 @@ rubyeval({expr}) *rubyeval()*
Other objects are represented as strings resulted from their
"Object#to_s" method.
+ Can also be used as a |method|: >
+ GetRubyExpr()->rubyeval()
+
screenattr({row}, {col}) *screenattr()*
Like |screenchar()|, but return the attribute. This is a rather
arbitrary number that can only be used to compare to the
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index 741b8547fe..70aa2bb1f8 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -271,25 +271,25 @@ return {
pyeval={args=1, base=1},
pyxeval={args=1, base=1},
perleval={args=1, base=1},
- range={args={1, 3}},
- readdir={args={1, 2}},
- readfile={args={1, 3}},
+ range={args={1, 3}, base=1},
+ readdir={args={1, 2}, base=1},
+ readfile={args={1, 3}, base=1},
reg_executing={},
reg_recording={},
- reltime={args={0, 2}},
- reltimefloat={args=1},
- reltimestr={args=1},
+ reltime={args={0, 2}, base=1},
+ reltimefloat={args=1, base=1},
+ reltimestr={args=1, base=1},
remove={args={2, 3}, base=1},
- rename={args=2},
+ rename={args=2, base=1},
['repeat']={args=2, base=1},
- resolve={args=1},
+ resolve={args=1, base=1},
reverse={args=1, base=1},
round={args=1, base=1, func="float_op_wrapper", data="&round"},
rpcnotify={args=varargs(2)},
rpcrequest={args=varargs(2)},
rpcstart={args={1, 2}},
rpcstop={args=1},
- rubyeval={args=1},
+ rubyeval={args=1, base=1},
screenattr={args=2},
screenchar={args=2},
screenchars={args=2},
diff --git a/src/nvim/testdir/test_clientserver.vim b/src/nvim/testdir/test_clientserver.vim
index 53704bd094..f3db472b03 100644
--- a/src/nvim/testdir/test_clientserver.vim
+++ b/src/nvim/testdir/test_clientserver.vim
@@ -34,7 +34,7 @@ func Test_client_server()
" When using valgrind it takes much longer.
call WaitForAssert({-> assert_match(name, serverlist())})
- call remote_foreground(name)
+ eval name->remote_foreground()
call remote_send(name, ":let testvar = 'yes'\<CR>")
call WaitFor('remote_expr("' . name . '", "exists(\"testvar\") ? testvar : \"\"", "", 1) == "yes"')
@@ -53,7 +53,7 @@ func Test_client_server()
endif
" Wait for the server to be up and answering requests.
sleep 100m
- call WaitForAssert({-> assert_true(remote_expr(name, "v:version", "", 1) != "")})
+ call WaitForAssert({-> assert_true(name->remote_expr("v:version", "", 1) != "")})
call remote_send(name, ":let testvar = 'maybe'\<CR>")
call WaitForAssert({-> assert_equal('maybe', remote_expr(name, "testvar", "", 2))})
@@ -72,7 +72,7 @@ func Test_client_server()
" Expression evaluated locally.
if v:servername == ''
- call remote_startserver('MYSELF')
+ eval 'MYSELF'->remote_startserver()
" May get MYSELF1 when running the test again.
call assert_match('MYSELF', v:servername)
endif
@@ -80,11 +80,11 @@ func Test_client_server()
call assert_equal('myself', remote_expr(v:servername, 'testvar'))
call remote_send(name, ":call server2client(expand('<client>'), 'got it')\<CR>", 'g:myserverid')
- call assert_equal('got it', remote_read(g:myserverid, 2))
+ call assert_equal('got it', g:myserverid->remote_read(2))
call remote_send(name, ":call server2client(expand('<client>'), 'another')\<CR>", 'g:myserverid')
let peek_result = 'nothing'
- let r = remote_peek(g:myserverid, 'peek_result')
+ let r = g:myserverid->remote_peek('peek_result')
" unpredictable whether the result is already available.
if r > 0
call assert_equal('another', peek_result)
@@ -98,7 +98,7 @@ func Test_client_server()
call assert_equal('another', g:peek_result)
call assert_equal('another', remote_read(g:myserverid, 2))
- call remote_send(name, ":qa!\<CR>")
+ eval name->remote_send(":qa!\<CR>")
try
call WaitForAssert({-> assert_equal("dead", job_status(job))})
finally
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim
index c08b43736b..a80c3e9bf2 100644
--- a/src/nvim/testdir/test_functions.vim
+++ b/src/nvim/testdir/test_functions.vim
@@ -295,7 +295,7 @@ func Test_resolve_unix()
call delete('Xlink')
silent !ln -s -f Xlink2/ Xlink1
- call assert_equal('Xlink2', resolve('Xlink1'))
+ call assert_equal('Xlink2', 'Xlink1'->resolve())
call assert_equal('Xlink2/', resolve('Xlink1/'))
call delete('Xlink1')
@@ -1306,7 +1306,7 @@ func Test_func_range_with_edit()
" is invalid in that buffer.
call writefile(['just one line'], 'Xfuncrange2')
new
- call setline(1, range(10))
+ call setline(1, 10->range())
write Xfuncrange1
call assert_fails('5,8call EditAnotherFile()', 'E16:')
@@ -1578,7 +1578,7 @@ func Test_readdir()
call assert_equal(['bar.txt', 'dir', 'foo.txt'], sort(files))
" Only results containing "f"
- let files = readdir('Xdir', { x -> stridx(x, 'f') !=- 1 })
+ let files = 'Xdir'->readdir({ x -> stridx(x, 'f') !=- 1 })
call assert_equal(['foo.txt'], sort(files))
" Only .txt files
diff --git a/src/nvim/testdir/test_reltime.vim b/src/nvim/testdir/test_reltime.vim
index 2ef2fbba23..37b9e783c6 100644
--- a/src/nvim/testdir/test_reltime.vim
+++ b/src/nvim/testdir/test_reltime.vim
@@ -8,11 +8,11 @@ func Test_reltime()
let now = reltime()
sleep 10m
let later = reltime()
- let elapsed = reltime(now)
+ let elapsed = now->reltime()
call assert_true(reltimestr(elapsed) =~ '0\.0')
- call assert_true(reltimestr(elapsed) != '0.0')
+ call assert_true(elapsed->reltimestr() != '0.0')
call assert_true(reltimefloat(elapsed) < 0.1)
- call assert_true(reltimefloat(elapsed) > 0.0)
+ call assert_true(elapsed->reltimefloat() > 0.0)
let same = reltime(now, now)
call assert_equal('0.000', split(reltimestr(same))[0][:4])
diff --git a/src/nvim/testdir/test_rename.vim b/src/nvim/testdir/test_rename.vim
index 2311caf790..3887fcfabf 100644
--- a/src/nvim/testdir/test_rename.vim
+++ b/src/nvim/testdir/test_rename.vim
@@ -25,7 +25,7 @@ func Test_rename_file_ignore_case()
set fileignorecase
call writefile(['foo'], 'Xrename')
- call assert_equal(0, rename('Xrename', 'XRENAME'))
+ call assert_equal(0, 'Xrename'->rename('XRENAME'))
call assert_equal(['foo'], readfile('XRENAME'))