aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2021-08-06 18:10:30 +0100
committerSean Dewar <seandewar@users.noreply.github.com>2021-08-12 22:35:20 +0100
commitaa2dc8b7b4e0e86c9102f2df6b670317c5693657 (patch)
tree669a96d841cc4ab90c83bbb1b86ed5cc38013c3b /src
parent003c8acc8a9863932430bfb51bee8403b964c19b (diff)
downloadrneovim-aa2dc8b7b4e0e86c9102f2df6b670317c5693657.tar.gz
rneovim-aa2dc8b7b4e0e86c9102f2df6b670317c5693657.tar.bz2
rneovim-aa2dc8b7b4e0e86c9102f2df6b670317c5693657.zip
vim-patch:8.1.1809: more functions can be used as a method
Problem: More functions can be used as a method. Solution: Add has_key(), split(), str2list(), etc. https://github.com/vim/vim/commit/a74e4946de074d2916e3d6004f7fa1810d12dda9
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.lua22
-rw-r--r--src/nvim/testdir/test_diffmode.vim12
-rw-r--r--src/nvim/testdir/test_method.vim11
-rw-r--r--src/nvim/testdir/test_syntax.vim4
-rw-r--r--src/nvim/testdir/test_system.vim4
5 files changed, 32 insertions, 21 deletions
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index 506368a3b2..50b6eaadfd 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -180,7 +180,7 @@ return {
glob2regpat={args=1},
globpath={args={2, 5}},
has={args=1},
- has_key={args=2},
+ has_key={args=2, base=1},
haslocaldir={args={0,2}},
hasmapto={args={1, 3}},
highlightID={args=1, func='f_hlID'}, -- obsolete
@@ -339,11 +339,11 @@ return {
stdioopen={args=1},
spellbadword={args={0, 1}},
spellsuggest={args={1, 3}},
- split={args={1, 3}},
+ split={args={1, 3}, base=1},
sqrt={args=1, func="float_op_wrapper", data="&sqrt"},
stdpath={args=1},
str2float={args=1},
- str2list={args={1, 2}},
+ str2list={args={1, 2}, base=1},
str2nr={args={1, 2}},
strcharpart={args={2, 3}},
strchars={args={1,2}},
@@ -352,23 +352,23 @@ return {
strgetchar={args={2, 2}},
stridx={args={2, 3}},
string={args=1, base=1},
- strlen={args=1},
+ strlen={args=1, base=1},
strpart={args={2, 4}},
strptime={args=2},
strridx={args={2, 3}},
- strtrans={args=1},
- strwidth={args=1},
+ strtrans={args=1, base=1},
+ strwidth={args=1, base=1},
submatch={args={1, 2}},
- substitute={args=4},
+ substitute={args=4, base=1},
swapinfo={args={1}},
swapname={args={1}},
synID={args=3},
- synIDattr={args={2, 3}},
- synIDtrans={args=1},
+ synIDattr={args={2, 3}, base=1},
+ synIDtrans={args=1, base=1},
synconcealed={args=2},
synstack={args=2},
- system={args={1, 2}},
- systemlist={args={1, 3}},
+ system={args={1, 2}, base=1},
+ systemlist={args={1, 3}, base=1},
tabpagebuflist={args={0, 1}},
tabpagenr={args={0, 1}},
tabpagewinnr={args={1, 2}},
diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim
index 8592f48af7..1552bc4f78 100644
--- a/src/nvim/testdir/test_diffmode.vim
+++ b/src/nvim/testdir/test_diffmode.vim
@@ -741,16 +741,16 @@ func Test_diff_hlID()
diffthis
redraw
- call assert_equal(synIDattr(diff_hlID(-1, 1), "name"), "")
+ call diff_hlID(-1, 1)->synIDattr("name")->assert_equal("")
call assert_equal(diff_hlID(1, 1), hlID("DiffChange"))
- call assert_equal(synIDattr(diff_hlID(1, 1), "name"), "DiffChange")
+ call diff_hlID(1, 1)->synIDattr("name")->assert_equal("DiffChange")
call assert_equal(diff_hlID(1, 2), hlID("DiffText"))
- call assert_equal(synIDattr(diff_hlID(1, 2), "name"), "DiffText")
- call assert_equal(synIDattr(diff_hlID(2, 1), "name"), "")
+ call diff_hlID(1, 2)->synIDattr("name")->assert_equal("DiffText")
+ call diff_hlID(2, 1)->synIDattr("name")->assert_equal("")
call assert_equal(diff_hlID(3, 1), hlID("DiffAdd"))
- call assert_equal(synIDattr(diff_hlID(3, 1), "name"), "DiffAdd")
- call assert_equal(synIDattr(diff_hlID(4, 1), "name"), "")
+ call diff_hlID(3, 1)->synIDattr("name")->assert_equal("DiffAdd")
+ call diff_hlID(4, 1)->synIDattr("name")->assert_equal("")
wincmd w
call assert_equal(diff_hlID(1, 1), hlID("DiffChange"))
diff --git a/src/nvim/testdir/test_method.vim b/src/nvim/testdir/test_method.vim
index 43ed830aba..ef87773924 100644
--- a/src/nvim/testdir/test_method.vim
+++ b/src/nvim/testdir/test_method.vim
@@ -49,6 +49,7 @@ func Test_dict()
" call assert_fails("let x = d->insert(0)", 'E899:')
call assert_fails("let x = d->index(2)", 'E714:')
call assert_fails("let x = d->insert(0)", 'E686:')
+ call assert_true(d->has_key('two'))
call assert_equal([['one', 1], ['two', 2], ['three', 3]], d->items())
call assert_fails("let x = d->join()", 'E714:')
call assert_equal(['one', 'two', 'three'], d->keys())
@@ -70,6 +71,16 @@ func Test_dict()
call assert_equal([1, 2, 3], d->values())
endfunc
+func Test_string()
+ call assert_equal(['1', '2', '3'], '1 2 3'->split())
+ call assert_equal([1, 2, 3], '1 2 3'->split()->map({i, v -> str2nr(v)}))
+ call assert_equal([65, 66, 67], 'ABC'->str2list())
+ call assert_equal(3, 'ABC'->strlen())
+ call assert_equal('a^Mb^[c', "a\rb\ec"->strtrans())
+ call assert_equal(4, "aあb"->strwidth())
+ call assert_equal('axc', 'abc'->substitute('b', 'x', ''))
+endfunc
+
func Test_append()
new
eval ['one', 'two', 'three']->append(1)
diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim
index 875e23894f..2344bac498 100644
--- a/src/nvim/testdir/test_syntax.vim
+++ b/src/nvim/testdir/test_syntax.vim
@@ -546,8 +546,8 @@ func Test_synstack_synIDtrans()
call assert_equal([], synstack(1, 1))
norm f/
- call assert_equal(['cComment', 'cCommentStart'], map(synstack(line("."), col(".")), 'synIDattr(v:val, "name")'))
- call assert_equal(['Comment', 'Comment'], map(synstack(line("."), col(".")), 'synIDattr(synIDtrans(v:val), "name")'))
+ eval synstack(line("."), col("."))->map('synIDattr(v:val, "name")')->assert_equal(['cComment', 'cCommentStart'])
+ eval synstack(line("."), col("."))->map('synIDattr(synIDtrans(v:val), "name")')->assert_equal(['Comment', 'Comment'])
norm fA
call assert_equal(['cComment'], map(synstack(line("."), col(".")), 'synIDattr(v:val, "name")'))
diff --git a/src/nvim/testdir/test_system.vim b/src/nvim/testdir/test_system.vim
index 6bbe714d19..7b8ee778cc 100644
--- a/src/nvim/testdir/test_system.vim
+++ b/src/nvim/testdir/test_system.vim
@@ -7,10 +7,10 @@ func Test_System()
if !executable('echo') || !executable('cat') || !executable('wc')
return
endif
- let out = system('echo 123')
+ let out = 'echo 123'->system()
call assert_equal("123\n", out)
- let out = systemlist('echo 123')
+ let out = 'echo 123'->systemlist()
if &shell =~# 'cmd.exe$'
call assert_equal(["123\r"], out)
else