Commit Graph

25575 Commits

Author SHA1 Message Date
Gregory Anders
9489406879 fix(iter): remove special case totable for map-like tables
This was originally meant as a convenience but prevents possible
functionality. For example:

  -- Get the keys of the table with even values
  local t = { a = 1, b = 2, c = 3, d = 4 }
  vim.iter(t):map(function(k, v)
    if v % 2 == 0 then return k end
  end):totable()

The example above would not work, because the map() function returns
only a single value, and cannot be converted back into a table (there
are many such examples like this).

Instead, to convert an iterator into a map-like table, users can use
fold():

  vim.iter(t):fold({}, function(t, k, v)
    t[k] = v
    return t
  end)
2023-04-19 07:52:04 -06:00
Gregory Anders
6b96122453 fix(iter): add tag to packed table
If pack() is called with a single value, it does not create a table; it
simply returns the value it is passed. When unpack is called with a
table argument, it interprets that table as a list of values that were
packed together into a table.

This causes a problem when the single value being packed is _itself_ a
table. pack() will not place it into another table, but unpack() sees
the table argument and tries to unpack it.

To fix this, we add a simple "tag" to packed table values so that
unpack() only attempts to unpack tables that have this tag. Other tables
are left alone. The tag is simply the length of the table.
2023-04-19 07:04:49 -06:00
dundargoc
0a3645a723
build: find system luv on ubuntu
Also use the system luv in CI for the with-external-deps job.
2023-04-19 00:47:15 +02:00
luukvbaal
59fed8bb64
fix(api): extmark highlight groups not always included in details (#23179)
Problem:    Erroneous for loop condition.
Solution:   Remove for loop condition.
2023-04-18 21:07:37 +08:00
Sean Dewar
9033d5eccc
Merge pull request #23005 from seandewar/fix-ruf-cmdline-pos
fix(ruler): fix some ruler issues with no statusline
2023-04-18 10:01:42 +01:00
zeertzjq
d4eff4052a
Merge pull request #23173 from zeertzjq/vim-9.0.0783
vim-patch:9.0.{0783,0785,0815,0817,0820,0864}
2023-04-18 15:04:47 +08:00
zeertzjq
2e21d1d5dd vim-patch:6ebe4f970b8b
Update runtime files

6ebe4f970b

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-18 14:37:17 +08:00
zeertzjq
9180c18c46 vim-patch:9.0.0864: crash when using "!!" without a previous shell command
Problem:    Crash when using "!!" without a previous shell command.
Solution:   Check "prevcmd" is not NULL. (closes vim/vim#11487)

6600447c7b

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-18 14:35:04 +08:00
zeertzjq
2a94dcf0c5 vim-patch:9.0.0820: memory leak with empty shell command
Problem:    Memory leak with empty shell command.
Solution:   Free the empty string.

03d6e6f42b

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-18 14:31:00 +08:00
zeertzjq
a1e0f6c07f vim-patch:9.0.0817
fb0cf2357e

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-18 14:30:01 +08:00
zeertzjq
187ba3efce vim-patch:9.0.0815
9c50eeb401

Co-authored-by: Martin Tournoij <martin@arp242.net>
2023-04-18 14:29:07 +08:00
zeertzjq
5b77dde8dd vim-patch:9.0.0785: memory leak with empty shell command
Problem:    Memory leak with empty shell command.
Solution:   Free the allocated memory when bailing out.

9652249a2d

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-18 14:22:59 +08:00
zeertzjq
c0f10d3fe0 vim-patch:9.0.0783: ":!" doesn't do anything but does update the previous command
Problem:    ":!" doesn't do anything but does update the previous command.
Solution:   Do not have ":!" change the previous command. (Martin Tournoij,
            closes vim/vim#11372)

8107a2a8af

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-18 14:20:44 +08:00
zeertzjq
240c41e1af
fix(genvimvim): add special abbreviations of :delete (#23172)
Also don't highlight :def as vimCommand.
2023-04-18 09:40:05 +08:00
luukvbaal
84a4319545
fix(mouse): cmdline click registered as statuscolumn (#23163) 2023-04-18 08:00:49 +08:00
Gregory Anders
ab1edecfb7
feat(lua): add vim.iter (#23029)
vim.iter wraps a table or iterator function into an `Iter` object with
methods such as `filter`, `map`, and `fold` which can be chained to
produce iterator pipelines that do not create new tables at each step.
2023-04-17 12:54:19 -06:00
Sean Dewar
65dd3c1180
fix(ruler): show ruler of curwin with no statusline in cmdline
Problem: After neovim/neovim@846a056, only the ruler for current floating or
last window without a statusline is drawn in the cmdline. This means that if the
current window is not one of these, but has no statusline, its ruler will not be
drawn anymore.

Solution: Make `showmode()` draw the ruler of the current window or the last
window in the cmdline if it has no statusline. This also maintains the
previously restored floating window case (`float->w_status_height` should be 0).

This behaviour should again match Vim, but without the overdraw it seems to do
to achieve the same effect; it calls `showmode()` to draw the ruler for the last
window without a statusline, then may draw over it in `showruler()` (which is
now `show_cursor_info_later()` in Nvim) to show the ruler for the current
window..? It's very confusing.

Also update the logic in `win_redr_ruler()` to mirror the check done in
`showmode()`, so that the ruler doesn't potentially draw over the long
ins-completion mode message in some cases.
2023-04-17 18:40:12 +01:00
Sean Dewar
7095f8ff9d
vim-patch:9.0.1461: ruler not drawn correctly when using 'rulerformat'
Problem:    Ruler not drawn correctly when using 'rulerformat'.
Solution:   Adjust formatting depending on whether the ruler is drawn in the
            statusline or the command line. (Sean Dewar, closes vim/vim#12246)

fc8a601c32

This issue was made apparent after neovim/neovim@0f1e2b6, as `showmode()` calls
`win_redr_ruler()` with `curwin` now if it's floating, rather than the last
window if there's no statusline (which usually already shares its right side
with that of the editor).

Co-authored-by: Sean Dewar <seandewar@users.noreply.github.com>
2023-04-17 18:38:31 +01:00
Jon Huhn
6cc76011ca
fix(watchfiles): skip Created events when poll starts (#23139) 2023-04-17 18:50:05 +02:00
zeertzjq
9e5f9c25d9
vim-patch:9.0.1460: insufficient testing for getcmdcompltype() (#23159)
Problem:    Insufficient testing for getcmdcompltype().
Solution:   Add a few more test cases. (closes vim/vim#12268)

961b2e54bd
2023-04-17 23:27:04 +08:00
Isak Samsten
07b60efd80
feat(diagnostic): specify diagnostic virtual text prefix as a function
- vim.diagnostic.config() now accepts a function for the virtual_text.prefix
  option, which allows for rendering e.g., diagnostic severities differently.
2023-04-17 12:53:34 +01:00
zeertzjq
e83682e652
refactor: suppress clang false positives (#23154) 2023-04-17 19:22:55 +08:00
zeertzjq
b98d195c55
ci(labeler): add back GitHub token for type-scope
It is required by `gh pr edit`.
2023-04-17 19:11:29 +08:00
zeertzjq
75d9c413d4
fix(excmd): make :def unknown rather than unimplemented (#23150) 2023-04-17 17:44:08 +08:00
Christian Clason
a30e61eb4d
build(deps): bump tree-sitter to HEAD - af92bfc02 (#23151) 2023-04-17 11:39:57 +02:00
zeertzjq
53985a6d31
Merge pull request #23148 from zeertzjq/vim-8.2.4179
vim-patch:8.2.{4179,4180,4181,4182,4183,4184,4185,4186,4193,4197}
2023-04-17 16:10:21 +08:00
zeertzjq
79a6933768 vim-patch:partial:6f4754b9f725
Update runtime files

6f4754b9f7

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-17 15:46:24 +08:00
zeertzjq
481c6e6cac vim-patch:8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Problem:    Cannot use an import in the "expr" part of 'spellsuggest'.
Solution:   Set the script context when evaluating "expr" of 'spellsuggest'.

2a7aa83458

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-17 15:46:24 +08:00
zeertzjq
f560c97059 vim-patch:8.2.4193: cannot use an import in 'charconvert'
Problem:    Cannot use an import in 'charconvert'.
Solution:   Set the script context when evaluating 'charconvert'.  Also expand
            script-local functions in 'charconvert'.

f4e88f2152

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-17 15:46:24 +08:00
zeertzjq
cec42e07bc vim-patch:8.2.4186: cannot use an import in 'patchexpr'
Problem:    Cannot use an import in 'patchexpr'.
Solution:   Set the script context when evaluating 'patchexpr'.  Do not
            require 'patchexpr' to return a bool, it was ignored anyway.

36c2add7f8

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-17 15:46:24 +08:00
zeertzjq
5d3ad6fd90 vim-patch:8.2.4185: cannot use an import in 'indentexpr'
Problem:    Cannot use an import in 'indentexpr'.
Solution:   Set the script context when evaluating 'indentexpr'

28e60cc088

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-17 15:46:24 +08:00
zeertzjq
96451e7f60 vim-patch:8.2.4184: cannot use an import in 'includeexpr'
Problem:    Cannot use an import in 'includeexpr'.
Solution:   Set the script context when evaluating 'includeexpr'

47bcc5f4c8

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-17 15:46:24 +08:00
zeertzjq
36f1e9824a vim-patch:8.2.4183: cannot use an import in 'formatexpr'
Problem:    Cannot use an import in 'formatexpr'.
Solution:   Set the script context when evaluating 'formatexpr'.

3ba685eeef

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-17 15:46:24 +08:00
zeertzjq
9cf59acfaa vim-patch:8.2.4182: memory leak when evaluating 'diffexpr'
Problem:    Memory leak when evaluating 'diffexpr'.
Solution:   Use free_tv() instead of clear_tv().

39b8944539

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-17 15:46:24 +08:00
zeertzjq
ba57566601 vim-patch:8.2.4181: Vim9: cannot use an import in 'diffexpr'
Problem:    Vim9: cannot use an import in 'diffexpr'.
Solution:   Set the script context when evaluating 'diffexpr'.  Do not require
            'diffexpr' to return a bool, it was ignored anyway.

7b29f6a394

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-17 15:46:24 +08:00
zeertzjq
0c99ae7a88 vim-patch:8.2.4180: 'balloonexpr' is evaluated in the current script context
Problem:    'balloonexpr' is evaluated in the current script context.
Solution:   Use the script context where the option was set.

5600a709f4

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-17 15:46:24 +08:00
zeertzjq
d6e0f3dad2 vim-patch:8.2.4179: 'foldtext' is evaluated in the current script context
Problem:    'foldtext' is evaluated in the current script context.
Solution:   Use the script context where the option was set.

9530b580a7

Script version is N/A.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-17 15:46:24 +08:00
Christian Clason
0dbb0419f4
build(deps): bump LuaJIT to HEAD - 1c2791270 (#23140) 2023-04-17 09:08:43 +02:00
zeertzjq
9722b3b9f9
vim-patch:9.0.1400: find_file_in_path() is not reentrant (#23146)
Problem:    find_file_in_path() is not reentrant.
Solution:   Instead of global variables pass pointers to the functions.
            (closes vim/vim#12093)

5145c9a829

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-17 14:38:53 +08:00
zeertzjq
85bc9e8970
Merge pull request #23144 from zeertzjq/vim-9.0.0419
vim-patch:9.0.{0406,0419}: the :defer command does not check the function arguments
2023-04-17 10:09:18 +08:00
zeertzjq
7a3f86481e vim-patch:9.0.0419: the :defer command does not check the function arguments
Problem:    The :defer command does not check the function argument count and
            types.
Solution:   Check the function arguments when adding a deferred function.

169003289f

Cherry-pick check_internal_func() from Vim, but use EvalFuncDef pointer
as first argument.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-17 09:38:09 +08:00
zeertzjq
6bfba3660c vim-patch:9.0.0406: deferred functions not invoked when partial func exits
Problem:    Deferred functions not invoked when partial func exits.
Solution:   Create a funccall_T when calling a :def function.

9667b2c888

The remove_funccal() function is currently unused, but it will be used
in patch 9.0.0618.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-17 09:08:08 +08:00
zeertzjq
78535664bd
vim-patch:8.2.2172: Vim9: number of arguments is not always checked (#23142)
Problem:    Vim9: number of arguments is not always checked. (Yegappan
            Lakshmanan)
Solution:   Check number of arguments when calling function by name.

5082471f91

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-17 09:07:30 +08:00
dundargoc
55d346fc26
ci: remove unnecessary token usage 2023-04-16 14:16:19 +02:00
zeertzjq
88c3d89001
vim-patch:9.0.1143: invalid memory access with bad 'statusline' value (#23133)
Problem:    Invalid memory access with bad 'statusline' value.
Solution:   Avoid going over the NUL at the end.

7b17eb4b06

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-16 19:21:06 +08:00
zeertzjq
227f06b7df
vim-patch:9.0.1145: invalid memory access with recursive substitute expression (#23132)
Problem:    Invalid memory access with recursive substitute expression.
Solution:   Check the return value of vim_regsub().

3ac1d97a1d

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-16 18:43:15 +08:00
JingMatrix
7f94a032e1
fix(checkhealth): shell_error and cpanm module
shell_error is a function, the code missed parentheses

The actual module for perl module version is App::cpanminus::script, not
App::cpanminus::fatscript.
2023-04-16 12:39:48 +02:00
zeertzjq
fd68cd1c0a
vim-patch:8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level (#23131)
Problem:    Vim9: exception in ISN_INSTR caught at wrong level.
Solution:   Set the starting trylevel in exec_instructions(). (closes vim/vim#8214)

ff65288aa8

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-16 18:27:33 +08:00
dundargoc
b0978fca6b
fix(checkhealth): fix crash due to incorrect argument type 2023-04-16 12:26:13 +02:00
Raphael
2f779b94e7
fix(lua): inspect_pos respect bufnr when get syntax info (#23098) 2023-04-16 17:50:32 +08:00