Commit Graph

32739 Commits

Author SHA1 Message Date
Francisco Giordano
c124594b22 fix(api): buffer overflow in nvim_buf_get_extmarks overlap #37184
With `overlap=true`, more extmarks than the requested limit may be
collected in `extmark_get`. This then leads to an out of bounds write of
`rv` in `nvim_buf_get_extmarks`.

(cherry picked from commit 612cd99a00)
2026-01-02 07:37:32 +00:00
zeertzjq
44eae48b75 vim-patch:9.1.0893: No test that undofile format does not regress (#37193)
Problem:  No test that undofile format does not regress
Solution: include a sample undofile to make sure we are always able to
          read it

This is so, that we don't unintentionally change the undofile format and
make sure we can load an undo file that has been created by an older
Vim.

closes: vim/vim#16127

14382c8bc9

Convert the undo file in samples/ using method from #13973.

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 94f7302e66)
2026-01-01 23:40:43 +00:00
Peter Cardenas
46f569a890 fix(treesitter): use metadata in :EditQuery captures #37116
Problem:
When the `#offset!` directive is used with `:EditQuery`, the query does not take the offset into consideration when creating the extmark to preview the capture.

Solution:
Use the capture metadata to modify the node range before creating the extmark.
2025-12-31 12:21:41 +01:00
zeertzjq
fda8d2c717 vim-patch:9.1.2028: [security]: Buffer-overflow with incomplete multi-byte chars (#37133)
Problem:  Buffer overflow in buf_write() when converting incomplete
          multi-byte characters (Kevin Goodsell)
Solution: Make the buffer slightly larger

closes: vim/vim#19007

f99de42a9f

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 444e1ffe3e)
2025-12-28 01:05:55 +00:00
zeertzjq
18f189a3f3 test(api/server_requests_spec): fix flaky test (again) (#37100)
(cherry picked from commit b7adf8081c)
2025-12-26 02:25:00 +00:00
Sean Dewar
648cf4e586 fix(autocmd): skip empty comma-separated patterns properly
Problem: empty comma-separated patterns in an aupat aren't skipped correctly.
Solution: skip consecutive commas in an aupat.

Also simplify the logic.

(cherry picked from commit 1cde71233f)
2025-12-26 02:21:20 +00:00
Sean Dewar
bea500dbeb fix(autocmd): parsing of comma-separated buflocal patterns
Problem: patterns after a buffer-local pattern in a comma-separated aupat are
         ignored.
Solution: ensure pat refers to the original buffer after each pattern, not the
          buflocal_pat buffer, and when printing make sure it's normalized for
          each pattern, not just the first.

Also simplify the logic when printing all autocommands for an event, and ensure
headings aren't repeated for each event when printing autocommands.

(cherry picked from commit 6d2330f50d)
2025-12-26 02:21:20 +00:00
phanium
bd2317f17f fix(lua): separate vim.{g,b,w,t} types #37081
Problem:
When `vim.g.foo = 1`, `vim.b.foo` also appears as
a completion candidate (when use emmylua_ls).

Solution:
Define separate types.

(cherry picked from commit 1aa26f5d55)
2025-12-23 16:08:39 +00:00
zeertzjq
fcdc984188 test(ui/inccommand_spec): don't check for transient message (#37078)
The check for v:errmsg is enough.

(cherry picked from commit c374d78095)
2025-12-23 01:01:42 +00:00
Sean Dewar
6338d2d54b fix(window): win_move_after UAF from naughty autocmds (#37065)
Problem: use-after-free in win_move_after if win_enter autocommands free win1/2.
Solution: set w_pos_changed before calling win_enter.

(cherry picked from commit d1189ea508, also adding
an import of "exec" in the test)
2025-12-22 09:38:38 +00:00
Jaehwang Jung
124c18261c fix(marks): wrong line('w$', win) with conceal_lines (#37047)
Background:
Suppose a window has concealed lines, and sets conceallevel>2,
concealcursor="". The concealed lines are displayed if the window is
curwin and the cursor is on the those lines.

Problem:
line('w$', win) switches curwin to win, and then does validate_botline
for curwin. It computes botline assuming the concealed lines displayed,
resulting in a smaller value than the actual botline that the user sees.

Solution:
Evaluate line('w$', win) without switching curwin.
Apply similar changes to other functions that switches curwin.

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
(cherry picked from commit 033f1123cd)
2025-12-22 09:29:41 +00:00
zeertzjq
d1cd79a4b6 vim-patch:64799a5: runtime(doc): clarify the behavior of CTRL-Z
fixes: vim/vim#18975

64799a5080

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 9b55f037d2)
2025-12-21 00:36:37 +00:00
zeertzjq
a93b5a7104 vim-patch:fe8c8b1: runtime(doc): fix outdated :function help
Since patch 7.4.264 a leading "g:" is skipped.

closes: vim/vim#18976

fe8c8b1e85
(cherry picked from commit 03aef8fd2a)
2025-12-21 00:36:37 +00:00
zeertzjq
275c769f01 fix(lua): don't remove first char of non-file stacktrace source (#37008) 2025-12-18 08:57:33 +08:00
Alejandro Exojo
df9452ea9e fix(man.lua): show_toc condition may cause infinite loop #36979
`lnum` gets set with `vim.fn.nextnonblank`, which returns 0 on failure,
and which is truthy on Lua.

(cherry picked from commit 46220afef8)
2025-12-15 23:05:19 +00:00
zeertzjq
6f84ea7c66 fix(buffer): switching buffer should respect jumpoptions+=view (#36969)
Also add missing change to buflist_findfmark() from #19224.

(cherry picked from commit 2700f6642a)
2025-12-15 07:40:48 +00:00
Shmerl
45cda1bcf4 fix(vim.loader): randomized AppImage path pollutes luac cache #36944
different approach to 78bbe53f76

(cherry picked from commit 1363ef7d50)
2025-12-14 23:02:44 +00:00
zeertzjq
69321879fe Merge pull request #36922 from zeertzjq/backport
Backport to release-0.11
2025-12-12 09:38:06 +08:00
zeertzjq
a66fce6fab vim-patch:98a0cbf: patch 9.1.1971: crash with invalid positional argument 0 in printf() (#36919)
Problem:  crash with invalid positional argument 0 in printf()
Solution: Reject positional arguments <= 0.

closes: vim/vim#18898

98a0cbf05b

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-12-12 08:49:19 +08:00
Justin M. Keyes
cfb586a77b docs(vimfn): fix vimdoc parser errors 2025-12-12 08:49:05 +08:00
zeertzjq
d1604e0f38 vim-patch:9.1.1969: Wrong cursor position after formatting with long 'formatprg' (#36918)
Problem:  Wrong cursor position after formatting with long 'formatprg'.
Solution: Don't show hit-enter prompt when there are stuffed characters.

Previously a stuffed character at the hit-enter prompt will dismiss the
prompt immediately and be put in the typeahead buffer, which leads to
incorrect behavior as the typeahead buffer is processed after the stuff
buffers. Using vungetc() when KeyStuffed is TRUE can fix this problem,
but since the hit-enter prompt isn't visible anyway (and is likely not
desired here), just skip the prompt instead, which also avoids a wait
when using "wait" instead of "hit-enter" in 'messagesopt'.

fixes:  vim/vim#18905
closes: vim/vim#18906

50325c3d59
(cherry picked from commit 18642a63be)
2025-12-12 00:45:44 +00:00
Olivia Kinnear
808d973fb0 feat(lsp): warn about unknown filetype #36910
(cherry picked from commit 054eaf8493)
2025-12-11 19:17:39 +00:00
Shmerl
91fd4d127e fix(vim.loader): randomized AppImage path pollutes luac cache #35636
Problem:
When using the Nvim appimage, `~/.cache/nvim/luac` directory can grow to
250,000+ files.

Example of 2 identical files in `./luac/`:

    %2ftmp%2f.mount_nvim.a65Rja0%2fusr%2fshare%2fnvim%2fruntime%2flua%2fvim%2ftreesitter.luac
    %2ftmp%2f.mount_nvim.aNpxXgo%2fusr%2fshare%2fnvim%2fruntime%2flua%2fvim%2ftreesitter.luac

Analysis:
The `nvim.appimage` mounts nvim at a different temporary path each time
it is invoked. The naming scheme of these cache files is random, which
defats the purpose of the cache creates N new files on every launch of
nvim.

Steps to reproduce:
1. install `nvim.appimage`
2. `mv ~/.cache/nvim/luac ~/.cache/nvim/luac.backup`
3. `nvim`
4. Observe contents of `~/.cache/nvim/luac/`
5. Close nvim and run `nvim` again
6. Observe contents of `~/.cache/nvim/luac/` and see that new identical
   files have been added with a different mount prefix

Solution:
When running from an appimage, trim the random part of the filepaths.

(cherry picked from commit 78bbe53f76)
2025-12-10 19:01:47 +00:00
skewb1k
83c589d95f fix(lua): relax vim.wait() timeout validation (#36907)
fix(lua): relax `vim.wait()` timeout validation #36900

Problem:
After bc0635a9fc `vim.wait()` rejects floats
and NaN values.

Solution:
Restore the prior behavior, while still supporting `math.huge`. Update
tests to cover float case.

(cherry picked from commit b87bdef2a8)
2025-12-10 11:09:24 -05:00
ymich9963
ec9e337479 docs(options): shell-powershell #36881
Problem:
Current options for powershell and pwsh had mistakes and rationale
behind them was not clear.

Solution:
Update the suggested options by splitting up powershell and pwsh, as
well as ensuring that all options work and rationale is documented and
discussed.

(cherry picked from commit d2e445e1bd)
2025-12-10 07:01:39 +00:00
zeertzjq
bcc6e13851 Merge pull request #36893 from zeertzjq/backport
ci: stop using macos-13 runner (#35996)
2025-12-10 09:59:18 +08:00
zeertzjq
7e99466a89 fix(eval): 0 should mean current tabpage in gettabvar() (#36891)
This matches the gettabvar() behavior change in Vim 8.1.1218.

(cherry picked from commit df9e4a037a)
2025-12-10 01:42:58 +00:00
skewb1k
9acbf5102f fix(lua): vim.wait(math.huge) fails #36885
Problem:
`nlua_wait()` uses `luaL_checkinteger()` which doesn't support
`math.huge` since it's double type. On PUC Lua this fails with
'number has no integer representation' error and on LuaJIT this
overflows int.

Solution:
Use `luaL_checknumber()` and handle `math.huge`.

(cherry picked from commit bc0635a9fc)
2025-12-09 23:20:22 +00:00
zeertzjq
c1c0078138 ci(cirrus): update to FreeBSD 14.3 (#36813)
(cherry picked from commit 6456a7cd1e)
2025-12-06 14:35:42 +00:00
zeertzjq
0706c55ab1 vim-patch:partial:9.1.1955: sort() does not handle large numbers correctly (#36840)
Problem:  sort() does not handle large numbers correctly
          (Igbanam Ogbuluijah)
Solution: Don't truncate the return value of tv_get_number_chk()
          (Yegappan Lakshmanan)

closes: vim/vim#18868

04794efe12

Use a Lua test for now, as the Vimscript test uses tuples.

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
(cherry picked from commit 5370b7a2e0)
2025-12-06 14:30:09 +00:00
Anatolii Sakhnik
5ca2eb5e48 fix(remote): remote-ui connect timeout on slow networks #36800
Problem:
Connecting to a remote Neovim fails on slow network:

```
$ nvim --remote-ui --server 10.0.3.100:11111
Remote ui failed to start: connection refused
```

Strace reveals that the connection wasn't actually refused, but was still in progress:
```
15:52:50.678223 socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 11
15:52:50.678278 setsockopt(11, SOL_TCP, TCP_NODELAY, [1], 4) = 0
15:52:50.678320 connect(11, {sa_family=AF_INET, sin_port=htons(11111), sin_addr=inet_addr("10.0.3.100")}, 16) = -1 EINPROGRESS (Дія зараз виконується)
15:52:50.678443 clock_gettime(CLOCK_MONOTONIC, {tv_sec=21736, tv_nsec=57625406}) = 0
15:52:50.678489 io_uring_enter(4, 3, 3, IORING_ENTER_GETEVENTS, NULL, 0) = 3
15:52:50.678544 epoll_pwait(3, [], 1024, 50, NULL, 8) = 0
15:52:50.728911 clock_gettime(CLOCK_MONOTONIC, {tv_sec=21736, tv_nsec=108159596}) = 0
15:52:50.729203 epoll_ctl(3, EPOLL_CTL_DEL, 11, 0x7ffd6ec9a3bc) = 0
15:52:50.729527 close(11)               = 0
```

Solution:
Increase hardcoded timeout from 50ms to 500ms.

(cherry picked from commit a141fd2c4d)
2025-12-02 16:59:27 +00:00
Christian Clason
b3eab00e55 vim-patch:229f79c: runtime(yaml): fix wrong order of undo_ftplugin suboptions
This commit fixes the following error message:
```
Compiler not supported: make inc< sw< sts<
```

1. orginal value: `setl com< cms< et< fo<| compiler make inc< sw< sts<`
2. correct value: `setl com< cms< et< fo< inc< sw< sts< | compiler make`

While at it, let's also document the g:yaml_recommended_style variable.

closes: vim/vim#17179

229f79c168

Co-authored-by: Vincent Law <vlaw@users.noreply.github.com>
Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 8d68dbf906)
2025-12-02 08:01:25 +00:00
Christian Clason
0978d83c6e vim-patch:7bc9880: runtime(make): do not automatically indent after a special target
prevent indentation if the previous line starts with e.g. `.PHONY:`

closes: vim/vim#17183

7bc988067e

Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
(cherry picked from commit 2ea14c0cf4)
2025-12-02 08:01:25 +00:00
Elias Assaf
43f5297fe3 fix(clipboard): tmux clipboard data may be stale #36787
Problem:
When Nvim wants to paste from tmux, it doesn't tell tmux to read the OS
clipboard first, so it may have stale clipboard state.

Solution:
Tickle `tmux refresh-client -l`, before requesting paste, as recommended
in the tmux manpage. https://man7.org/linux/man-pages/man1/tmux.1.html

Fixes https://github.com/neovim/neovim/issues/36786

Signed-off-by: Elias Assaf <elyas51000@gmail.com>
(cherry picked from commit 310d01d8fa)
2025-12-02 03:36:11 +00:00
CompileAndConquer
fa24e045e9 fix(buffer): defer w_buffer clearing to prevent dict watcher crash #36748
(cherry picked from commit f9ef1a4cab)
2025-12-01 02:35:30 +00:00
zeertzjq
9fb49aacde fix(buffer): don't allow changedtick watcher to delete buffer (#36764)
(cherry picked from commit 14d65dae91)
2025-12-01 01:47:44 +00:00
ymich9963
fcd0517dee fix(ui.open): use "start" instead of deprecated "rundll32" #36731
Problem:
The rundll32 utility is a leftover from Windows 95, and it has
been deprecated since at least Windows Vista.

Solution:
Use the start command through Command Prompt instead.

(cherry picked from commit c87d92c3b4)
2025-11-30 15:33:35 +00:00
Justin M. Keyes
1f93acc293 backport: build(windows): vendor xxd.c (#36755)
backport https://github.com/neovim/neovim/pull/36746

Problem:
Currently we fetch a prebuilt xxd.exe from neovim/deps for Windows,
which is not ideal in terms of obviousness, misses updates, and is
clumsy to update.

Solution:
Similar to tee.c (#36363), vendor xxd.c from Vim and build it as part
of the Neovim build process. This makes the source obvious, enables
analyzer checks, and simplifies updates.

Fixes #36664

Co-authored-by: benarcher2691 <ben.archer2691@gmail.com>
2025-11-30 05:33:55 +00:00
Siwen Yu
79b67ce331 fix(appimage): wrong $ARCH used by linuxdeploy #36712
Problem:
In scripts/genappimage.sh running on arm64 host, the $ARCH will be set to
'arm64' before calling linuxdeploy, which cause linuxdeploy to generate
an 32bit ELF executable instead 64bit. See the issue for more details.

Solution:
Keep $ARCH unchanged, use $ARCH_OUTPUT in the output file name. On arm64
host, $ARCH_OUTPUT will be converted to 'arm64'.

(cherry picked from commit 4daa8eb5ab)
2025-11-27 18:28:21 +00:00
Kent Sibilev
656ff4c438 fix(events): crash on WinScrolled #35995
Problem: apply_autocmds function can free both buf_T and win_T pointers

Solution: instead retain winids for WinResized and WinScrolled
autocmds and use curbuf pointer, which is consistent with other uses
of apply_autocmds function

(cherry picked from commit 0a0c349b6f)
2025-11-26 15:17:02 +00:00
Muhammad Saheed
5143419e22 fix(man.lua): :Man slow/hangs if MANPAGER is set #36689
Problem:
When `MANPAGER` is set to something like 'nvim +Man!',
`vim.system({ 'nvim' })` call waits forever for input and times out
after 10 seconds in `system()` and the assert on `stdout` being not
`nil` fails.

Solution:
Set `MANPAGER=cat` when calling `system()`

(cherry picked from commit 87bd16e470)
2025-11-26 14:45:37 +00:00
User0
d0ed06dcea build: haiku os support #36639
Initial support for compiling on haiku os. Some deps can be pulled from
haiku repos, some need to be compiled with nvim's dep build system:

    cmake -DUSE_BUNDLED_LIBUV=OFF -DUSE_BUNDLED_UNIBILIUM=OFF -DUSE_BUNDLED_LUAJIT=OFF -B .deps ./cmake.deps
    make -C .deps

(cherry picked from commit 10c11c4644)
2025-11-26 14:39:22 +00:00
zeertzjq
9978b1b29e Merge pull request #36701 from zeertzjq/backport
docs: misc
2025-11-26 22:07:57 +08:00
Justin M. Keyes
0bc2381b6b docs: misc
Co-authored-by: Maria José Solano <majosolano99@gmail.com>
Co-authored-by: glepnir <glephunter@gmail.com>
2025-11-26 21:47:10 +08:00
Riccardo Mazzarini
da825e5541 fix(api): on_bytes gets stale data on :substitute #36487
Problem: `extmark_splice()` was being called before `ml_replace()`,
which caused the on_bytes callback to be invoked with the old buffer
text instead of the new text.

Solution: store metadata for each match in a growing array, call
`ml_replace()` once to update the buffer, then call `extmark_splice()`
once per match.

Closes https://github.com/neovim/neovim/issues/36370.

(cherry picked from commit 7da4d6abe2)
2025-11-21 06:15:38 +00:00
Lewis Russell
53090ab6a8 fix(statusline): scope truncation bookkeeping
Limit the default truncation item to the current recursion range so
nested `nvim_eval_statusline()` calls don't reuse stale `stl_items`
pointers. Add a functional regression that evaluates a Lua statusline
helper which forces truncation to ensure the nested scenario stays
stable.

AI-Assist: OpenAI ChatGPT

Fixes #36616

(cherry picked from commit e9b6474ae7)
2025-11-20 12:10:46 +00:00
Justin M. Keyes
63c5a101af fix(install): only install "tee" on Windows #36629
Problem:
AUR does not want a web-scale implementation of "tee".

Solution:
- Only install "tee" on Windows.
- The build will still produce `./build/bin/tee` on all platforms, to
  have more coverage and avoid special-cases in tests.

(cherry picked from commit e0308dc147)
2025-11-20 05:37:32 +00:00
Justin M. Keyes
a94647bb08 backport: build(windows): restore "tee" on Windows #36627
build(windows): restore "tee" on Windows

Problem:
Neovim no longer ships with a tee binary on Windows, which breaks
functionality for the :grep and :make commands.

    nvim --clean
    :grep foo or :make
    "tee is not recognized as an internal or external command"

Solution:
Include a simple, no-dependency tee.c source file in the src/ directory.
Update CMakeLists.txt to build a tee executable alongside neovim during
the build process, and ensure the tee.exe program appears alongside the
neovim executable in the bin/ directory so that it is accessible for
:grep and :make.

tee.c was obtained from the vim codebase:
https://github.com/vim/vim/blob/master/src/tee/tee.c

And we modified it to fix performance issues.

Testing:

    nvim --clean
    :grep foo or :make, after setting a file to the makeprg option.
    Verify that :grep results and error output from a compiler appear in the message pane.

ref https://github.com/neovim/neovim/issues/32431
fix https://github.com/neovim/neovim/issues/32504

Other tee options:
- [tee-win32](https://github.com/dEajL3kA/tee-win32): MIT. However,
  I couldn't get it to build on my machine even after updating its
  makefile to call my install of MSVC. It's also super optimized and
  uses some processor intrinsics for multithreading.
- [gnu coreutils tee](https://gnuwin32.sourceforge.net/packages/coreutils.htm):
  (Windows coreutils contains a tee.c. Last updated 2005. Did not build
  immediately on my machine; we'd have to determine which definitions
  from elsewhere in coreutils tee.c needs and incorporate them somehow.
- [WinTee](https://github.com/mpderbec/WinTee): Has no license. Last
  updated 11 years ago. Relies on Visual Studio to build.

Co-authored-by: friendlyman23 <ams5661@gmail.com>
2025-11-19 17:03:42 -08:00
Justin M. Keyes
2794d349ad docs(diagnostic): diagnostic.Opts.Float extend open_floating_preview.… (#36612)
docs(diagnostic): diagnostic.Opts.Float extend open_floating_preview.Opts #30058

Problem: the opts table also is param of util.open_floating_preview,
vim.diagnostic.Opts.Float missing some fields of open_floating_preview.

Solution: diagnostic.Opts.Float extend util.open_floating_preview.Opts

Fix #29267

Co-authored-by: glepnir <glephunter@gmail.com>
2025-11-18 22:05:29 -08:00
neovim-backports[bot]
fac7c10eb8 fix(windows): set manifest resource ID to 1 in nvim.rc for MinGW (#36611)
fix(windows): wrong RT_MANIFEST ID in nvim.rc #36406

Problem:
Starting Nvim on MinGW fails:
https://github.com/msys2/MINGW-packages/issues/25140

    Unknown system error -1:"C:\msys64\ucrt64\bin\nvim.exe"Failed to start Nvim server!

Solution:
On Windows, the main application manifest should use resource ID 1 (RT_MANIFEST).
Update `nvim.rc` to use `1 RT_MANIFEST nvim.manifest` instead of `2`,
ensuring the manifest is correctly embedded and recognized by the system.

ID = 1 is for executable files (.exe)
ID = 2 is for DLLs (/DLL)
From MSVC docs: "Use a value of 2 for a DLL to enable it to specify private dependencies."
https://learn.microsoft.com/en-us/cpp/build/reference/manifest-create-side-by-side-assembly-manifest

(cherry picked from commit 2c04ae9fcc)

Co-authored-by: SquallATF <squallatf@gmail.com>
2025-11-18 21:56:26 -08:00