From 45fe4d11add933df76a2ea4bf52ce8904f4a778b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 4 Dec 2023 13:31:57 -0800 Subject: build: enable lintlua for src/ dir #26395 Problem: Not all Lua code is checked by stylua. Automating code-style is an important mechanism for reducing time spent on accidental (non-essential) complexity. Solution: - Enable lintlua for `src/` directory. followup to 517f0cc634b985057da5b95cf4ad659ee456a77e --- src/nvim/eval.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 55f4721c3a..59423808be 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -2114,7 +2114,7 @@ M.funcs = { name = 'execute', params = { { 'command', 'string|string[]' }, - { 'silent', "''|'silent'|'silent!'" } + { 'silent', "''|'silent'|'silent!'" }, }, returns = 'string', signature = 'execute({command} [, {silent}])', @@ -4519,7 +4519,7 @@ M.funcs = { name = 'getwininfo', params = { { 'winid', 'integer' } }, signature = 'getwininfo([{winid}])', - returns = 'vim.fn.getwininfo.ret.item[]' + returns = 'vim.fn.getwininfo.ret.item[]', }, getwinpos = { args = { 0, 1 }, @@ -6297,7 +6297,7 @@ M.funcs = { ]], name = 'maplist', params = {}, - signature = 'maplist([{abbr}])' + signature = 'maplist([{abbr}])', }, mapnew = { args = 2, @@ -9905,7 +9905,7 @@ M.funcs = { name = 'sign_jump', params = { { 'id', 'integer' }, { 'group', 'string' }, { 'buf', 'integer|string' } }, signature = 'sign_jump({id}, {group}, {buf})', - returns = 'integer' + returns = 'integer', }, sign_place = { args = { 4, 5 }, @@ -9968,7 +9968,7 @@ M.funcs = { { 'dict', 'vim.fn.sign_place.dict' }, }, signature = 'sign_place({id}, {group}, {name}, {buf} [, {dict}])', - returns = 'integer' + returns = 'integer', }, sign_placelist = { args = 1, @@ -10035,7 +10035,7 @@ M.funcs = { name = 'sign_placelist', params = { { 'list', 'vim.fn.sign_placelist.list.item[]' } }, signature = 'sign_placelist({list})', - returns = 'integer[]' + returns = 'integer[]', }, sign_undefine = { args = { 0, 1 }, @@ -10570,7 +10570,7 @@ M.funcs = { signature = 'stdpath({what})', }, state = { - args = {0, 1}, + args = { 0, 1 }, base = 1, desc = [=[ Return a string which contains characters indicating the @@ -12698,7 +12698,7 @@ M.funcs = { name = 'winsaveview', params = {}, signature = 'winsaveview()', - returns = 'vim.fn.winsaveview.ret' + returns = 'vim.fn.winsaveview.ret', }, winwidth = { args = 1, -- cgit From e057b38e7037808b3593fb1035794595b4e4a45e Mon Sep 17 00:00:00 2001 From: Emanuel Date: Wed, 6 Dec 2023 16:56:04 +0100 Subject: fix(json): allow objects with empty keys #25564 Problem: Empty string is a valid JSON key, but json_decode() treats an object with empty key as ":help msgpack-special-dict". #20757 :echo json_decode('{"": "1"}') {'_TYPE': [], '_VAL': [['', '1']]} Note: vim returns `{'': '1'}`. Solution: Allow empty string as an object key. Note that we still (currently) disallow empty keys in object_to_vim() (since 7c01d5ff9286d262097484c680e3a4eab49e2911): https://github.com/neovim/neovim/blob/f64e4b43e1191ff30d902730f752875aa55682ce/src/nvim/api/private/converter.c#L333-L334 Fix #20757 Co-authored-by: Justin M. Keyes --- src/nvim/eval.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 59423808be..51cf7bb0ea 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -5735,8 +5735,7 @@ M.funcs = { Vim value. In the following cases it will output |msgpack-special-dict|: 1. Dictionary contains duplicate key. - 2. Dictionary contains empty key. - 3. String contains NUL byte. Two special dictionaries: for + 2. String contains NUL byte. Two special dictionaries: for dictionary and for string will be emitted in case string with NUL byte was a dictionary key. @@ -7155,7 +7154,6 @@ M.funcs = { are binary strings). 2. String with NUL byte inside. 3. Duplicate key. - 4. Empty key. ext |List| with two values: first is a signed integer representing extension type. Second is |readfile()|-style list of strings. -- cgit From 165e5ececc25ce2d705efdd8ee6c8406884bf898 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 15 Dec 2023 06:42:29 +0800 Subject: vim-patch:17dca3cb97cd (#26584) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit runtime(doc): grammar & typo fixes closes: vim/vim#13654 https://github.com/vim/vim/commit/17dca3cb97cdd7835e334b990565c8c0b93b1284 Co-authored-by: Dominique Pellé --- 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 51cf7bb0ea..a86ca9c1ea 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -7443,9 +7443,9 @@ M.funcs = { Date: Tue, 15 Aug 2023 18:47:14 +0800 Subject: feat(ui): completeopt support popup like vim --- 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 a86ca9c1ea..984935d009 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -1373,6 +1373,8 @@ M.funcs = { no item is selected when using the or keys) inserted Inserted string. [NOT IMPLEMENTED YET] + preview_winid Info floating preview window id. + preview_bufnr Info floating preview buffer id. *complete_info_mode* mode values are: -- cgit From 53a3e6ac879d89039c69d3e44f46ed9bf857a9d9 Mon Sep 17 00:00:00 2001 From: xvzc <45588457+xvzc@users.noreply.github.com> Date: Thu, 28 Dec 2023 20:13:46 +0900 Subject: docs(eval): add parameter type for vim.fn.mode() (#26776) --- 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 984935d009..342650f0e3 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -7057,7 +7057,7 @@ M.funcs = { ]=], name = 'mode', - params = {}, + params = { { 'expr', 'any' } }, signature = 'mode([expr])', }, msgpackdump = { -- cgit From dab584408211a39962a7313b7b8c4cb7e3717a7a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 5 Jan 2024 08:23:51 +0800 Subject: vim-patch:9.1.0010: Keymap completion is not available (#26888) Problem: Keymap completion is not available Solution: Add keymap completion (Doug Kearns) Add keymap completion to the 'keymap' option, user commands and builtin completion functions. closes: vim/vim#13692 https://github.com/vim/vim/commit/81642d9d6ff5cd6a90a012b1b98632ce51eeb1a8 Co-authored-by: Doug Kearns --- 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 342650f0e3..322ab829a0 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -3609,6 +3609,7 @@ M.funcs = { help help subjects highlight highlight groups history |:history| suboptions + keymap keyboard mappings locale locale names (as output of locale -a) mapclear buffer argument mapping mapping name -- cgit From 2bdd8fad4cf4008125ce540453434888c07044a6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 14 Jan 2024 08:44:16 +0800 Subject: docs(builtin): fix mapset() signature (#27008) --- src/nvim/eval.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 322ab829a0..04d176ad1b 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -6315,6 +6315,13 @@ M.funcs = { signature = 'mapnew({expr1}, {expr2})', }, mapset = { + args = { 1, 3 }, + base = 1, + name = 'mapset', + params = { { 'mode', 'string' }, { 'abbr', 'any' }, { 'dict', 'any' } }, + signature = 'mapset({mode}, {abbr}, {dict})', + }, + mapset__1 = { args = { 1, 3 }, base = 1, desc = [=[ @@ -6354,8 +6361,8 @@ M.funcs = { endfor ]=], name = 'mapset', - params = { { 'mode', 'string' }, { 'abbr', 'any' }, { 'dict', 'any' } }, - signature = 'mapset({mode}, {abbr}, {dict})', + params = { { 'dict', 'any' } }, + signature = 'mapset({dict})', }, match = { args = { 2, 4 }, -- cgit From e5ff71fbbfea0431826a82a6de24656d93651ec3 Mon Sep 17 00:00:00 2001 From: altermo Date: Sun, 14 Jan 2024 12:10:31 +0100 Subject: docs(builtin): overload functions with union return types --- src/nvim/eval.lua | 64 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 10 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 04d176ad1b..6bd6087a4e 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -17,7 +17,7 @@ --- @field deprecated? true --- @field returns? string|false --- @field returns_desc? string ---- @field signature string +--- @field signature? string --- @field desc? string --- @field params {[1]:string, [2]:string, [3]:string}[] --- @field lua? false Do not render type information @@ -2348,9 +2348,20 @@ M.funcs = { ]=], name = 'expand', - params = { { 'string', 'string' }, { 'nosuf', 'boolean' }, { 'list', 'any' } }, - returns = 'string|string[]', + params = { { 'string', 'string' }, { 'nosuf', 'boolean' }, { 'list', 'nil|false' } }, signature = 'expand({string} [, {nosuf} [, {list}]])', + returns = 'string', + }, + expand__1 = { + args = { 3 }, + base = 1, + name = 'expand', + params = { + { 'string', 'string' }, + { 'nosuf', 'boolean' }, + { 'list', 'true|number|string|table' }, + }, + returns = 'string|string[]', }, expandcmd = { args = { 1, 2 }, @@ -3918,9 +3929,16 @@ M.funcs = { |getbufoneline()| ]=], name = 'getline', - params = { { 'lnum', 'integer' }, { 'end', 'any' } }, - returns = 'string|string[]', + params = { { 'lnum', 'integer' }, { 'end', 'nil|false' } }, signature = 'getline({lnum} [, {end}])', + returns = 'string', + }, + getline__1 = { + args = { 2 }, + base = 1, + name = 'getline', + params = { { 'lnum', 'integer' }, { 'end', 'true|number|string|table' } }, + returns = 'string|string[]', }, getloclist = { args = { 1, 2 }, @@ -4249,9 +4267,16 @@ M.funcs = { ]=], name = 'getreg', - params = { { 'regname', 'string' }, { 'list', 'any' } }, - returns = 'string|string[]', + params = { { 'regname', 'string' }, { 'list', 'nil|false' } }, signature = 'getreg([{regname} [, 1 [, {list}]]])', + returns = 'string', + }, + getreg__1 = { + args = { 3 }, + base = 1, + name = 'getreg', + params = { { 'regname', 'string' }, { 'list', 'true|number|string|table' } }, + returns = 'string|string[]', }, getreginfo = { args = { 0, 1 }, @@ -6218,10 +6243,22 @@ M.funcs = { { 'name', 'string' }, { 'mode', 'string' }, { 'abbr', 'boolean' }, - { 'dict', 'boolean' }, + { 'dict', 'false' }, }, - returns = 'string|table', signature = 'maparg({name} [, {mode} [, {abbr} [, {dict}]]])', + returns = 'string', + }, + maparg__1 = { + args = { 4 }, + base = 1, + name = 'maparg', + params = { + { 'name', 'string' }, + { 'mode', 'string' }, + { 'abbr', 'boolean' }, + { 'dict', 'true' }, + }, + returns = 'string|table', }, mapcheck = { args = { 1, 3 }, @@ -11120,9 +11157,16 @@ M.funcs = { ]=], name = 'submatch', + params = { { 'nr', 'integer' }, { 'list', 'nil' } }, + signature = 'submatch({nr} [, {list}])', + returns = 'string', + }, + submatch__1 = { + args = { 2 }, + base = 1, + name = 'submatch', params = { { 'nr', 'integer' }, { 'list', 'integer' } }, returns = 'string|string[]', - signature = 'submatch({nr} [, {list}])', }, substitute = { args = 4, -- cgit From 73e1942abe7a96d63ce3749af4187f2cdff87e69 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 16 Jan 2024 08:00:08 +0800 Subject: vim-patch:9.1.0009: Cannot easily get the list of matches (#27028) Problem: Cannot easily get the list of matches Solution: Add the matchstrlist() and matchbufline() Vim script functions (Yegappan Lakshmanan) closes: vim/vim#13766 Omit CHECK_LIST_MATERIALIZE(): it populates a List with numbers only, and there is a check for strings below. https://github.com/vim/vim/commit/f93b1c881a99fa847a1bafa71877d7e16f18e6ef vim-patch:eb3475df0d92 runtime(doc): Replace non-breaking space with normal space (vim/vim#13868) https://github.com/vim/vim/commit/eb3475df0d927a178789cf8e7fc4983932e1cdbe Co-authored-by: Yegappan Lakshmanan <4298407+yegappan@users.noreply.github.com> --- src/nvim/eval.lua | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 6bd6087a4e..9545cb9823 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -6615,6 +6615,60 @@ M.funcs = { params = { { 'nr', 'integer' } }, signature = 'matcharg({nr})', }, + matchbufline = { + args = { 4, 5 }, + base = 1, + desc = [=[ + Returns the |List| of matches in lines from {lnum} to {end} in + buffer {buf} where {pat} matches. + + {lnum} and {end} can either be a line number or the string "$" + to refer to the last line in {buf}. + + The {dict} argument supports following items: + submatches include submatch information (|/\(|) + + For each match, a |Dict| with the following items is returned: + byteidx starting byte index of the match + lnum line number where there is a match + text matched string + Note that there can be multiple matches in a single line. + + This function works only for loaded buffers. First call + |bufload()| if needed. + + When {buf} is not a valid buffer, the buffer is not loaded or + {lnum} or {end} is not valid then an error is given and an + empty |List| is returned. + + Examples: >vim + " Assuming line 3 in buffer 5 contains "a" + :echo matchbufline(5, '\<\k\+\>', 3, 3) + [{'lnum': 3, 'byteidx': 0, 'text': 'a'}] + " 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'}] + < + 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 + \ {'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'}] + < + 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\)\?\(.*\)', + \ #{submatches: v:true}) + [{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}] + Date: Tue, 16 Jan 2024 11:30:35 +0800 Subject: vim-patch:partial:9.1.0027: Vim is missing a foreach() func (#27037) Problem: Vim is missing a foreach() func Solution: Implement foreach({expr1}, {expr2}) function, which applies {expr2} for each item in {expr1} without changing it (Ernie Rael) closes: vim/vim#12166 https://github.com/vim/vim/commit/e79e2077607e8f829ba823308c91104a795736ba Partial port as this doesn't handle non-materialized range() lists. vim-patch:c92b8bed1fa6 runtime(help): delete duplicate help tag E741 (vim/vim#13861) https://github.com/vim/vim/commit/c92b8bed1fa632569c8358feb3b72dd6a0844ef7 Co-authored-by: Ernie Rael --- src/nvim/eval.lua | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 9545cb9823..9a66d20dbb 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -2923,6 +2923,48 @@ M.funcs = { returns = 'string', signature = 'foldtextresult({lnum})', }, + foreach = { + args = 2, + base = 1, + desc = [=[ + {expr1} must be a |List|, |String|, |Blob| or |Dictionary|. + For each item in {expr1} execute {expr2}. {expr1} is not + modified; its values may be, as with |:lockvar| 1. |E741| + See |map()| and |filter()| to modify {expr1}. + + {expr2} must be a |string| or |Funcref|. + + If {expr2} is a |string|, inside {expr2} |v:val| has the value + of the current item. For a |Dictionary| |v:key| has the key + of the current item and for a |List| |v:key| has the index of + the current item. For a |Blob| |v:key| has the index of the + current byte. For a |String| |v:key| has the index of the + current character. + Examples: > + call foreach(mylist, 'let used[v:val] = v:true') + Date: Tue, 16 Jan 2024 12:07:35 +0800 Subject: docs(builtin): remove signatures of undocumented functions (#27039) Having an empty signature causes an empty line in generated docs, so remove it. Also change ">" to ">vim" in foreach() docs. --- src/nvim/eval.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 9a66d20dbb..a820f11a5e 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -2940,7 +2940,7 @@ M.funcs = { the current item. For a |Blob| |v:key| has the index of the current byte. For a |String| |v:key| has the index of the current character. - Examples: > + Examples: >vim call foreach(mylist, 'let used[v:val] = v:true') Date: Mon, 22 Jan 2024 16:04:50 +0800 Subject: fix(eval): properly support checking v:lua function in exists() (#27124) --- 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 a820f11a5e..37fded85cd 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -2202,6 +2202,7 @@ M.funcs = { echo exists("*strftime") echo exists("*s:MyFunc") echo exists("*MyFunc") + echo exists("*v:lua.Func") echo exists("bufcount") echo exists(":Make") echo exists("#CursorHold") -- cgit From 76a659eb773ca69d8b6a8f08e1a5c538dc03b8fd Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Thu, 25 Jan 2024 00:34:18 +0100 Subject: docs: various fixes (#27063) Co-authored-by: lmenou Co-authored-by: altermo <107814000+altermo@users.noreply.github.com> Co-authored-by: VanaIgr Co-authored-by: Gregory Anders --- 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 37fded85cd..22c208426c 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -11550,7 +11550,7 @@ M.funcs = { ]=], name = 'synconcealed', params = { { 'lnum', 'integer' }, { 'col', 'integer' } }, - returns = '{[1]: integer, [2]: string, [3]: integer}[]', + returns = '{[1]: integer, [2]: string, [3]: integer}', signature = 'synconcealed({lnum}, {col})', }, synstack = { -- cgit From 226466a46941cd6b693f56b6eb7f4293d4066c8d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 26 Jan 2024 11:04:54 +0800 Subject: vim-patch:9.1.0058: Cannot map Super Keys in GTK UI (#27204) Problem: Cannot map Super Keys in GTK UI (Casey Tucker) Solution: Enable Super Key mappings in GTK using (Casey Tucker) As a developer who works in both Mac and Linux using the same keyboard, it can be frustrating having to remember different key combinations or having to rely on system utilities to remap keys. This change allows `` `` `` `` etc. to be recognized by the `map` commands, along with the `` shifted variants. ```vimrc if has('gui_gtk') nnoremap u nnoremap vnoremap "+d vnoremap "+y cnoremap + inoremap "+gP nnoremap "+P vnoremap "-d"+P nnoremap :w inoremap :w nnoremap :q nnoremap :qa nnoremap :tabe nnoremap :vs#T nnoremap ggVG vnoremap ggVG inoremap ggVG nnoremap / nnoremap n nnoremap N vnoremap "+x endif ``` closes: vim/vim#12698 https://github.com/vim/vim/commit/92e90a1e102825aa9149262cacfc991264db05df Co-authored-by: Casey Tucker --- 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 22c208426c..9f50fd1758 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -3461,7 +3461,7 @@ M.funcs = { 32 mouse double click 64 mouse triple click 96 mouse quadruple click (== 32 + 64) - 128 command (Macintosh only) + 128 command (Mac) or super Only the modifiers that have not been included in the character itself are obtained. Thus Shift-a results in "A" without a modifier. Returns 0 if no modifiers are used. -- cgit From d85f180f26c0570c2510c899a0bf0023ec55a692 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Tue, 15 Aug 2023 19:38:52 +0100 Subject: vim-patch:9.1.0049: Make "[Command Line]" a special buffer name Problem: E95 is possible if a buffer called "[Command Line]" already exists when opening the cmdwin. This can also happen if the cmdwin's buffer could not be deleted when closing. Solution: Un-name the cmdwin buffer, and give it a special name instead, similar to what's done for quickfix buffers and for unnamed prompt and scratch buffers. As a result, BufFilePre/Post are no longer fired when opening the cmdwin. Add a "command" key to the dictionary returned by getbufinfo() to differentiate the cmdwin buffer instead. (Sean Dewar) Cherry-pick test_normal changes from v9.0.0954. https://github.com/vim/vim/commit/1fb41032060df09ca2640dc49541f11062f6dfaa --- 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 9f50fd1758..bc976eaa58 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -3219,6 +3219,8 @@ M.funcs = { bufnr Buffer number. changed TRUE if the buffer is modified. changedtick Number of changes made to the buffer. + command TRUE if the buffer belongs to the + command-line window |cmdwin|. hidden TRUE if the buffer is hidden. lastused Timestamp in seconds, like |localtime()|, when the buffer was -- cgit From 1c7b0b9d5f874fe962a8e63d9e8db7e576ab0d48 Mon Sep 17 00:00:00 2001 From: Maria José Solano Date: Mon, 12 Feb 2024 20:15:27 -0800 Subject: docs: stricter bufname and bufnr types (#27454) --- 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 bc976eaa58..2630241077 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -809,7 +809,7 @@ M.funcs = { < ]=], name = 'bufname', - params = { { 'buf', 'any' } }, + params = { { 'buf', 'integer|string' } }, returns = 'string', signature = 'bufname([{buf}])', }, @@ -832,7 +832,7 @@ M.funcs = { ]=], name = 'bufnr', - params = { { 'buf', 'any' }, { 'create', 'any' } }, + params = { { 'buf', 'integer|string' }, { 'create', 'any' } }, returns = 'integer', signature = 'bufnr([{buf} [, {create}]])', }, -- cgit From 20e4001eeedc80b1f2857fcaca81f7a211a09b40 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 22 Feb 2024 20:32:52 +0800 Subject: vim-patch:9.1.0120: hard to get visual region using Vim script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: hard to get visual region using Vim script Solution: Add getregion() Vim script function (Shougo Matsushita, Jakub Łuczyński) closes: vim/vim#13998 closes: vim/vim#11579 https://github.com/vim/vim/commit/3f905ab3c4f66562f4a224bf00f49d98a0b0da91 Cherry-pick changes from patch 9.1.0122, with :echom instead of :echow. Co-authored-by: Shougo Matsushita Co-authored-by: Jakub Łuczyński --- src/nvim/eval.lua | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 2630241077..231dd1f9bf 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -4355,6 +4355,49 @@ M.funcs = { returns = 'table', signature = 'getreginfo([{regname}])', }, + getregion = { + args = 3, + base = 1, + desc = [=[ + Returns the list of strings from {pos1} to {pos2} as if it's + selected in visual mode of {type}. + For possible values of {pos1} and {pos2} see |line()|. + {type} is the selection type: + "v" for |charwise| mode + "V" for |linewise| mode + "" for |blockwise-visual| mode + You can get the last selection type by |visualmode()|. + If Visual mode is active, use |mode()| to get the Visual mode + (e.g., in a |:vmap|). + This function uses the line and column number from the + specified position. + It is useful to get text starting and ending in different + columns, such as |charwise-visual| selection. + + Note that: + - Order of {pos1} and {pos2} doesn't matter, it will always + return content from the upper left position to the lower + right position. + - If 'virtualedit' is enabled and selection is past the end of + line, resulting lines are filled with blanks. + - If the selection starts or ends in the middle of a multibyte + character, it is not included but its selected part is + substituted with spaces. + - If {pos1} or {pos2} equals "v" (see |line()|) and it is not in + |visual-mode|, an empty list is returned. + - If {pos1}, {pos2} or {type} is an invalid string, an empty + list is returned. + + Examples: > + :xnoremap + \ echom getregion('v', '.', mode()) + < + ]=], + name = 'getregion', + params = { { 'pos1', 'string' }, { 'pos2', 'string' }, { 'type', 'string' } }, + returns = 'string[]', + signature = 'getregion({pos1}, {pos2}, {type})', + }, getregtype = { args = { 0, 1 }, base = 1, -- cgit From 06df895e71720b65f98b6b9c579ca5918a12bc04 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 23 Feb 2024 06:35:40 +0800 Subject: vim-patch:9.1.0126: Internal error when using upper-case mark in getregion() Problem: Internal error when passing mark in another buffer to getregion(). Solution: Don't allow marks in another buffer (zeertzjq) closes: vim/vim#14076 Internal error when passing mark in another buffer to getregion() https://github.com/vim/vim/commit/421b597470c118871c7081de00dd065e0e000b7e --- 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 231dd1f9bf..9cca9c588a 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -4387,6 +4387,8 @@ M.funcs = { |visual-mode|, an empty list is returned. - If {pos1}, {pos2} or {type} is an invalid string, an empty list is returned. + - If {pos1} or {pos2} is a mark in different buffer, an empty + list is returned. Examples: > :xnoremap -- cgit From 9418381ccca5bf749b2f10b8a31d6e0900898ffa Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 24 Feb 2024 17:55:32 +0800 Subject: vim-patch:a35235e824bb (#27598) runtime(doc) Update help text for matchbufline() and matchstrlist() closes: vim/vim#14080 https://github.com/vim/vim/commit/a35235e824bb77df0cebdb2bd290e13f1201b292 Co-authored-by: Yegappan Lakshmanan --- src/nvim/eval.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 9cca9c588a..87850422b2 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -6546,6 +6546,7 @@ M.funcs = { Note that when {count} is added the way {start} works changes, see above. + *match-pattern* See |pattern| for the patterns that are accepted. The 'ignorecase' option is used to set the ignore-caseness of the pattern. 'smartcase' is NOT used. The matching is always @@ -6726,6 +6727,9 @@ M.funcs = { This function works only for loaded buffers. First call |bufload()| if needed. + See |match-pattern| for information about the effect of some + option settings on the pattern. + When {buf} is not a valid buffer, the buffer is not loaded or {lnum} or {end} is not valid then an error is given and an empty |List| is returned. @@ -6960,6 +6964,9 @@ M.funcs = { submatches a List of submatches. Present only if "submatches" is set to v:true in {dict}. + See |match-pattern| for information about the effect of some + option settings on the pattern. + Example: >vim :echo matchstrlist(['tik tok'], '\<\k\+\>') [{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}] -- cgit From 7ad2e3c64562bfb0ea2f7be305e4b0e6d2474d64 Mon Sep 17 00:00:00 2001 From: Maria José Solano Date: Tue, 27 Feb 2024 03:53:49 -0800 Subject: docs: fix type of setreg() argument {options} (#27631) --- 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 87850422b2..e03ee77141 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -9756,7 +9756,7 @@ M.funcs = { ]=], name = 'setreg', - params = { { 'regname', 'string' }, { 'value', 'any' }, { 'options', 'table' } }, + params = { { 'regname', 'string' }, { 'value', 'any' }, { 'options', 'string' } }, signature = 'setreg({regname}, {value} [, {options}])', }, settabvar = { -- cgit From ce7c51a1a3b2b38cdba730aeb53840d0ace32173 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 29 Feb 2024 07:19:26 +0800 Subject: vim-patch:9.1.0142: getregion() can be improved (#27662) Problem: getregion() can be improved (after v9.1.120) Solution: change getregion() implementation to use pos as lists and one optional {opt} dictionary (Shougo Matsushita) Note: The following is a breaking change! Currently, the getregion() function (included as of patch v9.1.120) takes 3 arguments: the first 2 arguments are strings, describing a position, arg3 is the type string. However, that is slightly inflexible, there is no way to specify additional arguments. So let's instead change the function signature to: getregion(pos1, pos2 [, {Dict}]) where both pos1 and pos2 are lists. This is slightly cleaner, and gives us the flexibility to specify additional arguments as key/value pairs to the optional Dict arg. Now it supports the "type" key to specify the selection type (characterwise, blockwise or linewise) and now in addition one can also define the selection type, independently of what the 'selection' option actually is. Technically, this is a breaking change, but since the getregion() Vimscript function is still quite new, this should be fine. closes: vim/vim#14090 https://github.com/vim/vim/commit/19b718828d8d5fab52d94c6cdba694641879ab38 Co-authored-by: Shougo Matsushita --- src/nvim/eval.lua | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index e03ee77141..8dc282cd43 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -4356,16 +4356,27 @@ M.funcs = { signature = 'getreginfo([{regname}])', }, getregion = { - args = 3, + args = { 2, 3 }, base = 1, desc = [=[ - Returns the list of strings from {pos1} to {pos2} as if it's - selected in visual mode of {type}. - For possible values of {pos1} and {pos2} see |line()|. - {type} is the selection type: - "v" for |charwise| mode - "V" for |linewise| mode - "" for |blockwise-visual| mode + Returns the list of strings from {pos1} to {pos2} in current + buffer. + + {pos1} and {pos2} must both be |List|s with four numbers. + See |getpos()| for the format of the list. + + The optional argument {opts} is a Dict and supports the + following items: + + type Specify the selection type + (default: "v"): + "v" for |charwise| mode + "V" for |linewise| mode + "" for |blockwise-visual| mode + + exclusive If |TRUE|, use exclusive selection + for the end position 'selection'. + You can get the last selection type by |visualmode()|. If Visual mode is active, use |mode()| to get the Visual mode (e.g., in a |:vmap|). @@ -4383,22 +4394,19 @@ M.funcs = { - If the selection starts or ends in the middle of a multibyte character, it is not included but its selected part is substituted with spaces. - - If {pos1} or {pos2} equals "v" (see |line()|) and it is not in - |visual-mode|, an empty list is returned. - - If {pos1}, {pos2} or {type} is an invalid string, an empty - list is returned. - - If {pos1} or {pos2} is a mark in different buffer, an empty + - If {pos1} or {pos2} is not current in the buffer, an empty list is returned. Examples: > :xnoremap - \ echom getregion('v', '.', mode()) + \ echom getregion( + \ getpos('v'), getpos('.'), #{ type: mode() }) < ]=], name = 'getregion', - params = { { 'pos1', 'string' }, { 'pos2', 'string' }, { 'type', 'string' } }, + params = { { 'pos1', 'table' }, { 'pos2', 'table' }, { 'opts', 'table' } }, returns = 'string[]', - signature = 'getregion({pos1}, {pos2}, {type})', + signature = 'getregion({pos1}, {pos2} [, {opts}])', }, getregtype = { args = { 0, 1 }, -- cgit From 6ab0876f51e8ff5debdff03b36508fe7279032b7 Mon Sep 17 00:00:00 2001 From: glepnir Date: Thu, 29 Feb 2024 19:39:11 +0800 Subject: docs(eval): getline and indent function support string type Problem: getline and indent function missing string type in param. Solution: add string type in eval gen. --- 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 8dc282cd43..3f7294bcba 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -3973,7 +3973,7 @@ M.funcs = { |getbufoneline()| ]=], name = 'getline', - params = { { 'lnum', 'integer' }, { 'end', 'nil|false' } }, + params = { { 'lnum', 'integer|string' }, { 'end', 'nil|false' } }, signature = 'getline({lnum} [, {end}])', returns = 'string', }, @@ -5220,7 +5220,7 @@ M.funcs = { ]=], name = 'indent', - params = { { 'lnum', 'integer' } }, + params = { { 'lnum', 'integer|string' } }, returns = 'integer', signature = 'indent({lnum})', }, -- cgit From 1fe65b3457d2e0632831445899d6d8a4bff9daee Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 2 Mar 2024 06:42:39 +0800 Subject: vim-patch:87410ab3f556 (#27696) runtime(doc): some improvements to getregion() docs (vim/vim#14122) - Mention the default selection behavior - Remove useless sentence - Correct description about space padding https://github.com/vim/vim/commit/87410ab3f556121dfb3b30515f40c5f079edd004 --- src/nvim/eval.lua | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 3f7294bcba..2984ce29c6 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -4368,32 +4368,31 @@ M.funcs = { The optional argument {opts} is a Dict and supports the following items: - type Specify the selection type + type Specify the region's selection type (default: "v"): "v" for |charwise| mode "V" for |linewise| mode "" for |blockwise-visual| mode exclusive If |TRUE|, use exclusive selection - for the end position 'selection'. + for the end position + (default: follow 'selection') You can get the last selection type by |visualmode()|. If Visual mode is active, use |mode()| to get the Visual mode (e.g., in a |:vmap|). - This function uses the line and column number from the - specified position. - It is useful to get text starting and ending in different - columns, such as |charwise-visual| selection. + This function is useful to get text starting and ending in + different columns, such as a |charwise-visual| selection. Note that: - Order of {pos1} and {pos2} doesn't matter, it will always return content from the upper left position to the lower right position. - - If 'virtualedit' is enabled and selection is past the end of - line, resulting lines are filled with blanks. - - If the selection starts or ends in the middle of a multibyte - character, it is not included but its selected part is - substituted with spaces. + - If 'virtualedit' is enabled and the region is past the end + of the lines, resulting lines are padded with spaces. + - If the region is blockwise and it starts or ends in the + middle of a multi-cell character, it is not included but + its selected part is substituted with spaces. - If {pos1} or {pos2} is not current in the buffer, an empty list is returned. -- cgit From 6525832a8c4d44a8ebabba02a5ea1ce09b389a4f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 7 Mar 2024 06:43:08 +0800 Subject: vim-patch:9.1.0155: can only get getregion() from current buffer (#27757) Problem: can only call getregion() for current buffer Solution: Allow to retrieve selections from different buffers (Shougo Matsushita) closes: vim/vim#14131 https://github.com/vim/vim/commit/84bf6e658da51126bdd2e50af1f40cabd149343f Co-authored-by: Shougo Matsushita --- 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 2984ce29c6..94c9af50d4 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -4359,11 +4359,13 @@ M.funcs = { args = { 2, 3 }, base = 1, desc = [=[ - Returns the list of strings from {pos1} to {pos2} in current + Returns the list of strings from {pos1} to {pos2} from a buffer. {pos1} and {pos2} must both be |List|s with four numbers. - See |getpos()| for the format of the list. + See |getpos()| for the format of the list. It's possible + to specify positions from a different buffer, but please + note the limitations at |getregion-notes| The optional argument {opts} is a Dict and supports the following items: @@ -4384,6 +4386,7 @@ M.funcs = { This function is useful to get text starting and ending in different columns, such as a |charwise-visual| selection. + *getregion-notes* Note that: - Order of {pos1} and {pos2} doesn't matter, it will always return content from the upper left position to the lower @@ -4393,8 +4396,12 @@ M.funcs = { - If the region is blockwise and it starts or ends in the middle of a multi-cell character, it is not included but its selected part is substituted with spaces. - - If {pos1} or {pos2} is not current in the buffer, an empty + - If {pos1} and {pos2} are not in the same buffer, an empty list is returned. + - {pos1} and {pos2} must belong to a |bufloaded()| buffer. + - It is evaluated in current window context, this makes a + different if a buffer is displayed in a different window and + 'virtualedit' or 'list' is set Examples: > :xnoremap -- cgit From 5f3579e6ea12659d48e92b2126f83777908c28fc Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 8 Mar 2024 06:44:57 +0800 Subject: vim-patch:9.1.0157: Duplicate assignment in f_getregion() (#27766) Problem: Duplicate assignment in f_getregion(). Solution: Remove the duplicate assignment. Also improve getregion() docs wording and fix an unrelated typo (zeertzjq) closes: vim/vim#14154 https://github.com/vim/vim/commit/0df8f93bdaea77a1afb9f4eca94fe67ec73e6df2 --- src/nvim/eval.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 94c9af50d4..b7120d5dd5 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -4365,7 +4365,7 @@ M.funcs = { {pos1} and {pos2} must both be |List|s with four numbers. See |getpos()| for the format of the list. It's possible to specify positions from a different buffer, but please - note the limitations at |getregion-notes| + note the limitations at |getregion-notes|. The optional argument {opts} is a Dict and supports the following items: @@ -4399,9 +4399,9 @@ M.funcs = { - If {pos1} and {pos2} are not in the same buffer, an empty list is returned. - {pos1} and {pos2} must belong to a |bufloaded()| buffer. - - It is evaluated in current window context, this makes a - different if a buffer is displayed in a different window and - 'virtualedit' or 'list' is set + - It is evaluated in current window context, which makes a + difference if the buffer is displayed in a window with + different 'virtualedit' or 'list' values. Examples: > :xnoremap -- cgit