From b02eeb6a7281df0561a021d7ae595c84be9a01be Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 2 Feb 2023 13:21:44 +0000 Subject: fix(lua): mark some eval functions that can run in API-fast --- src/nvim/eval.lua | 68 +++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index c17a44b990..9a5ab51c71 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -26,7 +26,7 @@ return { acos={args=1, base=1, float_func="acos"}, -- WJMc add={args=2, base=1}, ['and']={args=2, base=1}, - api_info={}, + api_info={fast=true}, append={args=2, base=2}, appendbufline={args=3, base=3}, argc={args={0, 1}}, @@ -64,14 +64,14 @@ return { bufwinid={args=1, base=1}, bufwinnr={args=1, base=1}, byte2line={args=1, base=1}, - byteidx={args=2, base=1}, - byteidxcomp={args=2, base=1}, + byteidx={args=2, base=1, fast=true}, + byteidxcomp={args=2, base=1, fast=true}, call={args={2, 3}, base=1}, ceil={args=1, base=1, float_func="ceil"}, changenr={}, chanclose={args={1, 2}}, chansend={args=2}, - char2nr={args={1, 2}, base=1}, + char2nr={args={1, 2}, base=1, fast=true}, charclass={args=1, base=1}, charcol={args={1, 2}, base=1}, charidx={args={2, 3}, base=1}, @@ -100,7 +100,7 @@ return { deletebufline={args={2,3}, base=1}, dictwatcheradd={args=3}, dictwatcherdel={args=3}, - did_filetype={}, + did_filetype={fast=true}, diff_filler={args=1, base=1}, diff_hlID={args=2, base=1}, digraph_get={args=1, base=1}, @@ -108,11 +108,11 @@ return { digraph_set={args=2, base=1}, digraph_setlist={args=1, base=1}, empty={args=1, base=1}, - environ={}, - escape={args=2, base=1}, + environ={fast=true}, + escape={args=2, base=1, fast=true}, eval={args=1, base=1}, eventhandler={}, - executable={args=1, base=1}, + executable={args=1, base=1, fast=true}, execute={args={1, 2}, base=1}, exepath={args=1, base=1}, exists={args=1, base=1}, @@ -122,8 +122,8 @@ return { extend={args={2, 3}, base=1}, feedkeys={args={1, 2}, base=1}, file_readable={args=1, base=1, func='f_filereadable'}, -- obsolete - filereadable={args=1, base=1}, - filewritable={args=1, base=1}, + filereadable={args=1, base=1, fast=true}, + filewritable={args=1, base=1, fast=true}, filter={args=2, base=1}, finddir={args={1, 3}, base=1}, findfile={args={1, 3}, base=1}, @@ -131,8 +131,8 @@ return { float2nr={args=1, base=1}, floor={args=1, base=1, float_func="floor"}, fmod={args=2, base=1}, - fnameescape={args=1, base=1}, - fnamemodify={args=2, base=1}, + fnameescape={args=1, base=1, fast=true}, + fnamemodify={args=2, base=1, fast=true}, foldclosed={args=1, base=1}, foldclosedend={args=1, base=1}, foldlevel={args=1, base=1}, @@ -167,17 +167,17 @@ return { getcwd={args={0, 2}, base=1}, getenv={args=1, base=1}, getfontname={args={0, 1}}, - getfperm={args=1, base=1}, - getfsize={args=1, base=1}, - getftime={args=1, base=1}, - getftype={args=1, base=1}, + getfperm={args=1, base=1, fast=true}, + getfsize={args=1, base=1, fast=true}, + getftime={args=1, base=1, fast=true}, + getftype={args=1, base=1, fast=true}, getjumplist={args={0, 2}, base=1}, getline={args={1, 2}, base=1}, getloclist={args={1, 2}}, getmarklist={args={0, 1}, base=1}, getmatches={args={0, 1}}, getmousepos={}, - getpid={}, + getpid={fast=true}, getpos={args=1, base=1}, getqflist={args={0, 1}}, getreg={args={0, 3}, base=1}, @@ -208,7 +208,7 @@ return { histnr={args=1, base=1}, hlID={args=1, base=1}, hlexists={args=1, base=1}, - hostname={}, + hostname={fast=true}, iconv={args=3, base=1, fast=true}, indent={args=1, base=1}, index={args={2, 4}, base=1}, @@ -221,7 +221,7 @@ return { insert={args={2, 3}, base=1}, interrupt={args=0}, invert={args=1, base=1}, - isdirectory={args=1, base=1}, + isdirectory={args=1, base=1, fast=true}, isinf={args=1, base=1}, islocked={args=1, base=1}, isnan={args=1, base=1}, @@ -300,13 +300,13 @@ return { reg_executing={}, reg_recording={}, reg_recorded={}, - reltime={args={0, 2}, base=1}, - reltimefloat={args=1, base=1}, - reltimestr={args=1, base=1}, + reltime={args={0, 2}, base=1, fast=true}, + reltimefloat={args=1, base=1, fast=true}, + reltimestr={args=1, base=1, fast=true}, remove={args={2, 3}, base=1}, rename={args=2, base=1}, - ['repeat']={args=2, base=1}, - resolve={args=1, base=1}, + ['repeat']={args=2, base=1, fast=true}, + resolve={args=1, base=1, fast=true}, reverse={args=1, base=1}, round={args=1, base=1, float_func="round"}, rpcnotify={args=varargs(2)}, @@ -374,24 +374,24 @@ return { split={args={1, 3}, base=1}, sqrt={args=1, base=1, float_func="sqrt"}, srand={args={0, 1}, base=1}, - stdpath={args=1}, + stdpath={args=1, fast=true}, str2float={args=1, base=1}, str2list={args={1, 2}, base=1}, str2nr={args={1, 3}, base=1}, strcharlen={args=1, base=1}, - strcharpart={args={2, 3}, base=1}, + strcharpart={args={2, 3}, base=1, fast=true}, 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}, + stridx={args={2, 3}, base=1, fast=true}, string={args=1, base=1}, strlen={args=1, base=1}, - strpart={args={2, 4}, base=1}, + strpart={args={2, 4}, base=1, fast=true}, strptime={args=2, base=1}, strridx={args={2, 3}, base=1}, - strtrans={args=1, base=1}, - strwidth={args=1, base=1}, + strtrans={args=1, base=1, fast=true}, + strwidth={args=1, base=1, fast=true}, submatch={args={1, 2}, base=1}, substitute={args=4, base=1}, swapinfo={args=1, base=1}, @@ -419,12 +419,12 @@ return { timer_start={args={2, 3}, base=1}, timer_stop={args=1, base=1}, timer_stopall={args=0}, - tolower={args=1, base=1}, - toupper={args=1, base=1}, + tolower={args=1, base=1, fast=true}, + toupper={args=1, base=1, fast=true}, tr={args=3, base=1}, trim={args={1, 3}, base=1}, trunc={args=1, base=1, float_func="trunc"}, - type={args=1, base=1}, + type={args=1, base=1, fast=true}, undofile={args=1, base=1}, undotree={}, uniq={args={1, 3}, base=1}, @@ -447,7 +447,7 @@ return { win_splitmove={args={2, 3}, base=1}, winbufnr={args=1, base=1}, wincol={}, - windowsversion={}, + windowsversion={fast=true}, winheight={args=1, base=1}, winlayout={args={0, 1}, base=1}, winline={}, -- cgit From 904d0995837a2569ae640f5253da3dd4569fec6f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 24 Feb 2023 15:03:28 +0800 Subject: vim-patch:8.2.2449: Vim9: flatten() always changes the list type Problem: Vim9: flatten() always changes the list type. Solution: Disallow using flatten() and add flattennew(). https://github.com/vim/vim/commit/3b690069730805a147d45d92eaca4dc838272d1d Co-authored-by: Bram Moolenaar --- src/nvim/eval.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 9a5ab51c71..a1caeea95a 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -128,6 +128,7 @@ return { finddir={args={1, 3}, base=1}, findfile={args={1, 3}, base=1}, flatten={args={1, 2}, base=1}, + flattennew={args={1, 2}, base=1}, float2nr={args=1, base=1}, floor={args=1, base=1, float_func="floor"}, fmod={args=2, base=1}, -- cgit From 0972d7a12468d6914a70e453af85c307b167c55b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Feb 2023 23:13:12 +0800 Subject: vim-patch:9.0.0196: finding value in list may require a for loop Problem: Finding value in list may require a for loop. Solution: Add indexof(). (Yegappan Lakshmanan, closes vim/vim#10903) https://github.com/vim/vim/commit/b218655d5a485f5b193fb18d7240837d42b89812 Co-authored-by: Yegappan Lakshmanan --- src/nvim/eval.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index a1caeea95a..0c6912a702 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -213,6 +213,7 @@ return { iconv={args=3, base=1, fast=true}, indent={args=1, base=1}, index={args={2, 4}, base=1}, + indexof={args={2, 3}, base=1}, input={args={1, 3}, base=1}, inputdialog={args={1, 3}, base=1}, inputlist={args=1, base=1}, -- cgit From 2c9fbe34b20266ef5ab54f6ed14fb38eef60430d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Feb 2023 10:10:42 +0800 Subject: vim-patch:8.2.2336: Vim9: not possible to extend dictionary with different type (#22425) Problem: Vim9: it is not possible to extend a dictionary with different item types. Solution: Add extendnew(). (closes vim/vim#7666) https://github.com/vim/vim/commit/b0e6b513648db7035046613431a4aa9d71ef4653 Co-authored-by: Bram Moolenaar --- src/nvim/eval.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 0c6912a702..a476e20339 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -120,6 +120,7 @@ return { expand={args={1, 3}, base=1}, expandcmd={args={1, 2}, base=1}, extend={args={2, 3}, base=1}, + extendnew={args={2, 3}, base=1}, feedkeys={args={1, 2}, base=1}, file_readable={args=1, base=1, func='f_filereadable'}, -- obsolete filereadable={args=1, base=1, fast=true}, -- cgit From bfa0bc7df0ca527fcec49dbd2055f1bac438663e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 19:04:32 +0800 Subject: vim-patch:9.0.0795: readblob() always reads the whole file Problem: readblob() always reads the whole file. Solution: Add arguments to read part of the file. (Ken Takata, closes vim/vim#11402) https://github.com/vim/vim/commit/11df3aeee548b959ccd4b9a4d3c44651eab6b3ce Remove trailing whitespace in test as done in patch 9.0.1257. Move the help for rand() before range(). Co-authored-by: K.Takata --- src/nvim/eval.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index a476e20339..24263d9aee 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -296,7 +296,7 @@ return { perleval={args=1, base=1}, rand={args={0, 1}, base=1}, range={args={1, 3}, base=1}, - readblob={args=1, base=1}, + readblob={args={1, 3}, base=1}, readdir={args={1, 2}, base=1}, readfile={args={1, 3}, base=1}, reduce={args={2, 3}, base=1}, -- cgit From f6b9791212e86bac3e8128035dec2bfc5016927f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 20:18:52 +0800 Subject: vim-patch:8.2.3438: cannot manipulate blobs Problem: Cannot manipulate blobs. Solution: Add blob2list() and list2blob(). (Yegappan Lakshmanan, closes vim/vim#8868) https://github.com/vim/vim/commit/5dfe467432638fac2e0156a2f9cd0d9eb569fb39 Co-authored-by: Yegappan Lakshmanan --- src/nvim/eval.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 24263d9aee..ae10a7e035 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -49,6 +49,7 @@ return { assert_true={args={1, 2}, base=1}, atan={args=1, base=1, float_func="atan"}, atan2={args=2, base=1}, + blob2list={args=1, base=1}, browse={args=4}, browsedir={args=2}, bufadd={args=1, base=1}, @@ -249,6 +250,7 @@ return { line={args={1, 2}, base=1}, line2byte={args=1, base=1}, lispindent={args=1, base=1}, + list2blob={args=1, base=1}, list2str={args={1, 2}, base=1}, localtime={}, log={args=1, base=1, float_func="log"}, -- cgit From 674e23f19c509381e2476a3990e21272e362e3a4 Mon Sep 17 00:00:00 2001 From: Michal Liszcz Date: Sat, 11 Mar 2023 04:22:22 +0100 Subject: vim-patch:9.0.0244: cannot easily get the list of sourced scripts (#22596) Problem: Cannot easily get the list of sourced scripts. Solution: Add the getscriptinfo() function. (Yegappan Lakshmanan, closes vim/vim#10957) https://github.com/vim/vim/commit/f768c3d19c518822d89dec4cc3947ddeea249316 Cherry-pick usr_41.txt change from a later runtime update. Co-authored-by: Yegappan Lakshmanan --- src/nvim/eval.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index ae10a7e035..66032adbaf 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -189,6 +189,7 @@ return { gettabinfo={args={0, 1}, base=1}, gettabvar={args={2, 3}, base=1}, gettabwinvar={args={3, 4}, base=1}, + getscriptinfo={}, gettagstack={args={0, 1}, base=1}, gettext={args=1, base=1}, getwininfo={args={0, 1}, base=1}, -- cgit From bcc971de15ed540356405f937d640eaffa4a03bb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 15 Apr 2023 19:50:23 +0800 Subject: vim-patch:9.0.0269: getscriptinfo() does not include the version Problem: getscriptinfo() does not include the version. Cannot select entries by script name. Solution: Add the "version" item and the "name" argument. (Yegappan Lakshmanan, closes vim/vim#10962) https://github.com/vim/vim/commit/520f6ef60a59f7b5f3da9199999d13dbe817d3ce Co-authored-by: Yegappan Lakshmanan --- src/nvim/eval.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 66032adbaf..7dbfac80f3 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -189,7 +189,7 @@ return { gettabinfo={args={0, 1}, base=1}, gettabvar={args={2, 3}, base=1}, gettabwinvar={args={3, 4}, base=1}, - getscriptinfo={}, + getscriptinfo={args={0, 1}}, gettagstack={args={0, 1}, base=1}, gettext={args=1, base=1}, getwininfo={args={0, 1}, base=1}, -- cgit From 85c61d67160133ba53762bc1e5e7bbd7a0c582c0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 19 Apr 2023 10:06:34 +0800 Subject: vim-patch:9.0.1007: there is no way to get a list of swap file names Problem: There is no way to get a list of swap file names. Solution: Add the swapfilelist() function. Use it in the test script to clean up. Remove deleting individual swap files. https://github.com/vim/vim/commit/c216a7a21a25a701b84b79abc1ba6ab0baa3a311 vim-patch:9.0.1005: a failed test may leave a swap file behind Problem: A failed test may leave a swap file behind. Solution: Delete the swap file to avoid another test to fail. Use another file name. https://github.com/vim/vim/commit/d0f8d39d20f8d42f7451f781f7be0bcd20e06741 Cherry-pick test_window_cmd.vim changes from patch 8.2.1593. Remove FUNC_ATTR_UNUSED from eval functions as fptr is always unused. Co-authored-by: Bram Moolenaar --- src/nvim/eval.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 7dbfac80f3..5babfa4809 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -400,6 +400,7 @@ return { strwidth={args=1, base=1, fast=true}, submatch={args={1, 2}, base=1}, substitute={args=4, base=1}, + swapfilelist={}, swapinfo={args=1, base=1}, swapname={args=1, base=1}, synID={args=3}, -- cgit From bfa92d3861e425b59f9b1793c08247965a8e53f5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 25 Apr 2023 22:22:26 +0800 Subject: vim-patch:8.2.5019: cannot get the first screen column of a character (#23312) Problem: Cannot get the first screen column of a character. Solution: Let virtcol() optionally return a list. (closes vim/vim#10482, closes vim/vim#7964) https://github.com/vim/vim/commit/0f7a3e1de6f71e8e1423fe594890d6aa7f94e132 Co-authored-by: LemonBoy --- src/nvim/eval.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 5babfa4809..357ecd5575 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -436,7 +436,7 @@ return { undotree={}, uniq={args={1, 3}, base=1}, values={args=1, base=1}, - virtcol={args=1, base=1}, + virtcol={args={1, 2}, base=1}, virtcol2col={args=3, base=1}, visualmode={args={0, 1}}, wait={args={2,3}}, -- cgit From 191e8b40625731a652bade7000911554834afe5f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 26 Apr 2023 09:50:37 +0800 Subject: vim-patch:9.0.1485: no functions for converting from/to UTF-16 index (#23318) Problem: no functions for converting from/to UTF-16 index. Solution: Add UTF-16 flag to existing funtions and add strutf16len() and utf16idx(). (Yegappan Lakshmanan, closes vim/vim#12216) https://github.com/vim/vim/commit/67672ef097dd708244ff042a8364994da2b91e75 Co-authored-by: Yegappan Lakshmanan --- src/nvim/eval.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 357ecd5575..09705148d0 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -65,8 +65,8 @@ return { bufwinid={args=1, base=1}, bufwinnr={args=1, base=1}, byte2line={args=1, base=1}, - byteidx={args=2, base=1, fast=true}, - byteidxcomp={args=2, base=1, fast=true}, + byteidx={args={2, 3}, base=1, fast=true}, + byteidxcomp={args={2, 3}, base=1, fast=true}, call={args={2, 3}, base=1}, ceil={args=1, base=1, float_func="ceil"}, changenr={}, @@ -75,7 +75,7 @@ return { char2nr={args={1, 2}, base=1, fast=true}, charclass={args=1, base=1}, charcol={args={1, 2}, base=1}, - charidx={args={2, 3}, base=1}, + charidx={args={2, 4}, base=1}, chdir={args=1, base=1}, cindent={args=1, base=1}, clearmatches={args={0, 1}, base=1}, @@ -397,6 +397,7 @@ return { strptime={args=2, base=1}, strridx={args={2, 3}, base=1}, strtrans={args=1, base=1, fast=true}, + strutf16len={args={1, 2}, base=1}, strwidth={args=1, base=1, fast=true}, submatch={args={1, 2}, base=1}, substitute={args=4, base=1}, @@ -435,6 +436,7 @@ return { undofile={args=1, base=1}, undotree={}, uniq={args={1, 3}, base=1}, + utf16idx={args={2, 4}, base=1}, values={args=1, base=1}, virtcol={args={1, 2}, base=1}, virtcol2col={args=3, base=1}, -- cgit From b441dafdf53e367c7d43177274bd781c5c73e6e0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 4 May 2023 16:46:38 +0800 Subject: vim-patch:8.2.2344: using inclusive index for slice is not always desired Problem: Using inclusive index for slice is not always desired. Solution: Add the slice() method, which has an exclusive index. (closes vim/vim#7408) https://github.com/vim/vim/commit/6601b62943a19d4f8818c3638440663d67a17b6a Cherry-pick a line in docs added later. Co-authored-by: Bram Moolenaar --- src/nvim/eval.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 09705148d0..aec5191249 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -371,6 +371,7 @@ return { simplify={args=1, base=1}, sin={args=1, base=1, float_func="sin"}, sinh={args=1, base=1, float_func="sinh"}, + slice={args={2, 3}, base=1}, sockconnect={args={2,3}}, sort={args={1, 3}, base=1}, soundfold={args=1, base=1}, -- cgit From 3724e65c30f7d1ef803ac4e34eab7d4a9531b1a8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 4 May 2023 17:42:34 +0800 Subject: vim-patch:8.2.2607: strcharpart() cannot include composing characters Problem: strcharpart() cannot include composing characters. Solution: Add the {skipcc} argument. https://github.com/vim/vim/commit/02b4d9b18a03549b68e364e428392b7a62766c74 Co-authored-by: Bram Moolenaar --- src/nvim/eval.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index aec5191249..d9c7208c02 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -386,7 +386,7 @@ return { str2list={args={1, 2}, base=1}, str2nr={args={1, 3}, base=1}, strcharlen={args=1, base=1}, - strcharpart={args={2, 3}, base=1, fast=true}, + strcharpart={args={2, 4}, base=1, fast=true}, strchars={args={1, 2}, base=1}, strdisplaywidth={args={1, 2}, base=1}, strftime={args={1, 2}, base=1}, -- cgit From 2f17ef1fc4b96cf1106fd95ba090d34a2e4b977b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 22 Jun 2023 04:09:14 -0700 Subject: fix(messages): use "Vimscript" instead of "VimL" #24111 followup to #24109 fix #16150 --- src/nvim/eval.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index d9c7208c02..fd4108813e 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -8,7 +8,7 @@ -- base For methods: the argument to use as the base argument (1-indexed): -- base->method() -- Defaults to BASE_NONE (function cannot be used as a method). --- func Name of the C function which implements the VimL function. Defaults to +-- func Name of the C function which implements the Vimscript function. Defaults to -- `f_{funcname}`. -- fast Function can run in |api-fast| events. Defaults to false. -- cgit From fd089c8e50c211d7beae15dbc9492ae5a1a5f2e2 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Wed, 26 Jul 2023 09:50:54 +0100 Subject: feat(lua): typing for vim.fn.* (#24473) Problem: No LSP information for `vim.fn.*` Solution: Add meta file for `vim.fn.*`. --- src/nvim/eval.lua | 299 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 169 insertions(+), 130 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index fd4108813e..a9c87e0a6d 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -2,74 +2,85 @@ -- -- Keys: -- --- args Number of arguments, list with maximum and minimum number of arguments --- or list with a minimum number of arguments only. Defaults to zero --- arguments. --- base For methods: the argument to use as the base argument (1-indexed): --- base->method() --- Defaults to BASE_NONE (function cannot be used as a method). --- func Name of the C function which implements the Vimscript function. Defaults to --- `f_{funcname}`. --- fast Function can run in |api-fast| events. Defaults to false. - -local varargs = function(nr) - return {nr} -end +--- @class vim.EvalFn +--- @field args? integer|integer[] Number of arguments, list with maximum and minimum number of arguments +--- or list with a minimum number of arguments only. Defaults to zero +--- arguments. +--- @field base? integer For methods: the argument to use as the base argument (1-indexed): +--- base->method() +--- Defaults to BASE_NONE (function cannot be used as a method). +--- @field func? string Name of the C function which implements the Vimscript function. Defaults to +--- `f_{funcname}`. +--- @field fast? boolean Function can run in |api-fast| events. Defaults to false. +--- @field deprecated? string[]|true +--- @field returns? string|false -- 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" (currently unused after port of v8.2.1168) +local VIMBOOL = '0|1' + return { + --- @type table funcs={ abs={args=1, base=1}, - acos={args=1, base=1, float_func="acos"}, -- WJMc + acos={args=1, base=1, float_func="acos", returns='number'}, -- WJMc add={args=2, base=1}, ['and']={args=2, base=1}, api_info={fast=true}, append={args=2, base=2}, appendbufline={args=3, base=3}, - argc={args={0, 1}}, - argidx={}, - arglistid={args={0, 2}}, + argc={args={0, 1}, returns='integer'}, + argidx={returns='integer'}, + arglistid={args={0, 2}, returns='integer'}, argv={args={0, 2}}, asin={args=1, base=1, float_func="asin"}, -- WJMc - assert_beeps={args=1, base=1}, - assert_equal={args={2, 3}, base=2}, + assert_beeps={args=1, base=1, returns=VIMBOOL}, + assert_equal={args={2, 3}, base=2, returns=VIMBOOL}, assert_equalfile={args={2, 3}, base=1}, - assert_exception={args={1, 2}}, - assert_fails={args={1, 5}, base=1}, - 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, base=1}, + assert_exception={args={1, 2}, returns=VIMBOOL}, + assert_fails={args={1, 5}, base=1, returns=VIMBOOL}, + assert_false={args={1, 2}, base=1, returns=VIMBOOL}, + assert_inrange={args={3, 4}, base=3, returns=VIMBOOL}, + assert_match={args={2, 3}, base=2, returns=VIMBOOL}, + assert_nobeep={args=1, base=1, returns=VIMBOOL}, assert_notequal={args={2, 3}, base=2}, assert_notmatch={args={2, 3}, base=2}, assert_report={args=1, base=1}, assert_true={args={1, 2}, base=1}, - atan={args=1, base=1, float_func="atan"}, - atan2={args=2, base=1}, + atan={args=1, base=1, float_func="atan", returns='number'}, + atan2={args=2, base=1, returns='number'}, blob2list={args=1, base=1}, browse={args=4}, browsedir={args=2}, - 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}, 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}, - bufname={args={0, 1}, base=1}, - bufnr={args={0, 2}, base=1}, - bufwinid={args=1, base=1}, - bufwinnr={args=1, base=1}, - byte2line={args=1, base=1}, - byteidx={args={2, 3}, base=1, fast=true}, - byteidxcomp={args={2, 3}, base=1, fast=true}, + bufadd={args=1, base=1, returns='integer'}, + bufexists={args=1, base=1, returns=VIMBOOL}, + buffer_exists={ + args=1, base=1, func='f_bufexists', + deprecated = { 'Obsolete name for |bufexists()|.' } + }, + buffer_name={ + args={0, 1}, base=1, func='f_bufname', + deprecated = { 'Obsolete name for |bufname()|.' } + }, + buffer_number={ + args={0, 1}, base=1, func='f_bufnr', + deprecated = { 'Obsolete name for |bufnr()|.' } + }, + buflisted={args=1, base=1, returns=VIMBOOL}, + bufload={args=1, base=1, returns=false}, + bufloaded={args=1, base=1, returns=VIMBOOL}, + bufname={args={0, 1}, base=1, returns='string'}, + bufnr={args={0, 2}, base=1, returns='integer'}, + bufwinid={args=1, base=1, returns='integer'}, + bufwinnr={args=1, base=1, returns='integer'}, + byte2line={args=1, base=1, returns='integer'}, + byteidx={args={2, 3}, base=1, fast=true, returns='integer'}, + byteidxcomp={args={2, 3}, base=1, fast=true, returns='integer'}, call={args={2, 3}, base=1}, ceil={args=1, base=1, float_func="ceil"}, - changenr={}, + changenr={returns='integer'}, chanclose={args={1, 2}}, chansend={args=2}, char2nr={args={1, 2}, base=1, fast=true}, @@ -79,11 +90,11 @@ return { chdir={args=1, base=1}, cindent={args=1, base=1}, clearmatches={args={0, 1}, base=1}, - col={args={1, 2}, base=1}, - complete={args=2, base=2}, - complete_add={args=1, base=1}, - complete_check={}, - complete_info={args={0, 1}, base=1}, + col={args={1, 2}, base=1, returns='integer'}, + complete={args=2, base=2, returns=false}, + complete_add={args=1, base=1, returns='0|1|2'}, + complete_check={returns=VIMBOOL}, + complete_info={args={0, 1}, base=1, returns='table'}, confirm={args={1, 4}, base=1}, copy={args=1, base=1}, cos={args=1, base=1, float_func="cos"}, @@ -97,7 +108,7 @@ return { cursor={args={1, 3}, base=1}, debugbreak={args={1, 1}, base=1}, deepcopy={args={1, 2}, base=1}, - delete={args={1,2}, base=1}, + delete={args={1,2}, base=1, returns='integer'}, deletebufline={args={2,3}, base=1}, dictwatcheradd={args=3}, dictwatcherdel={args=3}, @@ -116,33 +127,36 @@ return { executable={args=1, base=1, fast=true}, execute={args={1, 2}, base=1}, exepath={args=1, base=1}, - exists={args=1, base=1}, + exists={args=1, base=1, returns=VIMBOOL}, exp={args=1, base=1, float_func="exp"}, - expand={args={1, 3}, base=1}, + expand={args={1, 3}, base=1, returns='string|string[]'}, expandcmd={args={1, 2}, base=1}, extend={args={2, 3}, base=1}, extendnew={args={2, 3}, base=1}, feedkeys={args={1, 2}, base=1}, - file_readable={args=1, base=1, func='f_filereadable'}, -- obsolete - filereadable={args=1, base=1, fast=true}, - filewritable={args=1, base=1, fast=true}, + file_readable={ + args=1, base=1, func='f_filereadable', + deprecated = { 'Obsolete name for |filereadable()|.' } + }, + filereadable={args=1, base=1, fast=true, returns=VIMBOOL}, + filewritable={args=1, base=1, fast=true, returns=VIMBOOL}, filter={args=2, base=1}, finddir={args={1, 3}, base=1}, findfile={args={1, 3}, base=1}, - flatten={args={1, 2}, base=1}, - flattennew={args={1, 2}, base=1}, + flatten={args={1, 2}, base=1, returns='any[]|0'}, + flattennew={args={1, 2}, base=1, returns='any[]|0'}, float2nr={args=1, base=1}, floor={args=1, base=1, float_func="floor"}, fmod={args=2, base=1}, - fnameescape={args=1, base=1, fast=true}, - fnamemodify={args=2, base=1, fast=true}, - foldclosed={args=1, base=1}, - foldclosedend={args=1, base=1}, - foldlevel={args=1, base=1}, - foldtext={}, - foldtextresult={args=1, base=1}, + fnameescape={args=1, base=1, fast=true, returns='string'}, + fnamemodify={args=2, base=1, fast=true, returns='string'}, + foldclosed={args=1, base=1, returns='integer'}, + foldclosedend={args=1, base=1, returns='integer'}, + foldlevel={args=1, base=1, returns='integer'}, + foldtext={returns='string'}, + foldtextresult={args=1, base=1, returns='string'}, foreground={}, - fullcommand={args=1, base=1}, + fullcommand={args=1, base=1, returns='string'}, funcref={args={1, 3}, base=1}, ['function']={args={1, 3}, base=1}, garbagecollect={args={0, 1}}, @@ -153,39 +167,39 @@ return { getbufvar={args={2, 3}, base=1}, getcellwidths={}, getchangelist={args={0, 1}, base=1}, - getchar={args={0, 1}}, - getcharmod={}, + getchar={args={0, 1}, returns='integer'}, + getcharmod={returns='integer'}, getcharpos={args=1, base=1}, getcharsearch={}, - getcharstr={args={0, 1}}, - getcmdcompltype={}, - getcmdline={}, + getcharstr={args={0, 1}, returns='string'}, + getcmdcompltype={returns='string'}, + getcmdline={returns='string'}, getcmdpos={}, getcmdscreenpos={}, - getcmdtype={}, - getcmdwintype={}, - getcompletion={args={2, 3}, base=1}, + getcmdtype={returns="':'|'>'|'/'|'?'|'@'|'-'|'='"}, + getcmdwintype={returns="':'|'>'|'/'|'?'|'@'|'-'|'='"}, + getcompletion={args={2, 3}, base=1, returns='string[]'}, getcurpos={args={0, 1}, base=1}, getcursorcharpos={args={0, 1}, base=1}, - getcwd={args={0, 2}, base=1}, - getenv={args=1, base=1}, - getfontname={args={0, 1}}, - getfperm={args=1, base=1, fast=true}, - getfsize={args=1, base=1, fast=true}, - getftime={args=1, base=1, fast=true}, - getftype={args=1, base=1, fast=true}, + getcwd={args={0, 2}, base=1, returns='string'}, + getenv={args=1, base=1, returns='string'}, + getfontname={args={0, 1}, returns='string'}, + getfperm={args=1, base=1, fast=true, returns='string'}, + getfsize={args=1, base=1, fast=true, returns='integer'}, + getftime={args=1, base=1, fast=true, returns='integer'}, + getftype={args=1, base=1, fast=true, returns="'file'|'dir'|'link'|'bdev'|'cdev'|'socket'|'fifo'|'other'"}, getjumplist={args={0, 2}, base=1}, getline={args={1, 2}, base=1}, getloclist={args={1, 2}}, getmarklist={args={0, 1}, base=1}, getmatches={args={0, 1}}, getmousepos={}, - getpid={fast=true}, + getpid={fast=true, returns='integer'}, getpos={args=1, base=1}, getqflist={args={0, 1}}, - getreg={args={0, 3}, base=1}, - getreginfo={args={0, 1}, base=1}, - getregtype={args={0, 1}, base=1}, + getreg={args={0, 3}, base=1, returns='string|string[]'}, + getreginfo={args={0, 1}, base=1, returns='table'}, + getregtype={args={0, 1}, base=1, returns='string'}, gettabinfo={args={0, 1}, base=1}, gettabvar={args={2, 3}, base=1}, gettabwinvar={args={3, 4}, base=1}, @@ -194,31 +208,40 @@ return { gettext={args=1, base=1}, getwininfo={args={0, 1}, base=1}, getwinpos={args={0, 1}, base=1}, - getwinposx={}, - getwinposy={}, + getwinposx={returns='integer'}, + getwinposy={returns='integer'}, getwinvar={args={2, 3}, base=1}, glob={args={1, 4}, base=1}, glob2regpat={args=1, base=1}, globpath={args={2, 5}, base=2}, - has={args=1}, - has_key={args=2, base=1}, - haslocaldir={args={0, 2}, base=1}, - hasmapto={args={1, 3}, base=1}, - highlightID={args=1, base=1, func='f_hlID'}, -- obsolete - highlight_exists={args=1, base=1, func='f_hlexists'}, -- obsolete - histadd={args=2, base=2}, - histdel={args={1, 2}, base=1}, - histget={args={1, 2}, base=1}, - histnr={args=1, base=1}, - hlID={args=1, base=1}, - hlexists={args=1, base=1}, - hostname={fast=true}, + has={args=1, returns=VIMBOOL}, + has_key={args=2, base=1, returns=VIMBOOL}, + haslocaldir={args={0, 2}, base=1, returns=VIMBOOL}, + hasmapto={args={1, 3}, base=1, returns=VIMBOOL}, + highlightID={ + args=1, base=1, func='f_hlID', + deprecated = { 'Obsolete name for |hlID()|.' } + }, + highlight_exists={ + args=1, base=1, func='f_hlexists', + deprecated = { 'Obsolete name for |hlexists()|.' } + }, + histadd={args=2, base=2, returns=VIMBOOL}, + histdel={args={1, 2}, base=1, returns=VIMBOOL}, + histget={args={1, 2}, base=1, returns='string'}, + histnr={args=1, base=1, returns='integer'}, + hlID={args=1, base=1, returns='integer'}, + hlexists={args=1, base=1, returns=VIMBOOL}, + hostname={fast=true, returns='string'}, iconv={args=3, base=1, fast=true}, - indent={args=1, base=1}, + indent={args=1, base=1, returns='integer'}, index={args={2, 4}, base=1}, indexof={args={2, 3}, base=1}, input={args={1, 3}, base=1}, - inputdialog={args={1, 3}, base=1}, + inputdialog={ + args={1, 3}, base=1, + deprecated = { 'Use |input()| instead.' } + }, inputlist={args=1, base=1}, inputrestore={}, inputsave={}, @@ -226,16 +249,22 @@ return { insert={args={2, 3}, base=1}, interrupt={args=0}, invert={args=1, base=1}, - isdirectory={args=1, base=1, fast=true}, - isinf={args=1, base=1}, - islocked={args=1, base=1}, - isnan={args=1, base=1}, + isdirectory={args=1, base=1, fast=true, returns=VIMBOOL}, + isinf={args=1, base=1, returns='1|0|-1'}, + islocked={args=1, base=1, returns=VIMBOOL}, + isnan={args=1, base=1, returns=VIMBOOL}, id={args=1}, items={args=1, base=1}, - jobclose={args={1, 2}, func="f_chanclose"}, - jobpid={args=1}, + jobclose={ + args={1, 2}, func="f_chanclose", + deprecated = { 'Obsolete name for |chanclose()|' } + }, + jobpid={args=1, returns='integer'}, jobresize={args=3}, - jobsend={args=2, func="f_chansend"}, + jobsend={ + args=2, func="f_chansend", + deprecated = { 'Obsolete name for |chansend()|' } + }, jobstart={args={1, 2}}, jobstop={args=1}, jobwait={args={1, 2}}, @@ -244,12 +273,14 @@ return { json_encode={args=1, base=1}, keys={args=1, base=1}, keytrans={args=1, base=1}, - last_buffer_nr={}, -- obsolete + last_buffer_nr={ + deprecated = { 'Obsolete name for bufnr("$").' } + }, len={args=1, base=1}, libcall={args=3, base=3}, libcallnr={args=3, base=3}, - line={args={1, 2}, base=1}, - line2byte={args=1, base=1}, + line={args={1, 2}, base=1, returns='integer'}, + line2byte={args=1, base=1, returns='integer'}, lispindent={args=1, base=1}, list2blob={args=1, base=1}, list2str={args={1, 2}, base=1}, @@ -286,7 +317,7 @@ return { pathshorten={args={1, 2}, base=1}, pow={args=2, base=1}, prevnonblank={args=1, base=1}, - printf={args=varargs(1), base=2}, + printf={args={1}, base=2}, prompt_getprompt={args=1, base=1}, prompt_setcallback={args={2, 2}, base=1}, prompt_setinterrupt={args={2, 2}, base=1}, @@ -315,10 +346,18 @@ return { resolve={args=1, base=1, fast=true}, reverse={args=1, base=1}, round={args=1, base=1, float_func="round"}, - rpcnotify={args=varargs(2)}, - rpcrequest={args=varargs(2)}, + rpcnotify={args={2}}, + rpcrequest={args={2}}, rpcstart={args={1, 2}}, - rpcstop={args=1}, + rpcstop={ + args=1, + deprecated = { + 'Use |jobstop()| instead to stop any job, or', + '`chanclose(id, "rpc")` to close RPC communication', + 'without stopping the job. Use chanclose(id) to close', + 'any socket.' + } + }, rubyeval={args=1, base=1}, screenattr={args=2, base=1}, screenchar={args=2, base=1}, @@ -419,7 +458,7 @@ return { taglist={args={1, 2}, base=1}, tan={args=1, base=1, float_func="tan"}, tanh={args=1, base=1, float_func="tanh"}, - tempname={}, + tempname={returns='string'}, termopen={args={1, 2}}, test_garbagecollect_now={}, test_write_list_log={args=1}, @@ -428,16 +467,16 @@ return { timer_start={args={2, 3}, base=1}, timer_stop={args=1, base=1}, timer_stopall={args=0}, - tolower={args=1, base=1, fast=true}, - toupper={args=1, base=1, fast=true}, + tolower={args=1, base=1, fast=true, returns='string'}, + toupper={args=1, base=1, fast=true, returns='string'}, tr={args=3, base=1}, - trim={args={1, 3}, base=1}, + trim={args={1, 3}, base=1, returns='string'}, trunc={args=1, base=1, float_func="trunc"}, type={args=1, base=1, fast=true}, - undofile={args=1, base=1}, + undofile={args=1, base=1, returns='string'}, undotree={}, - uniq={args={1, 3}, base=1}, - utf16idx={args={2, 4}, base=1}, + uniq={args={1, 3}, base=1, returns='any[]|0'}, + utf16idx={args={2, 4}, base=1, returns='integer'}, values={args=1, base=1}, virtcol={args={1, 2}, base=1}, virtcol2col={args=3, base=1}, @@ -445,22 +484,22 @@ return { wait={args={2,3}}, wildmenumode={}, 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_findbuf={args=1, base=1, returns='integer[]'}, + win_getid={args={0, 2}, base=1, returns='integer'}, + win_gettype={args={0, 1}, base=1, returns="'autocmd'|'command'|''|'loclist'|'popup'|'preview'|'quickfix'|'unknown'"}, + win_gotoid={args=1, base=1, returns=VIMBOOL}, win_id2tabwin={args=1, base=1}, win_id2win={args=1, base=1}, win_move_separator={args=2, base=1}, win_move_statusline={args=2, base=1}, win_screenpos={args=1, base=1}, win_splitmove={args={2, 3}, base=1}, - winbufnr={args=1, base=1}, - wincol={}, - windowsversion={fast=true}, - winheight={args=1, base=1}, + winbufnr={args=1, base=1, returns='integer'}, + wincol={returns='integer'}, + windowsversion={fast=true, returns='string'}, + winheight={args=1, base=1, returns='integer'}, winlayout={args={0, 1}, base=1}, - winline={}, + winline={returns='integer'}, winnr={args={0, 1}, base=1}, winrestcmd={}, winrestview={args=1, base=1}, -- cgit From ccf328172bac2b02f9bd19fa58e105958514a28a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 26 Jul 2023 21:07:39 +0800 Subject: fix(gen_vimfn_types): don't include tag before signature's line (#24492) When signature is a bit long or there are too many tags, the tags appear before the signature's line. Don't include the line with tags in the previous function' docs. Also fix lint warnings. --- src/nvim/eval.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index a9c87e0a6d..173c99e271 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -12,7 +12,7 @@ --- @field func? string Name of the C function which implements the Vimscript function. Defaults to --- `f_{funcname}`. --- @field fast? boolean Function can run in |api-fast| events. Defaults to false. ---- @field deprecated? string[]|true +--- @field deprecated? string[] --- @field returns? string|false -- Usable with the base key: use the last function argument as the method base. -- cgit From 42333ea98dfcd2994ee128a3467dfe68205154cd Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 28 Jul 2023 14:48:41 +0100 Subject: feat(docs): generate builtin.txt (#24493) - eval.lua is now the source of truth. - Formatting is much more consistent. - Fixed Lua type generation for polymorphic functions (get(), etc). - Removed "Overview" section from builtin.txt - Can generate this if we really want it. - Moved functions from sign.txt and testing.txt into builtin.txt. - Removed the *timer* *timers* tags since libuv timers via vim.uv should be preferred. - Removed the temp-file-name tag from tempname() - Moved lueval() from lua.txt to builtin.txt. * Fix indent * fixup! * fixup! fixup! * fixup! better tag formatting * fixup: revert changes no longer needed * fixup! CI --------- Co-authored-by: zeertzjq --- src/nvim/eval.lua | 13886 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 13407 insertions(+), 479 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 173c99e271..266873308c 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -3,6 +3,7 @@ -- Keys: -- --- @class vim.EvalFn +--- @field name? string --- @field args? integer|integer[] Number of arguments, list with maximum and minimum number of arguments --- or list with a minimum number of arguments only. Defaults to zero --- arguments. @@ -11,502 +12,13429 @@ --- Defaults to BASE_NONE (function cannot be used as a method). --- @field func? string Name of the C function which implements the Vimscript function. Defaults to --- `f_{funcname}`. +--- @field float_func? string --- @field fast? boolean Function can run in |api-fast| events. Defaults to false. ---- @field deprecated? string[] +--- @field deprecated? true --- @field returns? string|false +--- @field signature string +--- @field desc? string +--- @field params {[1]:string, [2]:string}[] +--- @field lua? false Do not render type information +--- @field tags? string[] Extra tags +--- @field data? string Used by gen_eval.lua -- 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" (currently unused after port of v8.2.1168) -local VIMBOOL = '0|1' - -return { - --- @type table - funcs={ - abs={args=1, base=1}, - acos={args=1, base=1, float_func="acos", returns='number'}, -- WJMc - add={args=2, base=1}, - ['and']={args=2, base=1}, - api_info={fast=true}, - append={args=2, base=2}, - appendbufline={args=3, base=3}, - argc={args={0, 1}, returns='integer'}, - argidx={returns='integer'}, - arglistid={args={0, 2}, returns='integer'}, - argv={args={0, 2}}, - asin={args=1, base=1, float_func="asin"}, -- WJMc - assert_beeps={args=1, base=1, returns=VIMBOOL}, - assert_equal={args={2, 3}, base=2, returns=VIMBOOL}, - assert_equalfile={args={2, 3}, base=1}, - assert_exception={args={1, 2}, returns=VIMBOOL}, - assert_fails={args={1, 5}, base=1, returns=VIMBOOL}, - assert_false={args={1, 2}, base=1, returns=VIMBOOL}, - assert_inrange={args={3, 4}, base=3, returns=VIMBOOL}, - assert_match={args={2, 3}, base=2, returns=VIMBOOL}, - assert_nobeep={args=1, base=1, returns=VIMBOOL}, - assert_notequal={args={2, 3}, base=2}, - assert_notmatch={args={2, 3}, base=2}, - assert_report={args=1, base=1}, - assert_true={args={1, 2}, base=1}, - atan={args=1, base=1, float_func="atan", returns='number'}, - atan2={args=2, base=1, returns='number'}, - blob2list={args=1, base=1}, - browse={args=4}, - browsedir={args=2}, - bufadd={args=1, base=1, returns='integer'}, - bufexists={args=1, base=1, returns=VIMBOOL}, - buffer_exists={ - args=1, base=1, func='f_bufexists', - deprecated = { 'Obsolete name for |bufexists()|.' } +local M = {} + +local VARARGS = { { '...', 'any' } } + +--- @type table +M.funcs = { + abs = { + args = 1, + base = 1, + desc = [=[ + Return the absolute value of {expr}. When {expr} evaluates to + a |Float| abs() returns a |Float|. When {expr} can be + converted to a |Number| abs() returns a |Number|. Otherwise + abs() gives an error message and returns -1. + Examples: > + echo abs(1.456) + < 1.456 > + echo abs(-5.456) + < 5.456 > + echo abs(-4) + < 4 + + Can also be used as a |method|: > + Compute()->abs() + + ]=], + name = 'abs', + params = { { 'expr', 'any' } }, + signature = 'abs({expr})', + returns = 'number' + }, + acos = { + args = 1, + base = 1, + desc = [=[ + Return the arc cosine of {expr} measured in radians, as a + |Float| in the range of [0, pi]. + {expr} must evaluate to a |Float| or a |Number| in the range + [-1, 1]. + Returns NaN if {expr} is outside the range [-1, 1]. Returns + 0.0 if {expr} is not a |Float| or a |Number|. + Examples: > + :echo acos(0) + < 1.570796 > + :echo acos(-0.5) + < 2.094395 + + Can also be used as a |method|: > + Compute()->acos() + + ]=], + float_func = 'acos', + name = 'acos', + params = { { 'expr', 'any' } }, + returns = 'number', + signature = 'acos({expr})', + }, + add = { + args = 2, + base = 1, + desc = [=[ + Append the item {expr} to |List| or |Blob| {object}. Returns + the resulting |List| or |Blob|. Examples: > + :let alist = add([1, 2, 3], item) + :call add(mylist, "woodstock") + + mylist->add(val1)->add(val2) + + ]=], + name = 'add', + params = { { 'object', 'any' }, { 'expr', 'any' } }, + returns = 'any', + signature = 'add({object}, {expr})', + }, + ['and'] = { + args = 2, + base = 1, + desc = [=[ + Bitwise AND on the two arguments. The arguments are converted + to a number. A List, Dict or Float argument causes an error. + Also see `or()` and `xor()`. + Example: > + :let flag = and(bits, 0x80) + + :let flag = bits->and(0x80) + + ]=], + name = 'and', + params = { { 'expr', 'any' }, { 'expr', 'any' } }, + returns = 'integer', + signature = 'and({expr}, {expr})', + }, + api_info = { + desc = [=[ + Returns Dictionary of |api-metadata|. + + View it in a nice human-readable format: > + :lua vim.print(vim.fn.api_info()) + + ]=], + fast = true, + name = 'api_info', + params = {}, + returns = 'table', + signature = 'api_info()', + }, + append = { + args = 2, + base = 2, + desc = [=[ + When {text} is a |List|: Append each item of the |List| as a + text line below line {lnum} in the current buffer. + Otherwise append {text} as one text line below line {lnum} in + the current buffer. + Any type of item is accepted and converted to a String. + {lnum} can be zero to insert a line before the first one. + {lnum} is used like with |getline()|. + Returns 1 for failure ({lnum} out of range or out of memory), + 0 for success. Example: > + :let failed = append(line('$'), "# THE END") + :let failed = append(0, ["Chapter 1", "the beginning"]) + + + mylist->append(lnum) + + ]=], + name = 'append', + params = { { 'lnum', 'integer' }, { 'text', 'any' } }, + returns = '0|1', + signature = 'append({lnum}, {text})', + }, + appendbufline = { + args = 3, + base = 3, + desc = [=[ + Like |append()| but append the text in buffer {expr}. + + This function works only for loaded buffers. First call + |bufload()| if needed. + + For the use of {buf}, see |bufname()|. + + {lnum} is the line number to append below. Note that using + |line()| would use the current buffer, not the one appending + to. Use "$" to append at the end of the buffer. Other string + values are not supported. + + On success 0 is returned, on failure 1 is returned. + + If {buf} is not a valid buffer or {lnum} is not valid, an + error message is given. Example: > + :let failed = appendbufline(13, 0, "# THE START") + < + Can also be used as a |method| after a List: > + mylist->appendbufline(buf, lnum) + + ]=], + name = 'appendbufline', + params = { { 'buf', 'any' }, { 'lnum', 'integer' }, { 'text', 'string' } }, + returns = '0|1', + signature = 'appendbufline({buf}, {lnum}, {text})', + }, + argc = { + args = { 0, 1 }, + desc = [=[ + The result is the number of files in the argument list. See + |arglist|. + If {winid} is not supplied, the argument list of the current + window is used. + If {winid} is -1, the global argument list is used. + Otherwise {winid} specifies the window of which the argument + list is used: either the window number or the window ID. + Returns -1 if the {winid} argument is invalid. + ]=], + name = 'argc', + params = { { 'winid', 'integer' } }, + returns = 'integer', + signature = 'argc([{winid}])', + }, + argidx = { + desc = [=[ + The result is the current index in the argument list. 0 is + the first file. argc() - 1 is the last one. See |arglist|. + ]=], + name = 'argidx', + params = {}, + returns = 'integer', + signature = 'argidx()', + }, + arglistid = { + args = { 0, 2 }, + desc = [=[ + Return the argument list ID. This is a number which + identifies the argument list being used. Zero is used for the + global argument list. See |arglist|. + Returns -1 if the arguments are invalid. + + Without arguments use the current window. + With {winnr} only use this window in the current tab page. + With {winnr} and {tabnr} use the window in the specified tab + page. + {winnr} can be the window number or the |window-ID|. + ]=], + name = 'arglistid', + params = { { 'winnr', 'integer' }, { 'tabnr', 'integer' } }, + returns = 'integer', + signature = 'arglistid([{winnr} [, {tabnr}]])', + }, + argv = { + args = { 0, 2 }, + desc = [=[ + The result is the {nr}th file in the argument list. See + |arglist|. "argv(0)" is the first one. Example: > + :let i = 0 + :while i < argc() + : let f = escape(fnameescape(argv(i)), '.') + : exe 'amenu Arg.' .. f .. ' :e ' .. f .. '' + : let i = i + 1 + :endwhile + + :echo asin(0.8) + < 0.927295 > + :echo asin(-0.5) + < -0.523599 + + Can also be used as a |method|: > + Compute()->asin() + < + ]=], + float_func = 'asin', + name = 'asin', + params = { { 'expr', 'any' } }, + returns = 'number', + signature = 'asin({expr})', + }, + assert_beeps = { + args = 1, + base = 1, + desc = [=[ + Run {cmd} and add an error message to |v:errors| if it does + NOT produce a beep or visual bell. + Also see |assert_fails()|, |assert_nobeep()| and + |assert-return|. + + Can also be used as a |method|: > + GetCmd()->assert_beeps() + < + ]=], + name = 'assert_beeps', + params = { { 'cmd', 'any' } }, + returns = '0|1', + signature = 'assert_beeps({cmd})', + }, + assert_equal = { + args = { 2, 3 }, + base = 2, + desc = [=[ + When {expected} and {actual} are not equal an error message is + added to |v:errors| and 1 is returned. Otherwise zero is + returned. |assert-return| + The error is in the form "Expected {expected} but got + {actual}". When {msg} is present it is prefixed to that. + + There is no automatic conversion, the String "4" is different + from the Number 4. And the number 4 is different from the + Float 4.0. The value of 'ignorecase' is not used here, case + always matters. + Example: > + assert_equal('foo', 'bar') + + mylist->assert_equal([1, 2, 3]) + ]=], + name = 'assert_equal', + params = { { 'expected', 'any' }, { 'actual', 'any' }, { 'msg', 'any' } }, + returns = '0|1', + signature = 'assert_equal({expected}, {actual} [, {msg}])', + }, + assert_equalfile = { + args = { 2, 3 }, + base = 1, + desc = [=[ + When the files {fname-one} and {fname-two} do not contain + exactly the same text an error message is added to |v:errors|. + Also see |assert-return|. + When {fname-one} or {fname-two} does not exist the error will + mention that. + + Can also be used as a |method|: > + GetLog()->assert_equalfile('expected.log') + ]=], + name = 'assert_equalfile', + params = {}, + returns = '0|1', + signature = 'assert_equalfile({fname-one}, {fname-two})', + }, + assert_exception = { + args = { 1, 2 }, + desc = [=[ + When v:exception does not contain the string {error} an error + message is added to |v:errors|. Also see |assert-return|. + This can be used to assert that a command throws an exception. + Using the error number, followed by a colon, avoids problems + with translations: > + try + commandthatfails + call assert_false(1, 'command should have failed') + catch + call assert_exception('E492:') + endtry + < + ]=], + name = 'assert_exception', + params = { { 'error', 'any' }, { 'msg', 'any' } }, + returns = '0|1', + signature = 'assert_exception({error} [, {msg}])', + }, + assert_fails = { + args = { 1, 5 }, + base = 1, + desc = [=[ + Run {cmd} and add an error message to |v:errors| if it does + NOT produce an error or when {error} is not found in the + error message. Also see |assert-return|. + + When {error} is a string it must be found literally in the + first reported error. Most often this will be the error code, + including the colon, e.g. "E123:". > + assert_fails('bad cmd', 'E987:') + < + When {error} is a |List| with one or two strings, these are + used as patterns. The first pattern is matched against the + first reported error: > + assert_fails('cmd', ['E987:.*expected bool']) + + assert_fails('cmd', ['', 'E987:']) + < + If {msg} is empty then it is not used. Do this to get the + default message when passing the {lnum} argument. + + When {lnum} is present and not negative, and the {error} + argument is present and matches, then this is compared with + the line number at which the error was reported. That can be + the line number in a function or in a script. + + When {context} is present it is used as a pattern and matched + against the context (script name or function name) where + {lnum} is located in. + + Note that beeping is not considered an error, and some failing + commands only beep. Use |assert_beeps()| for those. + + Can also be used as a |method|: > + GetCmd()->assert_fails('E99:') + + ]=], + name = 'assert_fails', + params = { + { 'cmd', 'any' }, + { 'error', 'any' }, + { 'msg', 'any' }, + { 'lnum', 'integer' }, + { 'context', 'any' }, }, - buffer_name={ - args={0, 1}, base=1, func='f_bufname', - deprecated = { 'Obsolete name for |bufname()|.' } + returns = '0|1', + signature = 'assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]])', + }, + assert_false = { + args = { 1, 2 }, + base = 1, + desc = [=[ + When {actual} is not false an error message is added to + |v:errors|, like with |assert_equal()|. + The error is in the form "Expected False but got {actual}". + When {msg} is present it is prepended to that. + Also see |assert-return|. + + A value is false when it is zero. When {actual} is not a + number the assert fails. + + Can also be used as a |method|: > + GetResult()->assert_false() + + ]=], + name = 'assert_false', + params = { { 'actual', 'any' }, { 'msg', 'any' } }, + returns = '0|1', + signature = 'assert_false({actual} [, {msg}])', + }, + assert_inrange = { + args = { 3, 4 }, + base = 3, + desc = [=[ + This asserts number and |Float| values. When {actual} is lower + than {lower} or higher than {upper} an error message is added + to |v:errors|. Also see |assert-return|. + The error is in the form "Expected range {lower} - {upper}, + but got {actual}". When {msg} is present it is prefixed to + that. + ]=], + name = 'assert_inrange', + params = { { 'lower', 'any' }, { 'upper', 'any' }, { 'actual', 'any' }, { 'msg', 'any' } }, + returns = '0|1', + signature = 'assert_inrange({lower}, {upper}, {actual} [, {msg}])', + }, + assert_match = { + args = { 2, 3 }, + base = 2, + desc = [=[ + When {pattern} does not match {actual} an error message is + added to |v:errors|. Also see |assert-return|. + The error is in the form "Pattern {pattern} does not match + {actual}". When {msg} is present it is prefixed to that. + + {pattern} is used as with |expr-=~|: The matching is always done + like 'magic' was set and 'cpoptions' is empty, no matter what + the actual value of 'magic' or 'cpoptions' is. + + {actual} is used as a string, automatic conversion applies. + Use "^" and "$" to match with the start and end of the text. + Use both to match the whole text. + + Example: > + assert_match('^f.*o$', 'foobar') + + getFile()->assert_match('foo.*') + < + ]=], + name = 'assert_match', + params = { { 'pattern', 'any' }, { 'actual', 'any' }, { 'msg', 'any' } }, + returns = '0|1', + signature = 'assert_match({pattern}, {actual} [, {msg}])', + }, + assert_nobeep = { + args = 1, + base = 1, + desc = [=[ + Run {cmd} and add an error message to |v:errors| if it + produces a beep or visual bell. + Also see |assert_beeps()|. + + Can also be used as a |method|: > + GetCmd()->assert_nobeep() + < + ]=], + name = 'assert_nobeep', + params = { { 'cmd', 'any' } }, + returns = '0|1', + signature = 'assert_nobeep({cmd})', + }, + assert_notequal = { + args = { 2, 3 }, + base = 2, + desc = [=[ + The opposite of `assert_equal()`: add an error message to + |v:errors| when {expected} and {actual} are equal. + Also see |assert-return|. + + Can also be used as a |method|: > + mylist->assert_notequal([1, 2, 3]) + + < + ]=], + name = 'assert_notequal', + params = { { 'expected', 'any' }, { 'actual', 'any' }, { 'msg', 'any' } }, + returns = '0|1', + signature = 'assert_notequal({expected}, {actual} [, {msg}])', + }, + assert_notmatch = { + args = { 2, 3 }, + base = 2, + desc = [=[ + The opposite of `assert_match()`: add an error message to + |v:errors| when {pattern} matches {actual}. + Also see |assert-return|. + + Can also be used as a |method|: > + getFile()->assert_notmatch('bar.*') + < + ]=], + name = 'assert_notmatch', + params = { { 'pattern', 'any' }, { 'actual', 'any' }, { 'msg', 'any' } }, + returns = '0|1', + signature = 'assert_notmatch({pattern}, {actual} [, {msg}])', + }, + assert_report = { + args = 1, + base = 1, + desc = [=[ + Report a test failure directly, using String {msg}. + Always returns one. + + Can also be used as a |method|: > + GetMessage()->assert_report() + < + ]=], + name = 'assert_report', + params = { { 'msg', 'any' } }, + returns = '0|1', + signature = 'assert_report({msg})', + }, + assert_true = { + args = { 1, 2 }, + base = 1, + desc = [=[ + When {actual} is not true an error message is added to + |v:errors|, like with |assert_equal()|. + Also see |assert-return|. + A value is |TRUE| when it is a non-zero number or |v:true|. + When {actual} is not a number or |v:true| the assert fails. + When {msg} is given it precedes the default message. + + Can also be used as a |method|: > + GetResult()->assert_true() + < + ]=], + name = 'assert_true', + params = { { 'actual', 'any' }, { 'msg', 'any' } }, + returns = '0|1', + signature = 'assert_true({actual} [, {msg}])', + }, + atan = { + args = 1, + base = 1, + desc = [=[ + Return the principal value of the arc tangent of {expr}, in + the range [-pi/2, +pi/2] radians, as a |Float|. + {expr} must evaluate to a |Float| or a |Number|. + Returns 0.0 if {expr} is not a |Float| or a |Number|. + Examples: > + :echo atan(100) + < 1.560797 > + :echo atan(-4.01) + < -1.326405 + + Can also be used as a |method|: > + Compute()->atan() + + ]=]