37184 Commits

Author SHA1 Message Date
Justin M. Keyes
0f7bd6a3cd fix(diff): resource leak on :diffput E787 error path #40686
Coverity CID 649080/649081
2026-07-11 07:15:04 -04:00
Justin M. Keyes
eb2e695e40 test: "Failed to start server: address already in use" #40683
Problem:
unreliable test:

    FAILED   …/tui_spec.lua @ 895: TUI mouse events work with right-click menu (escape sequences sent to child)
    D:/a/…/testnvim.lua:144: Vim:Failed to start server: address already in use
    stack traceback:
    D:/a/…/testnvim.lua:144: in function 'eval'
    D:/a/…/testnvim.lua:1015: in function 'new_pipename'
    …/tui_spec.lua:897: in function <…/tui_spec.lua:895>

Solution:
Workaround potential PID reuse.
2026-07-11 06:52:04 -04:00
github-actions[bot]
7e9f384dde docs: update version.c #40609
Co-authored-by: marvim <marvim@users.noreply.github.com>
2026-07-11 04:19:55 -04:00
glepnir
59dbca9b0c fix(api): nvim_cmd() "args" type too narrow #40670
Problem: nvim_cmd() accepts number/boolean in args and converts them
to strings, but the keyset declares ArrayOf(String).

Solution: use ArrayOf(Union(Integer, String, Boolean)) and wrap union
types in parens when generating array annotations.
nightly
2026-07-10 20:34:08 -04:00
Barrett Ruth
784765cb73 fix(winbar): update hidden tabpages on global 'winbar' change #40608
Problem:
Changing global 'winbar' only updates window layout state in the current
tabpage. This means existing hidden tabs can keep stale winbar height.

Solution:
Recompute winbar state for all tabpages on global `'winbar'` changes.
2026-07-10 12:49:52 -04:00
Barrett Ruth
3b88a8a65d fix(filetype): ensure directory bufname ends w/ slash sep #40552
Problem:
`vim.filetype.match()` needs a cheap way to recognize directory buffers
without doing filesystem stat work.

Solution:
Ensure full buffer names for directories end in a trailing slash. Now
directory buffers can proceed through the normal 'filetype' path.

Note side-effects: session and ShaDa buffer-list restore behavior must
be compatible, so those + corresponding tests must be updated.
2026-07-10 12:40:13 -04:00
Barrett Ruth
20a4b1bc5e fix(dir): user/plugin can override default "-" mapping #40676 2026-07-10 11:52:24 -04:00
Justin M. Keyes
6a8bb2d62f refactor(ctx): simplify ctx_switch (40674 2026-07-10 09:08:58 -04:00
dependabot[bot]
435734e8db ci: bump the github-actions group across 1 directory with 2 updates
Bumps the github-actions group with 2 updates in the / directory: [actions/checkout](https://github.com/actions/checkout) and [github/codeql-action](https://github.com/github/codeql-action).


Updates `actions/checkout` from 6 to 7
- [Release notes](https://github.com/actions/checkout/releases)
- [Commits](https://github.com/actions/checkout/compare/v6...v7)

Updates `github/codeql-action` from 4.36.2 to 4.36.3
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v4.36.2...v4.36.3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: github/codeql-action
  dependency-version: 4.36.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-10 14:44:52 +02:00
Justin M. Keyes
d79c787f27 refactor(ctx): ctx_restore_curwin #40667
unify context-switching logic.

1. `prevwin` is now restored for all targets (was buf-only).
   - add a `nvim_win_call` test.
2. The buf-found "restore the shown buffer" dance no longer depends on
   the origin window: it runs even if the callback closed the origin.
2026-07-10 07:58:02 -04:00
bfredl
e684a3dd18 Merge pull request #38546 from dchinmay2/push-pozrrzptmvnv
build(zig): add formatc and lintc steps
2026-07-10 11:18:43 +02:00
Justin M. Keyes
edb043bf33 Merge #40661 from justinmk/unifyctx 2026-07-09 21:50:45 -04:00
Justin M. Keyes
d3ffc94110 refactor(cmdpreview): lift undo-checkpoint code
This is a mechanical lift of undo save-and-restore logic into... the
module that owns undo.
2026-07-10 03:27:37 +02:00
Justin M. Keyes
6bb1aa74e6 refactor: unify context-switching concepts 2026-07-10 03:27:37 +02:00
Justin M. Keyes
982d2f2531 fix(test): screen:expect({none=…}) with no any/grid
Problem:
`screen:expect({none=…})` with no any/grid crashed (concat on nil)
because actual_rows was only rendered when any or grid was present.

Solution:
Update the condition.
2026-07-10 00:06:59 +02:00
Barrett Ruth
7dccbfed10 fix(dir): select origin on parent navigation #40658 2026-07-09 17:47:56 -04:00
MAAZIZ Adel Ayoub
de141b4679 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>"
2026-07-09 16:07:17 -04:00
Barrett Ruth
a54a7f6a78 fix(dir): preserve alternate buffer #40659 2026-07-09 15:41:09 -04:00
Justin M. Keyes
8c285c6c33 refactor(api): drop CmdParseInfo indirection #40657
Just Say No to indirection.
2026-07-09 13:30:33 -04:00
Vivek Kumar
bcbd9d7992 refactor(api): promote magic spec from CmdParseInfo to exarg_T #39119
Problem:
`magic` was owned by `CmdParseInfo`, but command handlers
need it at execution time via `exarg_T`.

Solution:
Move `magic` into `exarg_T`, and initialize it in `parse_cmdline()`.
2026-07-09 11:53:40 -04:00
Justin M. Keyes
55e3e4e984 build: bump minimum libuv #40648 2026-07-09 11:45:42 -04:00
Nathan Zeng
c0a16a5977 feat(restart)!: ZR restores session #40498 2026-07-09 07:09:12 -04:00
Christian Clason
e32874f17f build(deps): bump luajit to fed6d4782 2026-07-09 13:07:59 +02:00
Evgeni Chasnovski
fce6d9a549 feat(lua): add cwd context to vim._with() #40653
Problem: No concise way to execute a callback with temporarily set
  working directory. This might be useful when sourcing nested files to
  allow them to assume that current working directory is their root
  directory.

Solution: Add `cwd` context to `vim._with().`
2026-07-09 07:07:14 -04:00
Evgeni Chasnovski
3e9615b48a fix(options): set default 'packlockfile' respecting $NVIM_APPNAME #40651
Problem: The default 'packlockfile' value doesn't respect $NVIM_APPNAME.

Solution: Use more direct way of setting the default value, following
  the example of other options with a similar behavior.
2026-07-09 06:20:08 -04:00
zeertzjq
7c9222f45e fix(mouse): reset click count on next click if mouse moved (#40637)
Also, drop drag event if the mouse hasn't moved, like in gVim.
2026-07-09 08:40:00 +08:00
Justin M. Keyes
d55252a3ec refactor(logging)!: rename current_level #40642 2026-07-08 20:15:42 +00:00
Evgeni Chasnovski
0653e7a338 feat(pack): 'packlockfile' option #40562
Problem: No way to configure the lockfile location.

Solution: Add 'packlockfile' option.
2026-07-08 12:23:28 -04:00
Oleh Volynets
ef130902cf fix(lsp): clear push diagnostics on detach #40634
Problem: when an LS client detaches from the buffer, only pull diagnostics
are cleared via capability framework. Push diagnostics remain stuck even
when client stops/restarts.

Solution: clear push diagnostics on client detach.

ref #33864
2026-07-08 12:00:21 -04:00
Christian Clason
089662d318 build(deps): bump luajit to acb223497 2026-07-08 14:36:16 +02:00
Caleb White
653f2092ce fix(lsp): refresh document-pull buffers on workspace/diagnostic/refresh #40623
When a server supports both document and workspace pull diagnostics,
`on_refresh` only dispatched a `workspace/diagnostic` request.  The
workspace response handler skips buffers with `pull_kind == "document"`
(i.e. all buffers opened by the user), so their diagnostics went stale
until the next `didChange` or `didOpen` event.

Change `on_refresh` to always refresh document-pull buffers via
`textDocument/diagnostic`, regardless of whether the server also
supports workspace diagnostics.  This ensures that opened buffers
see updated diagnostics (e.g. after a save triggers an external
tool like PHPStan) without requiring the user to re-enter insert
mode.
2026-07-08 07:26:22 -04:00
Barrett Ruth
cfd7f29d52 feat(vim.fs): vim.fs.mkdir() #40599
Problem:
`vim.fs` does not provide a directory creation helper matching its
filesystem API shape.

Solution:
Add `vim.fs.mkdir()` as a thin wrapper around `vim.fn.mkdir()`, with
`parents` and `mode` options.
2026-07-08 07:16:29 -04:00
jdrouhard
6a6431cb99 refactor(lsp): use LspNotify for codelens #40604
Problem: The codelens LSP module was using its own raw buffer events and
its own debounce mechanism for refreshing code lens in attached buffers.

Solution: Switch the module to using the LspNotify autocmd events.
LspNotify fires just after document versions are synced with the server
and provides a built in debounce mechanism for changes.

Additionally, this fixes some bugs with the previous implementation:

1. The workspace/codeLens/refresh handler  re-requested codelens for all
   buffers but when the response came back, it forced an extra redraw
   after clearing the work the handler had just done.
2. Document synchronization was reworked to be more resilient to
   multiple clients providing codelens for a single buffer. The latest
   document version is now separately tracked per client (and per
   client's lenses per row) instead of for the buffer as a whole. This
   allows the on_win() function to properly redraw all codelens even
   when different clients' responses for a particular document version
   come back at different times.
2026-07-07 12:23:59 -04:00
Barrett Ruth
5231ad1357 fix(terminal): avoid E676 after failed :wqa (#40620) 2026-07-07 01:41:11 +00:00
Justin M. Keyes
18e27292e4 Merge pull #40619 fix(lua): statusline expr leaks into msg area 2026-07-06 17:21:03 -04:00
Justin M. Keyes
a6d7193f07 refactor(lua): rename nlua_call_typval 2026-07-06 22:17:25 +02:00
Justin M. Keyes
b5f500263b fix(lua): bufwrite message overridden by :redrawstatus
Problem:
bufwrite message overridden by :redrawstatus command within Progress callback.

Solution:
- don't use globally-shared IObuf.
- use vim_snprintf to deduplicate `nlua_call_luaeval`, `nlua_call_vlua`.

fix https://github.com/neovim/neovim/issues/40616
2026-07-06 22:17:25 +02:00
dependabot[bot]
c4af59647f ci: bump korthout/backport-action
Bumps the github-actions group with 1 update in the / directory: [korthout/backport-action](https://github.com/korthout/backport-action).


Updates `korthout/backport-action` from 4.5.2 to 4.6.0
- [Release notes](https://github.com/korthout/backport-action/releases)
- [Commits](6606540695...2e830a1d0b)

---
updated-dependencies:
- dependency-name: korthout/backport-action
  dependency-version: 4.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-06 15:41:58 +02:00
Barrett Ruth
aff618536b fix(shada): persist cleared registers #40601
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.
2026-07-06 09:40:17 -04:00
Barrett Ruth
af9f24b80b 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
2026-07-06 09:36:02 -04:00
prwang
732bf4db97 fix(input): stops accepting input after a large paste/input burst #40585
Problem:
Neovim can permanently stop accepting keyboard input after a large paste, or after
any sufficiently large input burst. The screen still redraws and honours window
resize, but typed keys have no effect and the session must be killed. A paste that
triggers the freeze is applied only partially.

Root cause:

`src/nvim/os/input.c` holds `input_buffer[INPUT_BUFFER_SIZE]` (16386 bytes),
compacted left rather than used as a ring:

- `input_get()` drains the buffer by advancing `input_read_pos`, but never rewinds
  the cursors when it empties (`input_read_pos == input_write_pos`).
- The only rewind lives in `input_enqueue_raw()`, which `input_enqueue()` reaches
  only inside `while (input_space() >= 19 && ptr < end)` (19 is the maximum
  expansion of one `<x>` key form).

So once input fills the buffer to within 19 bytes of the top and is then fully
drained, the cursors are pinned near the top with `input_space() < 19`. The gate
never reopens, `input_enqueue()` never rewinds, and all further input is silently
dropped: `input_available()` stays 0 and the editor blocks forever in
`state_enter()` → `input_get()`. Redraw and resize run on independent paths, which
is why the UI looks alive while the keyboard is ignored.

Solution:
Rewind the read/write cursors when the buffer is empty, at the start of
`input_enqueue()`. The reset moves no data in the empty case and guarantees the
space gate can reopen; the non-empty case self-heals as the editor drains.

Test case:
A reproducer (no terminal required; drives `nvim --embed` over msgpack-RPC via
`nvim_input`) floods the input buffer, lets the editor drain it, then probes with
`:qa!`. It shows a sharp threshold at `INPUT_BUFFER_SIZE − 18`:

| `--fill` | master    | with this fix |
|----------|-----------|---------------|
| ≤ 16367  | quits     | quits         |
| ≥ 16368  | **hangs** | quits         |

- On current `master`, the freeze reproduces at `fill=16368`; the patched build
  quits for every fill up to 100000.
- Interactive: a ~40 kB bracketed paste into Insert mode or a `:terminal` no longer
  freezes.
2026-07-06 08:37:02 -04:00
Barrett Ruth
a6827be98f 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.
2026-07-06 06:45:10 -04:00
bfredl
f034e5f66b Merge pull request #40522 from bfredl/neopath
refactor(test): unify XDG path handling (cmake vs zig)
2026-07-06 11:47:13 +02:00
bfredl
349f810eed refactor(test): unify XDG path handling (cmake vs zig)
fixes #40381
2026-07-06 10:55:20 +02:00
Barrett Ruth
dbe59b5457 test(lsp): retry on-type formatting assertions #40602 2026-07-05 18:07:16 -04:00
Nathan Zeng
47958bb4db 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).
2026-07-05 17:53:45 -04:00
Justin M. Keyes
8dfe4d6629 fix(api): nvim_win_resize tweaks #40596 2026-07-05 13:22:16 -04:00
jdrouhard
1f18ea1cf7 feat(lsp): convert inlay_hint to capability framework #40569
Problem:
Inlay hints used separate global and per-buffer bufstates tables and
bespoke global autocmds for managing the inlay hint state across buffers
and clients, duplicating the lifecycle logic already provided by the
Capability framework. This caused inconsistencies in how client state
was handled and inlay hint state lifecycle was managed compared to other
LSP features.

Solution:
Replace the ad-hoc bufstate tracking and global autocmds in
vim.lsp.inlay_hint with a proper InlayHint subclass of Capability.

This also refactors the way inlay hint state is managed and fixes bugs I
found while doing this:

1. For each line with inlay hints, the list of the hints along with
   whether they have been applied is stored in a current result on the
   client state. This allows the on_win decorator to clear all inlay
   hints for an old document version once, and then re-add the new
   version's hints line-by-line as they are drawn to the screen,
   modeling the semantic tokens module.
2. It fixes problems with mixing results from multiple clients attached
   to the buffer by fully moving each client's state to its own table.
   Previously, only the most recent document version used to populate a
   line's inlay hints was stored, but there was no distinction for which
   client the hints may have come from. (Fixes #36318)
3. It fixes the workspace/inlayHint/refresh server->client notification
   behavior. Previously it would only re-request inlay hints for buffers
   currently displayed in a window but would not invalidate them in
   non-displayed buffers (or provide any mechanism for those buffers to
   re-request at a later time). Model semantic token module here again
   by invalidating all buffers, and adding a BufWinEnter autocmd to
   refresh hints.
4. Add a mechanism to cancel in-flight requests if a new request for a
   newer document version is made before the last one returned
5. Handle stale results by simply dropping them.
2026-07-05 12:47:30 -04:00
Justin M. Keyes
e494c4777b fix(test): screen:expect() render crash masks the real failure #40593
Problem:
When screen:expect() fails, it renders a snapshot for the error
message. If the grid references a highlight id that was never defined
via "hl_attr_define", the renderer crashes:

    screen.lua:1910: attempt to index local 'entry' (a nil value)

This hides the actual failure, and appears "flaky": it only fires on the
failure path, and only when the shared screen is missing an id the grid
still references. A screen created in setup() attaches mid-session, so
highlight ids allocated before it attached (still referenced by stale
grid cells) are never sent to it.

Solution:
- Don't crash while rendering a diagnostic: show undefined highlight ids
  as "UNKNOWN_HL_ID(n)", so the real failure and the desync are legible.
- put_spec: fix `visualbell` typo. If it fails again then we can find
  the actual root cause.

ref https://github.com/neovim/neovim/issues/36250
2026-07-05 12:08:41 -04:00
Justin M. Keyes
a0fd59352a Merge #40520 nvim_win_resize 2026-07-05 12:06:13 -04:00