Commit Graph

36308 Commits

Author SHA1 Message Date
phanium
78d001cff7 backport: build: support variant builds via env-var and cpack overrides (#40963)
build: support variant builds via env-var and cpack overrides

Problem: scripts/genappimage.sh runs `make` with no extra flags and
emits a fixed nvim-linux-<arch>.appimage filename, so packaging a
variant build (e.g. with the bundled PUC-Rio Lua interpreter)
requires editing the Makefile or post-renaming the AppImage, which
breaks the AppImage zsync URL.

Solution: forward DEPS_CMAKE_FLAGS and CMAKE_EXTRA_FLAGS to `make`,
accept OUTPUT so the AppImage (and its zsync Filename:) follows the
caller's chosen name, and mark CPACK_PACKAGE_FILE_NAME as CACHE
STRING on Linux so the resulting tarball/deb follow as well. Default
behavior is unchanged when none of these env vars are set.
2026-07-25 08:59:12 -04:00
zeertzjq
ab7ae9ce47 vim-patch:9.2.0838: searchcount() returns wrong cached maxcount (#40913)
Problem:  Cached searchcount() returns 'maxsearchcount' instead of the
          requested maxcount.
Solution: return the remembered last_maxcount (glepnir)

closes: vim/vim#20701

4352dc6ab0

Co-authored-by: glepnir <glephunter@gmail.com>
(cherry picked from commit 53cbf66bd2)
2026-07-23 01:26:27 +00:00
XiaowenHu
41163b7731 fix(inccommand): enforce timeout during matching, not just after a line #40892
Problem: do_sub() only checks the timeout limit after finishing a line.
         A pathological regex will run on a single line input unbounded
         until the compute is completed.

Solution: Pass the timeout limit to `vim_regexec_multi()` so the
          computation on the regex engine is bounded per-line.

Signed-off-by: XiaowenHu96 <me@xiaowenhu.com>
(cherry picked from commit bd73d8c011)
2026-07-22 13:02:26 +00:00
Artem Krinitsyn
290f7e69a1 backport: fix(lsp): guard linked_editing_range refresh on attach (#40900)
Problem:
on_attach() calls refresh(), but there is no guarantee the attached
buffer is the current buffer. This can make linked editing request
handling assume the wrong window.

Solution:
Call refresh() only if the current buffer is attached. This keeps the
initial highlighting behavior while avoiding making incorrect request.

(cherry picked from commit 9180c6e093)
2026-07-22 10:43:05 +00:00
Justin M. Keyes
ba2ea67a1f fix(lsp): incorrect rendering of markdown codeblock #40861
Problem:
LSP hover erroneously drops blank lines before a 4-space-indented
codeblock, which is not valid Markdown. This causes incorrect parsing
and wrong display.

Solution:
Fix `split_lines` so that it doesn't drop the blank line just before
a 4-space-indented codeblock.

fix https://github.com/neovim/neovim/issues/40860

(cherry picked from commit 317c5ddda6)
2026-07-20 14:53:01 +00:00
Barrett Ruth
37d7b11bc1 fix(window): avoid UAF in close_windows (#40853)
(cherry picked from commit a787a31490)
2026-07-20 08:12:44 +00:00
neovim-backports[bot]
6cb9334aa0 backport: fix(path): avoid shell fallback for unknown users (#40791)
fix(path): avoid shell fallback for unknown users

Problem:
Expanding an unknown ~user path falls back to the shell. In a fast event,
this re-enters the event loop and aborts Nvim.

Solution:
Leave unknown users unexpanded when the system account lookup fails.

(cherry picked from commit 9d3edf345f)

Co-authored-by: MAAZIZ Adel Ayoub <adelayoub.maaziz@gmail.com>
2026-07-18 19:46:25 +00:00
Justin M. Keyes
37da244685 backport: test: unreliable "put command . register special … ring the bell" (#40818)
test: unreliable "put command . register special … ring the bell"

Problem:

    FAILED   …/put_spec.lua:894: …/put_spec.lua @ 898: put command . register special tests should ring the bell when deleting if not appropriate
    …/put_spec.lua:894: …/put_spec.lua:898: Bell was not rung after action

    Snapshot:
    screen:expect([[
      ^ine of words 1                                       |
      Line of words 2                                      |
      {1:~                                                    }|*4
      {3:[No Name] [+]                                        }|
                                                           |
      {1:~                                                    }|*4
      {UNKNOWN_HL_ID(4):[No Name]                                            }|
      {UNKNOWN_HL_ID(1):                                                     }|
    ]])
    stack traceback:
    …/ui/screen.lua:917: in function '_wait'
    …/ui/screen.lua:540: in function 'expect'
    …/editor/put_spec.lua:894: in function 'bell_test'
    …/editor/put_spec.lua:940: in function <…/editor/put_spec.lua:932>

Analysis:
The bell was asserted via the UI 'bell' event (screen.bell), but
vim_beep() rate-limits that to 3 per 500ms. These tests share one
long-lived session, so beeps from earlier tests could exhaust the window
and drop the asserted beep.

Solution:
Use assert_beeps()/assert_nobeep(), which check called_vim_beep (set
before the rate-limit gate).
2026-07-18 15:19:34 -04:00
Barrett Ruth
371e60dceb fix(restart): distinguish v:exitreason for :restart! #40801
(cherry picked from commit 12e8db3847)
2026-07-18 08:37:51 +00:00
Justin M. Keyes
5d39617e7e Merge pull request #40790 from superatomic/backport-restart-message-improvements
backport: `:restart` related message improvements + docs
2026-07-17 16:26:03 -04:00
Olivia Kinnear
feec7b848f docs: remove incorrect mention of ZR in the docs for v:startreason 2026-07-17 13:13:47 -05:00
Olivia Kinnear
19ddd86128 fix(restart): messages EXX error codes #40759
(cherry picked from commit ed5dcc0edf)
2026-07-17 12:58:37 -05:00
Sean Dewar
fa3a0a7feb fix(window): yeet grid later when closing float in other tabpage #40758
Problem: #40731 may still crash if close_buffer autocmds reinsert the float's
grid. Plus removing the grid (and posting win_close) is unneeded if
win_close_othertab refuses to close the window later, which is possible.

Solution: do the stuff before freeing the window, like win_close.
(cherry picked from commit 1741da8412)
2026-07-16 07:07:07 +00:00
Olivia Kinnear
a198506815 fix(restart): keep :restart error message concise #40746
(cherry picked from commit 4f1ef2dec1)
2026-07-15 20:45:05 -05:00
phanium
3a0e6239e9 fix(window): remove float grid from compositor layers before free #40731
Problem: Closing a floating window from a non-current tab frees its grid
without removing it from the compositor's `layers` table, so the next
`ui_comp_put_grid()` walks a dangling pointer (UAF).

Solution: Call `ui_comp_remove_grid()` (and `ui_call_win_close()` for
multigrid UIs) before `win_free_mem()`, matching `win_close()` since
PR #21551.

(cherry picked from commit 6f370f34f2)
2026-07-15 14:22:22 +00:00
Robert Muir
d2b217b043 fix(lsp): improve inlayHint.resolveSupport in client capabilities #40741
Problem
The current list of properties for inlay hint resolve support includes a
non-existent "location". This field should be "label.location" according
to the specification. Tooltips and commands for inlay hint "parts"
aren't advertised as being resolvable.

Solution
Remove "location" and add "label.location", "label.tooltip", and
"label.command".

Closes #40740

(cherry picked from commit 4bc30d6e10)
2026-07-15 11:24:17 +00:00
zeertzjq
68e0b78ce3 test: fix typo
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2026-07-15 07:02:53 +00:00
zeertzjq
9ea90ec35a fix(floatwin): don't use same window as altwin (#40748)
Fixes a regression from #34486
Fix #40745

(cherry picked from commit 39bc59a8f1)
2026-07-15 07:02:53 +00:00
Ryan Patterson
a8d7292de3 fix(treesitter): give each wasm parser its own TSWasmStore #40163
All wasm parsers shared a single global TSWasmStore via
ts_parser_set_wasm_store(). A TSWasmStore is owned by exactly one parser:
ts_parser_delete() frees it through ts_wasm_store_delete(). So the first
wasm parser collected freed the shared store, leaving the global pointer
dangling, and creating the next wasm parser dereferenced freed memory in
ts_wasm_store_reset() -> wasmtime_store_context(), crashing with SIGSEGV.

Give each parser its own store via ts_wasm_store_new() instead. This is
the 1:1 store-per-parser model intended by tree-sitter (see
tree-sitter/tree-sitter#3454): the global store remains only as the
language loader, ts_parser_delete() cleanly frees each parser's own
store, and the wasm engine is shared safely because ts_wasm_store_new()
clones its engine reference internally.

AI-assisted: Claude Code
2026-07-12 12:45:35 +02:00
Christian Clason
a14617849f build(deps): bump wasmtime to v36.0.12 2026-07-12 12:45:35 +02:00
Christian Clason
939efc2d31 build(deps): bump tree-sitter to v0.26.11 2026-07-12 12:45:35 +02:00
Nathan Zeng
3dc32d5cd1 backport: feat(restart)!: ZR restores session #40669
(cherry picked from commit c0a16a5977)
2026-07-10 06:58:59 -04:00
MAAZIZ Adel Ayoub
65345c9981 fix(socket): --listen silently truncates long paths #40625
Problem:
A `--listen` path longer than the system socket path limit (~104 bytes on
macOS, 108 on Linux) is silently truncated by `uv_pipe_bind()`. Nvim either
serves a socket at a different path than `v:servername` reports, or fails with
an error that blames the full untruncated path (confusing):

    nvim: Failed to --listen: address already in use: "<full path>"

Steps to reproduce:

    $ nvim --listen /var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T//nvim/-Users-rpatterson-Projects-src-github.com-neovide-neovide --embed -p
    nvim: Failed to --listen: address already in use: "/var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T//nvim/-Users-rpatterson-Projects-src-github.com-neovide-neovide"

    $ ls /var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T//nvim/-Users-rpatterson-Projects-src-github.com-neovide-neovide
    "/var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T//nvim/-Users-rpatterson-Projects-src-github.com-neovide-neovide": No such file or directory (os error 2)

    $ ls -l /var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T//nvim/
    srwxr-xr-x@ - rpatterson 31 Mar 10:24 -Users-rpatterson-Projects-src-github.com-neovid

Solution:
Bind with `uv_pipe_bind2()` and `UV_PIPE_NO_TRUNCATE` (libuv 1.46+), so
a too-long path fails up front with the actual reason:

    nvim: Failed to --listen: invalid argument: "<full path>"

(cherry picked from commit de141b4679)
2026-07-09 20:30:40 +00:00
Barrett Ruth
e81d67ffa1 fix(terminal): avoid E676 after failed :wqa (#40620)
(cherry picked from commit 5231ad1357)
2026-07-07 02:04:18 +00:00
neovim-backports[bot]
d23c98deab backport: fix(shada): persist cleared registers (#40615)
Problem:
Clearing a register via `:let @a = ""` doesn't persist in shada.

Solution:
Follows the precedent of ee56daebb6 .
Namely, when the live register is empty and *at least as recent* as the copy
that is on disk, drop it instead of writing it back.

(cherry picked from commit aff618536b)

Co-authored-by: Barrett Ruth <62671086+barrettruth@users.noreply.github.com>
2026-07-06 11:25:40 -04:00
Barrett Ruth
40dccef262 fix(shada): persist cleared search patterns #40600
Problem:
`:let @/ = ""` doesn't stick after restart (the old search pattern comes back).

Solution:
When the current session cleared the pattern more-recently than stored
shada entry, drop the shada entry instead of restoring it.

Note: similar timestamp-based suppression was used for deleted
marks: ee56daebb6
(cherry picked from commit af9f24b80b)
2026-07-06 14:07:25 +00:00
Barrett Ruth
d427d38d06 fix(man.lua): cache pages until width changes #40607
Problem: :Man unloads hidden buffers, so reopening large pages reruns rendering
even when the width is unchanged.

Solution: keep regular man buffers loaded and refresh them only when the
effective width changes.

(cherry picked from commit a6827be98f)
2026-07-06 11:09:31 +00:00
Justin M. Keyes
7d80e18207 Merge pull request #40606 from superatomic/backport-seamless-restart
backport: `v:startreason` and ":restart" (no bang) saves/restores session
2026-07-06 05:18:10 -04:00
Nathan Zeng
de42a039de docs(restart): use 'sessionoptions' to adjust :restart behavior #40583
(cherry picked from commit 656b4d9c34)
2026-07-06 00:04:35 -05:00
Nathan Zeng
97290e8658 fix(:restart): remove -S [file] from v:argv #40521
Problem:
Session files specified at startup `-S [file]`, logically conflict
with `:restart`.

Solution:
Remove `-S [file]` from `v:argv` when doing :restart.
Also for the "bang" variant `:restart!`, just because it's
simpler (if anyone reports a use-case later, we can revisit).

(cherry picked from commit 47958bb4db)
2026-07-06 00:04:35 -05:00
Nathan Zeng
9905c7b425 feat(:restart)!: ":restart" (no bang) saves/restores session #40321
Problem:
`:restart` does not preserve window layout, etc.

Solution:
- Change `:restart` to save/restore a session automatically.
- Introduce "bang" variant `:restart!` to restart *without* session
  save/restore.
- Introduce `v:startreason`.
- `ZR` maps to `:restart!`.

(cherry picked from commit 845b66dd4a)
2026-07-06 00:04:30 -05:00
Justin M. Keyes
2b56939619 fix(:restart): set job env instead of mutating parent env #40308
Problem:
- Transient mutation of the parent env is visible to any concurrent
  code. Or at least just kinda sloppy.
- Latent bug:`channel_job_start` queues the spawn and returns before
  `uv_spawn` runs, so the prior `os_unsetenv` immediately after the call
  could in principle race with the deferred spawn.

Solution:
Pass `env` to the channel.

(cherry picked from commit a1da5d1f14)
2026-07-05 23:05:18 -05:00
Nathan Zeng
611b4f8237 feat(:restart): v:startreason #40186
Problem:
It's clumsy for scripts to handle a "restart", without custom mappings or
global vars.

Solution:
Introduce `v:startreason`

(cherry picked from commit ae426ee465)
2026-07-05 23:05:16 -05:00
bfredl
a4985ac902 fix(lua): give nicer error message when trying to index vim.NIL
The added test shows the context, one expected a JSON field
to be a Object but it was a null value

pros: shows `vim.NIL` instead of `a userdata`
cons: the context `field 'foo'` is lost. I think this is generated
with internal magic which is hard to replicate.

(cherry picked from commit 71b28da0f4)
2026-07-05 22:50:06 +00:00
Justin M. Keyes
6da50f145a build: version bump 2026-07-05 14:08:26 +02:00
Justin M. Keyes
68ea43cd0c NVIM v0.12.4
Following is a list of commits (fixes/features only) in this release.
See `:help news` in Nvim for release notes.

FEATURES
--------------------------------------------------------------------------------
- fec4045601 lsp: clean up semantic token initialization and debounce #40266
- 55205b3231 lsp: use LspNotify for semantic tokens (#40242)

PERFORMANCE
--------------------------------------------------------------------------------
- fded370b3e lsp: overscan semantic_token range requests #40036
- fa365cedad treesitter: reduce memory usage of _select.lua #40409

FIXES
--------------------------------------------------------------------------------
- e57c37d246 api: nvim_buf_set_text resets changelist to 0 #39965
- ea07b60fb1 api: preserve ArrayOf metadata #40429
- 5ff4e147d0 cmdline: avoid redraw loop after wrapped line #40240
- a0d7e80368 folds: foldcolumn is interrupted for virtual line above nested fold (#39999)
- a4cfded55e health: always set 'modifiable' #40584
- 7fd0f541e7 health: don't check node package via yarn #40572
- 749126de08 highlight: keep guisp underline color in float with 'winblend' #40283
- 5c38490806 lsp: allow specifying bufnr + client_id filter when enabling capabilities #37690
- c81ab6027d lsp: catch another nil buffer state #40285
- bf8d0bef16 lsp: fire LspNotify didChange autocmds after undo/redo #40404
- 41dbb828bd lsp: fix multiline semantic token processing (#40340)
- 3dd3a6ceab lsp: make LspNotify more robust (#40341)
- ecda67662f lsp: refresh codelens despite pending debounce #40177
- 822d96969b lsp: request semantic tokens in BufWinEnter #40513
- fd27246f67 lsp: skip invalid file watcher globs #40376 #40396
- dc6a9170eb lsp: trailing blank line when edit inserts past end of buffer (#40176)
- 93dd8053ee lsp: use LspNotify for document_color (#40575)
- dffacf5c9d man.lua: highlight codeblocks #40310
- 527c7c8c6b messages: "progress" kind for busy messages #39280
- 0b134d8b23 messages: message kind for :recover and swapfile attention #39444
- 304f8ed67a net: set buftype=nofile (again) (#39932)
- f533a17958 pack: do not assert non-nil `stderr` #40544
- 61765b97fe process: avoid inherited stdio for Windows jobs #40074
- ed7acd1391 startup: use `nvim.difftool` for `nvim -d` only for directories #40185
- 83d9b9afca statusline: prevent various buffer overflows with item groups #40219
- c1318ac348 test: support multiple --filter-out #39885
- 2b37c26477 treesitter: incremental selection causes beeps when the bell is enabled #40414
- abaf2a0e93 tui: more compatible way to reset cursor #40234
- 1f82ecf770 tui: patch reset-cursor-style seq regardless of terminfo #40249
- c58e5b73f1 xxd: buffer overread #40236
- 5c75abf790 xxd: signed left-shift overflow in -r mode #40246

VIM PATCHES
--------------------------------------------------------------------------------
- 1b9159a695 9.2.0718: :syn sync without an argument also lists syntax cluster (#40399)
- ad5720eab9 9.2.0735: [security]: arbitrary Ex command execution during C omni-completion (#40441)
- e41b309abe 9.2.0754: repeated completion length lookup in search_for_exact_line (#40511)
- 71343dad79 9.2.0756: Session with multiple tabpages sets 'winminheight' to 0 (#40512)

REFACTOR
--------------------------------------------------------------------------------
- d6476eda40 os: libuv_proc_stdio #40506
stable v0.12.4
2026-07-05 14:05:57 +02:00
Justin M. Keyes
83babc720e Apply suggestion from justinmk 2026-07-05 10:39:22 +00:00
Evgeni Chasnovski
f533a17958 fix(pack): do not assert non-nil stderr #40544
Problem: On some systems `stderr` can be disabled. This results in not
  usable `vim.pack` since it asserted `stderr` to be non-nil.

Solution: Stop asserting non-nil `stderr`. The downside is that
  potential errors are not shown, but this is intentional since `stderr`
  is disabled on system level.

  Still assert non-nil `stdout` as its output is important for
  `vim.pack` to actually do its job. Disabled `stdout` is not something
  that can work with `vim.pack`.

(cherry picked from commit 25d33dd12b)
2026-07-05 10:39:22 +00:00
dqnne
a4cfded55e fix(health): always set 'modifiable' #40584
Problem:
When buffers are by default `nomodifiable`, such as when Nvim starts with
`-M`, the health buffer cannot be updated.

Solution:
Always set `modifiable` before modifying the buffer.

(cherry picked from commit 0f86ea5ed8)
2026-07-05 10:27:04 +00:00
Barrett Ruth
7fd0f541e7 fix(health): don't check node package via yarn #40572
(cherry picked from commit 1aced004ce)
2026-07-04 20:33:10 +00:00
jdrouhard
93dd8053ee fix(lsp): use LspNotify for document_color (#40575)
fix(lsp): use LspNotify for document_color #40571

Problem: The document_color lsp module was already using the capability
framework but was still using raw buffer events to handle requests and
reloading. This means that every keystroke was sending a document_color
request to the server since there was no debounce in the raw handlers.

Solution: Switch to using LspNotify autocmd events. LspNotify fires just
after new document versions are synced with the server and provides a
built in debounce mechanism for changes. It also provides the signal for
when the current state should be cleared (didClose). The detach part is
already handled by the capability framework.

Fixes #39785

(cherry picked from commit 29db6ce84c)
2026-07-04 14:42:45 +00:00
zeertzjq
e41b309abe vim-patch:9.2.0754: repeated completion length lookup in search_for_exact_line (#40511)
Problem:  search_for_exact_line() repeatedly calls ins_compl_len() and
          relies on ternary operator precedence.
Solution: Cache the completion length and parenthesize the ternary
          expression.

closes: vim/vim#20678

ac443b9924

Co-authored-by: glepnir <glephunter@gmail.com>
(cherry picked from commit 3fea2a7fc5)
2026-07-01 00:35:48 +00:00
zeertzjq
71343dad79 vim-patch:9.2.0756: Session with multiple tabpages sets 'winminheight' to 0 (#40512)
Problem:  Session with multiple tabpages sets 'winminheight' to 0.
Solution: Only save 'winminheight' and 'winminwidth' once (zeertzjq).

related: vim/vim#8119
related: neovim/neovim#40493
closes: vim/vim#20673

294dec827d
(cherry picked from commit c040f53dc1)
2026-07-01 00:10:44 +00:00
jdrouhard
822d96969b fix(lsp): request semantic tokens in BufWinEnter #40513
Problem: A previous refactor removed the BufWinEnter autocmd that
initiated a token request. When an LSP server sends a refresh
notification, then buffers that aren't shown in any window lost their
only trigger to request new tokens.

Solution: Add the BufWinEnter autocmd back which simply requests tokens
for all clients attached to the buffer.
2026-06-30 19:15:54 -04:00
Justin M. Keyes
d6476eda40 refactor(os): libuv_proc_stdio #40506
(cherry picked from commit d303617132)
2026-06-30 19:04:59 +00:00
glepnir
e57c37d246 fix(api): nvim_buf_set_text resets changelist to 0 #39965
Problem: changed_lines got a hardcoded 0, so the changelist entry
and '. mark always recorded column 0 instead of where the edit
actually happened.

Solution: pass start_col instead. changelist now tracks the real
column.

(cherry picked from commit 7312df77bb)
2026-06-29 19:01:22 +00:00
Sanzhar Kuandyk
61765b97fe fix(process): avoid inherited stdio for Windows jobs #40074
Problem:
On Windows, channel jobs inherit Nvim's stdio, so a background job
writing to CON (e.g. gutentags) draws onto the TUI and stays until
redraw.

Solution:
Give Windows job stdin/stderr libuv-created pipes (UV_CREATE_PIPE)
instead of inherited fds, so libuv spawns the child with
CREATE_NO_WINDOW and CON writes no longer leak onto the TUI.

(cherry picked from commit 39e9c1754a)
2026-06-29 15:56:30 +00:00
zeertzjq
ad5720eab9 vim-patch:9.2.0735: [security]: arbitrary Ex command execution during C omni-completion (#40441)
Problem:  [security]: With C omni-completion, a crafted tags file can execute
          arbitrary Ex commands when completing a struct/union member
          (cipher-creator)
Solution: Escape the type field before inserting it into the :vimgrep
          pattern so it cannot close the pattern and start a new command
          (Hirohito Higashi).

Github Security Advisory:
https://github.com/vim/vim/security/advisories/GHSA-mf92-v4xw-j45x

6b611b0d15

Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
(cherry picked from commit d844a276bb)
2026-06-27 01:39:24 +00:00
Lewis Russell
ea07b60fb1 fix(api): preserve ArrayOf metadata #40429
ArrayOf metadata existed before the LuaCATS type documentation refactor and is
useful to typed clients consuming api_info().

Keep Tuple metadata normalized to Array, since tuple element types can be mixed,
but preserve ArrayOf(...) for exported API metadata.

Fixes #38734

AI-assisted: Codex
(cherry picked from commit ea0af59854)
2026-06-26 10:14:30 +00:00
Dmytro Meleshko
fa365cedad perf(treesitter): reduce memory usage of _select.lua #40409
Problem:  The table `history` in treesitter/_select.lua stores references
          to previously selected TSNodes, but a TSNode needs to keep its
          whole TSTree alive in memory, which may be kept alive even
          after closing the buffer to which this history corresponds.

Solution: Store just the bits of information from the TSNode we need to
          go back in selection history (the range and ID), without
          referencing the TSNode itself.
(cherry picked from commit bcfc2037ef)
2026-06-25 16:35:51 +00:00