From 06347a64cac5e33574713a59ace9d1d0ea4b6f82 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 25 May 2024 05:19:46 +0800 Subject: vim-patch:9.1.0443: Can't use blockwise selection with width for getregion() (#28985) Problem: Can't use a blockwise selection with a width for getregion(). Solution: Add support for blockwise selection with width like the return value of getregtype() or the "regtype" value of TextYankPost (zeertzjq). closes: vim/vim#14842 https://github.com/vim/vim/commit/afc2295c2201ae87bfbb42d5f5315ad0583ccabf --- src/nvim/eval.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 7d4438ded6..4adf3ce959 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -4370,14 +4370,13 @@ M.funcs = { The optional argument {opts} is a Dict and supports the following items: - type Specify the region's selection type - (default: "v"): - "v" for |charwise| mode - "V" for |linewise| mode - "" for |blockwise-visual| mode + type Specify the region's selection type. + See |getregtype()| for possible values, + except it cannot be an empty string. + (default: "v") exclusive If |TRUE|, use exclusive selection - for the end position + for the end position. (default: follow 'selection') You can get the last selection type by |visualmode()|. -- cgit From 4757d497f3c85cc343f7dcbc09f95e43ba5c1314 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 25 May 2024 16:53:10 +0800 Subject: vim-patch:9.1.0444: Not enough tests for getregion() with multibyte chars (#29000) Problem: Not enough tests for getregion() with multibyte chars. Solution: Add a few more tests (zeertzjq). closes: vim/vim#14844 https://github.com/vim/vim/commit/dff55a335889c746a79974f7c52cdcdebad682c2 --- src/nvim/eval.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 4adf3ce959..f0c8963459 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -4372,7 +4372,8 @@ M.funcs = { type Specify the region's selection type. See |getregtype()| for possible values, - except it cannot be an empty string. + except that the width can be omitted + and an empty string cannot be used. (default: "v") exclusive If |TRUE|, use exclusive selection -- cgit From 6e8a728e3dad747d0c46dc47a530b76e8997bc08 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 25 May 2024 20:35:37 +0200 Subject: refactor: fix luals type warnings --- 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 f0c8963459..ceaba11f41 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -2133,6 +2133,7 @@ M.funcs = { name = 'exepath', params = { { 'expr', 'any' } }, signature = 'exepath({expr})', + returns = 'string', }, exists = { args = 1, -- cgit From 8cbb1f20e557461c8417583a7f69d53aaaef920b Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Tue, 4 Jun 2024 09:06:02 -0400 Subject: refactor(lua): use tuple syntax everywhere #29111 --- src/nvim/eval.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index ceaba11f41..3c99ba22c2 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -19,7 +19,7 @@ --- @field returns_desc? string --- @field signature? string --- @field desc? string ---- @field params {[1]:string, [2]:string, [3]:string}[] +--- @field params [string, string, string][] --- @field lua? false Do not render type information --- @field tags? string[] Extra tags --- @field data? string Used by gen_eval.lua @@ -11672,7 +11672,7 @@ M.funcs = { ]=], name = 'synconcealed', params = { { 'lnum', 'integer' }, { 'col', 'integer' } }, - returns = '{[1]: integer, [2]: string, [3]: integer}', + returns = '[integer, string, integer]', signature = 'synconcealed({lnum}, {col})', }, synstack = { -- cgit From 5e49ef0af3cb8dba658e5d0dc6a807f8edebf590 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 11 Jun 2024 12:05:18 +0100 Subject: refactor(lua): improve type annotations --- src/nvim/eval.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 3c99ba22c2..f303878897 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -4047,8 +4047,9 @@ M.funcs = { ]=], name = 'getmarklist', - params = { { 'buf', 'any' } }, + params = { { 'buf', 'integer?' } }, signature = 'getmarklist([{buf}])', + returns = 'vim.fn.getmarklist.ret.item[]', }, getmatches = { args = { 0, 1 }, -- cgit From 44410d063ad23544f87d1c8a553de336ae7939d8 Mon Sep 17 00:00:00 2001 From: notomo Date: Tue, 11 Jun 2024 21:11:40 +0900 Subject: fix(types): add some vim.fn type annotations Problem: Some vim.fn have no type annotations. Solution: Add type annotations. --- src/nvim/eval.lua | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index f303878897..0e7b0bf4ec 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -3448,7 +3448,7 @@ M.funcs = { < ]=], name = 'getchar', - params = {}, + params = { { 'expr', '0|1' } }, returns = 'integer', signature = 'getchar([{expr}])', }, @@ -3537,7 +3537,7 @@ M.funcs = { result is converted to a string. ]=], name = 'getcharstr', - params = {}, + params = { { 'expr', '0|1' } }, returns = 'string', signature = 'getcharstr([{expr}])', }, @@ -6482,7 +6482,8 @@ M.funcs = { echo printf("Operator-pending mode bit: 0x%x", op_bit) ]], name = 'maplist', - params = {}, + params = { { 'abbr', '0|1' } }, + returns = 'table[]', signature = 'maplist([{abbr}])', }, mapnew = { @@ -9143,7 +9144,16 @@ M.funcs = { < ]=], name = 'searchpair', - params = {}, + params = { + { 'start', 'any' }, + { 'middle', 'any' }, + { 'end', 'any' }, + { 'flags', 'string' }, + { 'skip', 'any' }, + { 'stopline', 'any' }, + { 'timeout', 'integer' }, + }, + returns = 'integer', signature = 'searchpair({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]])', }, searchpairpos = { @@ -9160,7 +9170,16 @@ M.funcs = { See |match-parens| for a bigger and more useful example. ]=], name = 'searchpairpos', - params = {}, + params = { + { 'start', 'any' }, + { 'middle', 'any' }, + { 'end', 'any' }, + { 'flags', 'string' }, + { 'skip', 'any' }, + { 'stopline', 'any' }, + { 'timeout', 'integer' }, + }, + returns = '[integer, integer]', signature = 'searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]])', }, searchpos = { -- cgit From 72155121006bca884e154e935640054f2e090367 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 12 Jun 2024 11:44:38 +0800 Subject: vim-patch:210b39c: runtime(doc): clarify documentation for "v" position at line() (#29296) Problem: the previous documentation falsely states that "v" always refers to the start of a visual area. In fact, the reference of "v" and "." complement each other. If the cursor is at the start of a (characterwise) visual area, then "v" refers to the end of the area. Solution: be more verbose and explicit about the connection between "." and "v" and also refer to |v_o| which many vim users will be familiar with for visual areas. https://github.com/vim/vim/commit/210b39c2d686d875e2464ca1f42131453dc6bd41 Co-authored-by: Peter Aronoff --- src/nvim/eval.lua | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 0e7b0bf4ec..f5706f9553 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -6081,10 +6081,21 @@ M.funcs = { display isn't updated, e.g. in silent Ex mode) w$ last line visible in current window (this is one less than "w0" if no lines are visible) - v In Visual mode: the start of the Visual area (the - cursor is the end). When not in Visual mode - returns the cursor position. Differs from |'<| in - that it's updated right away. + v When not in Visual mode, returns the cursor + position. In Visual mode, returns the other end + of the Visual area. A good way to think about + this is that in Visual mode "v" and "." complement + each other. While "." refers to the cursor + position, "v" refers to where |v_o| would move the + cursor. As a result, you can use "v" and "." + together to work on all of a selection in + characterwise visual mode. If the cursor is at + the end of a characterwise visual area, "v" refers + to the start of the same visual area. And if the + cursor is at the start of a characterwise visual + area, "v" refers to the end of the same visual + area. "v" differs from |'<| and |'>| in that it's + updated right away. Note that a mark in another file can be used. The line number then applies to another buffer. To get the column number use |col()|. To get both use -- cgit From fab3d4721ffb5109c2c30633605af30d37d7d229 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 13 Jun 2024 04:31:59 +0800 Subject: vim-patch:02f3eba: runtime(doc): deduplicate getpos(), line(), col(), virtcol() Move the main description to getpos() and link to that from the other functions. closes: vim/vim#14970 https://github.com/vim/vim/commit/02f3ebacfbfa1f892347d7532278f24620e68300 --- src/nvim/eval.lua | 113 ++++++++++++++++++++++++++---------------------------- 1 file changed, 54 insertions(+), 59 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index f5706f9553..65f599b213 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -1238,33 +1238,31 @@ M.funcs = { base = 1, desc = [=[ The result is a Number, which is the byte index of the column - position given with {expr}. The accepted positions are: - . the cursor position - $ the end of the cursor line (the result is the - number of bytes in the cursor line plus one) - 'x position of mark x (if the mark is not set, 0 is - returned) - v In Visual mode: the start of the Visual area (the - cursor is the end). When not in Visual mode - returns the cursor position. Differs from |'<| in - that it's updated right away. + position given with {expr}. + For accepted positions see |getpos()|. Additionally {expr} can be [lnum, col]: a |List| with the line and column number. Most useful when the column is "$", to get the last column of a specific line. When "lnum" or "col" is out of range then col() returns zero. + With the optional {winid} argument the values are obtained for that window instead of the current window. + To get the line number use |line()|. To get both use |getpos()|. + For the screen column position use |virtcol()|. For the character position use |charcol()|. + Note that only marks in the current file can be used. + Examples: >vim echo col(".") " column of cursor echo col("$") " length of cursor line plus one echo col("'t") " column of mark t echo col("'" .. markname) " column of mark markname - | in that it's + updated right away. + Note that a mark in another file can be used. The line number + then applies to another buffer. + The result is a |List| with four numbers: [bufnum, lnum, col, off] "bufnum" is zero, unless a mark like '0 or 'A is used, then it @@ -4154,19 +4177,24 @@ M.funcs = { it is the offset in screen columns from the start of the character. E.g., a position within a or after the last character. - Note that for '< and '> Visual mode matters: when it is "V" - (visual line mode) the column of '< is zero and the column of - '> is a large number equal to |v:maxcol|. + + For getting the cursor position see |getcurpos()|. The column number in the returned List is the byte position within the line. To get the character position in the line, use |getcharpos()|. + + Note that for '< and '> Visual mode matters: when it is "V" + (visual line mode) the column of '< is zero and the column of + '> is a large number equal to |v:maxcol|. A very large column number equal to |v:maxcol| can be returned, in which case it means "after the end of the line". If {expr} is invalid, returns a list with all zeros. + This can be used to save and restore the position of a mark: >vim let save_a_mark = getpos("'a") " ... call setpos("'a", save_a_mark) + | in that it's - updated right away. - Note that a mark in another file can be used. The line number - then applies to another buffer. + See |getpos()| for accepted positions. + 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. + Returns 0 for invalid values of {expr} and {winid}. + Examples: >vim echo line(".") " line number of the cursor echo line(".", winid) " idem, in window "winid" @@ -12459,7 +12464,7 @@ M.funcs = { set to 8, it returns 8. |conceal| is ignored. For the byte position use |col()|. - For the use of {expr} see |col()|. + For the use of {expr} see |getpos()| and |col()|. When 'virtualedit' is used {expr} can be [lnum, col, off], where "off" is the offset in screen columns from the start of @@ -12469,18 +12474,6 @@ M.funcs = { beyond the end of the line can be returned. Also see |'virtualedit'| - The accepted positions are: - . the cursor position - $ the end of the cursor line (the result is the - number of displayed characters in the cursor line - plus one) - 'x position of mark x (if the mark is not set, 0 is - returned) - v In Visual mode: the start of the Visual area (the - cursor is the end). When not in Visual mode - returns the cursor position. Differs from |'<| in - that it's updated right away. - If {list} is present and non-zero then virtcol() returns a List with the first and last screen position occupied by the character. @@ -12499,7 +12492,9 @@ M.funcs = { " With text " there", with 't at 'h': echo virtcol("'t") " returns 6 - vim echo max(map(range(1, line('$')), "virtcol([v:val, '$'])")) -- cgit From 6ba152168787e2cf7d197d8f2d682daaca0c94cf Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 14 Jun 2024 04:45:12 +0800 Subject: vim-patch:d353d27: runtime(doc): restore description of "$" in col() and virtcol() (vim/vim#14981) These are different from line() and getpos(). https://github.com/vim/vim/commit/d353d2782032b91498601afefee4256592f48074 --- src/nvim/eval.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 65f599b213..93a2bce2a5 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -1240,6 +1240,8 @@ M.funcs = { The result is a Number, which is the byte index of the column position given with {expr}. For accepted positions see |getpos()|. + When {expr} is "$", it means the end of the cursor line, so + the result is the number of bytes in the cursor line plus one. Additionally {expr} can be [lnum, col]: a |List| with the line and column number. Most useful when the column is "$", to get the last column of a specific line. When "lnum" or "col" is @@ -4144,7 +4146,7 @@ M.funcs = { . The cursor position. $ The last line in the current buffer. 'x Position of mark x (if the mark is not set, 0 is - returned). + returned for all values). w0 First line visible in current window (one if the display isn't updated, e.g. in silent Ex mode). w$ Last line visible in current window (this is one @@ -4194,8 +4196,8 @@ M.funcs = { let save_a_mark = getpos("'a") " ... call setpos("'a", save_a_mark) - - Date: Sat, 15 Jun 2024 06:04:13 +0800 Subject: vim-patch:d6d4e13: runtime(doc): rewrite mkdir() doc and simplify {flags} meaning related: vim/vim#14991 https://github.com/vim/vim/commit/d6d4e1333659c0d2acee3133819498d014df47de Co-authored-by: Christian Brabandt --- src/nvim/eval.lua | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 93a2bce2a5..ec2bfed9e4 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -7264,17 +7264,14 @@ M.funcs = { When {flags} is present it must be a string. An empty string has no effect. - If {flags} contains "p" then intermediate directories are - created as necessary. - - If {flags} contains "D" then {name} is deleted at the end of - the current function, as with: >vim - defer delete({name}, 'd') - < - If {flags} contains "R" then {name} is deleted recursively at - the end of the current function, as with: >vim - defer delete({name}, 'rf') - vim -- cgit From b969e3e0b994db8bf5a5aba498f36ae4ab2555c1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 15 Jun 2024 06:08:45 +0800 Subject: vim-patch:c509c00: runtime(doc): fix wrong helptag for :defer https://github.com/vim/vim/commit/c509c009bbc07eff678a9239a5813398e180f019 Co-authored-by: Christian Brabandt --- src/nvim/eval.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index ec2bfed9e4..e411db0170 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -7267,9 +7267,9 @@ M.funcs = { {flags} can contain these character flags: "p" intermediate directories will be created as necessary "D" {name} will be deleted at the end of the current - function, but not recursively |defer| + function, but not recursively |:defer| "R" {name} will be deleted recursively at the end of the - current function |defer| + current function |:defer| Note that when {name} has more than one part and "p" is used some directories may already exist. Only the first one that -- cgit From 6e28589e00a32045d5a62654151299802e40fdb0 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 15 Jun 2024 01:04:27 +0200 Subject: docs: misc (#29229) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ilia Choly Co-authored-by: Jose Pedro Oliveira Co-authored-by: Maria José Solano Co-authored-by: zeertzjq --- src/nvim/eval.lua | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index e411db0170..79a62874a4 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -4435,8 +4435,8 @@ M.funcs = { difference if the buffer is displayed in a window with different 'virtualedit' or 'list' values. - Examples: > - :xnoremap + Examples: >vim + xnoremap \ echom getregion( \ getpos('v'), getpos('.'), #{ type: mode() }) < @@ -6813,19 +6813,19 @@ M.funcs = { Examples: >vim " Assuming line 3 in buffer 5 contains "a" - :echo matchbufline(5, '\<\k\+\>', 3, 3) - [{'lnum': 3, 'byteidx': 0, 'text': 'a'}] + echo matchbufline(5, '\<\k\+\>', 3, 3) + < `[{'lnum': 3, 'byteidx': 0, 'text': 'a'}]` >vim " Assuming line 4 in buffer 10 contains "tik tok" - :echo matchbufline(10, '\<\k\+\>', 1, 4) - [{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}] - < + echo matchbufline(10, '\<\k\+\>', 1, 4) + < `[{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}]` + If {submatch} is present and is v:true, then submatches like "\1", "\2", etc. are also returned. Example: >vim " Assuming line 2 in buffer 2 contains "acd" - :echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2 + echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2 \ {'submatches': v:true}) - [{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}] - vim - :echo matchstrlist(['tik tok'], '\<\k\+\>') - [{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}] - :echo matchstrlist(['a', 'b'], '\<\k\+\>') - [{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}] - < + echo matchstrlist(['tik tok'], '\<\k\+\>') + < `[{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}]` >vim + echo matchstrlist(['a', 'b'], '\<\k\+\>') + < `[{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}]` + If "submatches" is present and is v:true, then submatches like "\1", "\2", etc. are also returned. Example: >vim - :echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)', + echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)', \ #{submatches: v:true}) - [{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}] - vim nnoremap GG ":echom " .. screencol() .. "\n" nnoremap GG :echom screencol() - noremap GG echom screencol() + noremap GG echom screencol() < ]=], name = 'screencol', -- cgit From bda63d5b97dfb333de6f4bd757dbb978906062a2 Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 25 Jun 2024 15:33:47 +0200 Subject: refactor(typval)!: remove distinction of binary and nonbinary strings This is a breaking change which will make refactor of typval and shada code a lot easier. In particular, code that would use or check for v:msgpack_types.binary in the wild would be broken. This appears to be rarely used in existing plugins. Also some cases where v:msgpack_type.string would be used to represent a binary string of "string" type, we use a BLOB instead, which is vimscripts native type for binary blobs, and already was used for BIN formats when necessary. msgpackdump(msgpackparse(data)) no longer preserves the distinction of BIN and STR strings. This is very common behavior for language-specific msgpack bindings. Nvim uses msgpack as a tool to serialize its data. Nvim is not a tool to bit-perfectly manipulate arbitrary msgpack data out in the wild. The changed tests should indicate how behavior changes in various edge cases. --- src/nvim/eval.lua | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 79a62874a4..82d695d82b 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -7444,12 +7444,7 @@ M.funcs = { C parser does not support such values. float |Float|. This value cannot possibly appear in |msgpackparse()| output. - string |readfile()|-style list of strings. This value will - appear in |msgpackparse()| output if string contains - zero byte or if string is a mapping key and mapping is - being represented as special dictionary for other - reasons. - binary |String|, or |Blob| if binary string contains zero + string |String|, or |Blob| if binary string contains zero byte. This value cannot appear in |msgpackparse()| output since blobs were introduced. array |List|. This value cannot appear in |msgpackparse()| -- cgit From 6a886a2511bbfd24a4d6ecc3f3a75f08a6df9de9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 7 Jul 2024 07:21:14 +0800 Subject: vim-patch:9.1.0538: not possible to assign priority when defining a sign (#29592) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: not possible to assign priority when defining a sign (Mathias Fußenegger) Solution: Add the priority argument for the :sign-define ex command and the sign_define() function (LemonBoy) Use the specified value instead of the default one (SIGN_DEF_PRIO) when no priority is explicitly specified in sign_place or :sign place. fixes: vim/vim#8334 closes: vim/vim#15124 https://github.com/vim/vim/commit/b975ddfdf96644b8df808415dee36f99abd48753 Co-authored-by: LemonBoy --- src/nvim/eval.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 82d695d82b..b57482dc9a 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -10112,6 +10112,7 @@ M.funcs = { linehl highlight group used for the whole line the sign is placed in; not present if not set. name name of the sign + priority default priority value of the sign numhl highlight group used for the line number where the sign is placed; not present if not set. text text that is displayed when there is no icon @@ -10322,7 +10323,8 @@ M.funcs = { priority Priority of the sign. When multiple signs are placed on a line, the sign with the highest priority is used. If not specified, the - default value of 10 is used. See + default value of 10 is used, unless specified + otherwise by the sign definition. See |sign-priority| for more information. If {id} refers to an existing sign, then the existing sign is -- cgit From 435ce9921374055ed2103212bb102e2506c1e2e3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 8 Jul 2024 06:19:12 +0800 Subject: vim-patch:9.1.0540: Unused assignment in sign_define_cmd() Problem: Unused assignment in sign_define_cmd() Solution: Remove the assignment. Also document the "priority" flag of sign_define(). (zeertzjq) closes: vim/vim#15169 https://github.com/vim/vim/commit/fc3f5dba52099d82ccc8bfe309d58a6fac01373d --- 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 b57482dc9a..0e5503b829 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -10057,6 +10057,7 @@ M.funcs = { icon full path to the bitmap file for the sign. linehl highlight group used for the whole line the sign is placed in. + priority default priority value of the sign numhl highlight group used for the line number where the sign is placed. text text that is displayed when there is no icon -- cgit From 545aafbeb80eb52c182ce139800489b392a12d0d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 10 Jul 2024 08:07:16 +0800 Subject: vim-patch:9.1.0547: No way to get the arity of a Vim function (#29638) Problem: No way to get the arity of a Vim function (Austin Ziegler) Solution: Enhance get() Vim script function to return the function argument info using get(func, "arity") (LemonBoy) fixes: vim/vim#15097 closes: vim/vim#15109 https://github.com/vim/vim/commit/48b7d05a4f88c4326bd5d7a73a523f2d953b3e51 Co-authored-by: LemonBoy --- src/nvim/eval.lua | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 0e5503b829..72a3246da5 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -3141,6 +3141,7 @@ M.funcs = { name = 'get', params = { { 'list', 'any[]' }, { 'idx', 'integer' }, { 'default', 'any' } }, signature = 'get({list}, {idx} [, {default}])', + tags = { 'get()-list' }, }, get__1 = { args = { 2, 3 }, @@ -3153,6 +3154,7 @@ M.funcs = { name = 'get', params = { { 'blob', 'string' }, { 'idx', 'integer' }, { 'default', 'any' } }, signature = 'get({blob}, {idx} [, {default}])', + tags = { 'get()-blob' }, }, get__2 = { args = { 2, 3 }, @@ -3168,23 +3170,38 @@ M.funcs = { name = 'get', params = { { 'dict', 'table' }, { 'key', 'string' }, { 'default', 'any' } }, signature = 'get({dict}, {key} [, {default}])', + tags = { 'get()-dict' }, }, get__3 = { args = { 2, 3 }, base = 1, desc = [=[ - Get item {what} from Funcref {func}. Possible values for + Get item {what} from |Funcref| {func}. Possible values for {what} are: - "name" The function name - "func" The function - "dict" The dictionary - "args" The list with arguments + "name" The function name + "func" The function + "dict" The dictionary + "args" The list with arguments + "arity" A dictionary with information about the number of + arguments accepted by the function (minus the + {arglist}) with the following fields: + required the number of positional arguments + optional the number of optional arguments, + in addition to the required ones + varargs |TRUE| if the function accepts a + variable number of arguments |...| + + Note: There is no error, if the {arglist} of + the Funcref contains more arguments than the + Funcref expects, it's not validated. + Returns zero on error. ]=], name = 'get', params = { { 'func', 'function' }, { 'what', 'string' } }, returns = 'any', signature = 'get({func}, {what})', + tags = { 'get()-func' }, }, getbufinfo = { args = { 0, 1 }, -- cgit From 83f42aa450582594f0be044c9f0710809ef0f93d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 12 Jul 2024 07:11:54 +0800 Subject: vim-patch:9.1.0568: Cannot expand paths from 'cdpath' setting Problem: Cannot expand paths from 'cdpath' setting (Daniel Hahler) Solution: Implement 'cdpath' completion, add the new 'dir_in_path' completion type (LemonBoy) fixes vim/vim#374 closes: vim/vim#15205 https://github.com/vim/vim/commit/a20bf69a3b32024cb7809be87af33bf9dc490a19 Co-authored-by: LemonBoy --- 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 72a3246da5..dfb1cab542 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -3672,6 +3672,7 @@ M.funcs = { customlist,{func} custom completion, defined via {func} diff_buffer |:diffget| and |:diffput| completion dir directory names + dir_in_path directory names in |'cdpath'| environment environment variable names event autocommand events expression Vim expression -- cgit From 04c158fbec9aeeccd7bd1bb16fc8a688edadd353 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Mon, 15 Jul 2024 00:54:45 +0200 Subject: docs: misc (#29622) Co-authored-by: Christian Clason Co-authored-by: zeertzjq --- 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 dfb1cab542..bbc78bc68e 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -5293,7 +5293,7 @@ M.funcs = { Note that `v:_null_string`, `v:_null_list`, `v:_null_dict` and `v:_null_blob` have the same `id()` with different types because they are internally represented as NULL pointers. - `id()` returns a hexadecimal representanion of the pointers to + `id()` returns a hexadecimal representation of the pointers to the containers (i.e. like `0x994a40`), same as `printf("%p", {expr})`, but it is advised against counting on the exact format of the return value. -- cgit From 18f1a3aaa5e28421ebe631346e5cca6f75c9b104 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 18 Jul 2024 08:08:56 +0800 Subject: vim-patch:c1b3984: runtime(doc): minor updates. (#29778) closes: vim/vim#15280 https://github.com/vim/vim/commit/c1b3984a7b3cd6adcd1f43e558cb04fad1af3182 Co-authored-by: Shane Harper --- src/nvim/eval.lua | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index bbc78bc68e..7ca14693ef 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -301,16 +301,17 @@ M.funcs = { 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. + {actual}". When {msg} is present it is prefixed to that, along + with the location of the assert when run from a script. 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: >vim - assert_equal('foo', 'bar') - Date: Fri, 19 Jul 2024 12:12:13 +0800 Subject: vim-patch:eb6d733: runtime(doc): fix more inconsistencies in assert function docs (#29796) related: https://github.com/vim/vim/pull/15280#issuecomment-2233771449 closes: vim/vim#15285 https://github.com/vim/vim/commit/eb6d733bef312a0634770e023e8a41f0347f1503 --- src/nvim/eval.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 7ca14693ef..4bc0827bcc 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -301,8 +301,8 @@ M.funcs = { 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, along - with the location of the assert when run from a script. + {actual}". When {msg} is present it is prefixed to that, + along with the location of the assert when run from a script. There is no automatic conversion, the String "4" is different from the Number 4. And the number 4 is different from the @@ -367,16 +367,16 @@ M.funcs = { 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:". >vim - assert_fails('bad cmd', 'E987:') + call 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: >vim - assert_fails('cmd', ['E987:.*expected bool']) + call assert_fails('cmd', ['E987:.*expected bool']) vim - assert_fails('cmd', ['', 'E987:']) + call 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. @@ -412,8 +412,8 @@ M.funcs = { 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, along - with the location of the assert when run from a script. + When {msg} is present it is prefixed to that, along with the + location of the assert when run from a script. Also see |assert-return|. A value is false when it is zero. When {actual} is not a @@ -460,7 +460,7 @@ M.funcs = { Use both to match the whole text. Example: >vim - assert_match('^f.*o$', 'foobar') + call assert_match('^f.*o$', 'foobar') Date: Tue, 30 Jul 2024 11:46:24 +0800 Subject: vim-patch:49cdd62: runtime(doc): list of new/changed features in version9.txt closes: vim/vim#13753 https://github.com/vim/vim/commit/49cdd629a39d7e40e7349e65cb177e2442871a04 Co-authored-by: Yegappan Lakshmanan --- src/nvim/eval.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 4bc0827bcc..687d052d19 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -5752,7 +5752,10 @@ M.funcs = { for [key, value] in items(mydict) echo key .. ': ' .. value endfor - + < + A List or a String argument is also supported. In these + cases, items() returns a List with the index and the value at + the index. ]=], name = 'items', params = { { 'dict', 'any' } }, -- cgit From 2b4049719ab6cc01afcde3b5be7ba33fd1e33ab4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 1 Aug 2024 11:50:38 +0800 Subject: vim-patch:partial:f10911e: Update runtime files (#29936) https://github.com/vim/vim/commit/f10911e5db16f1fe6ab519c5d091ad0c1df0d063 Also cherry-pick E1142 and E1156 tags from Vim. Co-authored-by: Bram Moolenaar --- src/nvim/eval.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 687d052d19..4bb82e5b3e 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -380,12 +380,12 @@ M.funcs = { < If {msg} is empty then it is not used. Do this to get the default message when passing the {lnum} argument. - + *E1115* 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. - + *E1116* 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. @@ -12058,7 +12058,7 @@ M.funcs = { Like |garbagecollect()|, but executed right away. This must only be called directly to avoid any structure to exist internally, and |v:testing| must have been set before calling - any function. + any function. *E1142* ]=], params = {}, signature = 'test_garbagecollect_now()', -- cgit From 28fbba2092adb9659253434605cb94252241f5e0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 6 Aug 2024 20:49:59 +0800 Subject: vim-patch:9.1.0465: missing filecopy() function (#29989) Problem: missing filecopy() function Solution: implement filecopy() Vim script function (Shougo Matsushita) closes: vim/vim#12346 https://github.com/vim/vim/commit/60c8743ab6c90e402e6ed49d27455ef7e5698abe Co-authored-by: Shougo Matsushita --- src/nvim/eval.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 4bb82e5b3e..430ee20081 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -2521,6 +2521,23 @@ M.funcs = { params = { { 'file', 'string' } }, signature = 'file_readable({file})', }, + filecopy = { + args = 2, + base = 1, + desc = [[ + Copy the file pointed to by the name {from} to {to}. The + result is a Number, which is |TRUE| if the file was copied + successfully, and |FALSE| when it failed. + If a file with name {to} already exists, it will fail. + Note that it does not handle directories (yet). + + This function is not available in the |sandbox|. + ]], + name = 'filecopy', + params = { { 'from', 'string' }, { 'to', 'string' } }, + returns = '0|1', + signature = 'filecopy({from}, {to})', + }, filereadable = { args = 1, base = 1, -- cgit From 37952bf7b442cac794c4663f2e0123e7d72bc443 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 6 Aug 2024 21:19:12 +0800 Subject: vim-patch:8.2.4838: checking for absolute path is not trivial (#29990) Problem: Checking for absolute path is not trivial. Solution: Add isabsolutepath(). (closes vim/vim#10303) https://github.com/vim/vim/commit/dca1d40cd0f2af0755519e7028378bd3c8fefd31 vim-patch:8a3b805c6c9c Co-authored-by: LemonBoy --- src/nvim/eval.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 430ee20081..0a003f3b84 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -5686,6 +5686,30 @@ M.funcs = { params = { { 'expr', 'any' } }, signature = 'invert({expr})', }, + isabsolutepath = { + args = 1, + base = 1, + desc = [=[ + The result is a Number, which is |TRUE| when {path} is an + absolute path. + On Unix, a path is considered absolute when it starts with '/'. + On MS-Windows, it is considered absolute when it starts with an + optional drive prefix and is followed by a '\' or '/'. UNC paths + are always absolute. + Example: >vim + echo isabsolutepath('/usr/share/') " 1 + echo isabsolutepath('./foobar') " 0 + echo isabsolutepath('C:\Windows') " 1 + echo isabsolutepath('foobar') " 0 + echo isabsolutepath('\\remote\file') " 1 + < + ]=], + fast = true, + name = 'isabsolutepath', + params = { { 'path', 'any' } }, + returns = '0|1', + signature = 'isabsolutepath({path})', + }, isdirectory = { args = 1, base = 1, -- cgit From e01ccda1bebf2d420d725478b480740ff45ad6ad Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 9 Aug 2024 07:05:33 +0800 Subject: vim-patch:0cc5dce: runtime(doc): clarify directory of Vim's executable vs CWD According to :h win32-PATH, "the same directory as Vim" means the same directory as the Vim executable, not Vim's current directory. In patch 8.2.4860 these two concepts were mixed up. closes: vim/vim#15451 https://github.com/vim/vim/commit/0cc5dce5780d39fe621f6146d4fb862318918125 --- src/nvim/eval.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 0a003f3b84..825931938e 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -2059,8 +2059,10 @@ M.funcs = { This function checks if an executable with the name {expr} exists. {expr} must be the name of the program without any arguments. + executable() uses the value of $PATH and/or the normal - searchpath for programs. *PATHEXT* + searchpath for programs. + *PATHEXT* On MS-Windows the ".exe", ".bat", etc. can optionally be included. Then the extensions in $PATHEXT are tried. Thus if "foo.exe" does not exist, "foo.exe.bat" can be found. If @@ -2070,8 +2072,13 @@ M.funcs = { then the name is also tried without adding an extension. On MS-Windows it only checks if the file exists and is not a directory, not if it's really executable. - On Windows an executable in the same directory as Vim is - always found (it is added to $PATH at |startup|). + On MS-Windows an executable in the same directory as the Vim + executable is always found (it's added to $PATH at |startup|). + *NoDefaultCurrentDirectoryInExePath* + On MS-Windows an executable in Vim's current working directory + is also normally found, but this can be disabled by setting + the $NoDefaultCurrentDirectoryInExePath environment variable. + The result is a Number: 1 exists 0 does not exist -- cgit From 9b5ab66678f8efa1f5fe89205839fe053fe5efaf Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Sun, 11 Aug 2024 11:58:15 +0100 Subject: test(lsp): refactor and tidy - Merge all the top level 'LSP' describe blocks - Refactor text edit tests - Fix typing errors - Add linebreaks between tests --- 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 825931938e..228683065a 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -12445,6 +12445,7 @@ M.funcs = { ]=], name = 'undotree', params = { { 'buf', 'integer|string' } }, + returns = 'vim.fn.undotree.ret', signature = 'undotree([{buf}])', }, uniq = { -- cgit From cd05a72fec49bfaa3911c141ac605b67b6e2270a Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Thu, 29 Aug 2024 00:11:32 +0200 Subject: docs: misc (#29719) Co-authored-by: Evgeni Chasnovski Co-authored-by: Lauri Heiskanen Co-authored-by: Piotr Doroszewski <5605596+Doroszewski@users.noreply.github.com> Co-authored-by: Tobiasz Laskowski Co-authored-by: ariel-lindemann <41641978+ariel-lindemann@users.noreply.github.com> Co-authored-by: glepnir Co-authored-by: zeertzjq --- 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 228683065a..8deff7dd6b 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -2066,7 +2066,7 @@ M.funcs = { On MS-Windows the ".exe", ".bat", etc. can optionally be included. Then the extensions in $PATHEXT are tried. Thus if "foo.exe" does not exist, "foo.exe.bat" can be found. If - $PATHEXT is not set then ".exe;.com;.bat;.cmd" is used. A dot + $PATHEXT is not set then ".com;.exe;.bat;.cmd" is used. A dot by itself can be used in $PATHEXT to try using the name without an extension. When 'shell' looks like a Unix shell, then the name is also tried without adding an extension. -- cgit From 6c2186a998acb4a25ffa0b1b176be5119d1517aa Mon Sep 17 00:00:00 2001 From: glepnir Date: Thu, 29 Aug 2024 18:02:23 +0800 Subject: docs(eval): fix wrong return type of getcharsearch() (#30176) --- 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 8deff7dd6b..5087c2d36d 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -3564,7 +3564,7 @@ M.funcs = { ]=], name = 'getcharsearch', params = {}, - returns = 'table[]', + returns = 'table', signature = 'getcharsearch()', }, getcharstr = { -- cgit From 61e9137394fc5229e582a64316c2ffef55d8d7af Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 1 Sep 2024 13:01:24 -0700 Subject: docs: misc #28970 --- 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 5087c2d36d..cbab735489 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -6442,6 +6442,7 @@ M.funcs = { "lhsrawalt" The {lhs} of the mapping as raw bytes, alternate form, only present when it differs from "lhsraw" "rhs" The {rhs} of the mapping as typed. + "callback" Lua function, if RHS was defined as such. "silent" 1 for a |:map-silent| mapping, else 0. "noremap" 1 if the {rhs} of the mapping is not remappable. "script" 1 if mapping was defined with