Commit Graph

10492 Commits

Author SHA1 Message Date
bfredl
2124ffb27b Merge pull request #39339 from bfredl/reunification
fix(build.zig): reunify parser install path
2026-04-23 15:55:52 +02:00
bfredl
d50cca5b87 fix(build.zig): reunify parser install path
Both for tests and for system wide install, $PREFIX/lib/nvim/parser
is a valid path for tree-sitter parsers. This also brings the build.zig
behavior in line with how we set up the paths in CMakeLists.txt
2026-04-23 15:37:37 +02:00
Ashley Hauck
7e006b06c4 fix(lsp): callHierarchy/outgoingCalls ranges are relative to caller, not callee #39336
Problem:
The fromRanges field of the result of callHierarchy/outgoingCalls is
documented as being relative to the caller. Using
vim.lsp.buf.outgoing_calls() opened the qflist with an entry with the
callee's filename, but the caller's line number.

Solution:
Open the qflist with the callers file (the bufnr from the request),
rather than the callees (the uri from the resulting CallHierarchyItem)
2026-04-23 08:20:58 -04:00
Barrett Ruth
ecb8402197 fix(lsp): filter code_action diagnostics to the cursor #38988
Problem:
Cursor-position `vim.lsp.buf.code_action()` requests include all diagnostics on the current line, so unrelated same-line diagnostics affect the returned actions.

Solution:
Filter same-line diagnostics to the cursor position for cursor-position requests.
2026-04-23 06:46:59 -04:00
Barrett Ruth
19ef632dec fix(terminal): memory leak in pending TermRequest StringBuilder #39333
Problem: Destroying a terminal with pending `TermRequest` events leaks
memory.

Solution: Make `emit_termrequest` the sole owner of its `pending_send`
allocation.
2026-04-23 06:31:24 -04:00
zeertzjq
313e0f9281 vim-patch:9.2.0383: [security]: runtime(netrw): shell-injection via sftp: and file: URLs
Problem:  runtime(netrw): shell-injection via sftp: and file: URLs
          (Joshua Rogers)
Solution: Escape temporary file names, harden filename suffix regex,
          drop unused g:netrw_tmpfile_escape variable

Supported by AI

405e2fb6d5

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-04-23 12:51:11 +08:00
zeertzjq
d6cdd04223 vim-patch:9.2.0367: runtime(netrw): ~ note expanded on MS Windows
Problem:  runtime(netrw): ~ note expanded on MS Windows
          (Tom Vamvanij)
Solution: Expand ~ on MS Windows (Yasuhiro Matsumoto)

On Windows, ":Explore ~" did nothing because the tilde expansion was
gated to Unix/Cygwin only.  Additionally, substitute() interprets
backslashes in the replacement string specially (e.g. \U as a case
modifier), which would corrupt $HOME values like C:\Users\name even
if the branch were taken.

Include has("win32") in the guard, anchor the pattern to the start of
the string, and escape backslashes, ampersands and tildes in $HOME
before substituting.

fixes:  vim/vim#20003
closes: vim/vim#20014

723c0acf25

Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
2026-04-23 12:51:11 +08:00
zeertzjq
b33dc7fe45 vim-patch:9.2.0302: runtime(netrw): RFC2396 decoding double escaping spaces
Problem:  runtime(netrw): RFC2396 decoding double escaping spaces
          (lilydjwg, after 3e60f03d942d6bb0f7eac)
Solution: Remove escape() call, since we are using fnameescape() anyhow

fixes: vim/vim#19913

ab4ebb62ee

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-04-23 12:51:11 +08:00
zeertzjq
06a47ac994 vim-patch:9.2.0281: tests: Test_netrw_FileUrlEdit.. fails on Windows
Problem:  tests: Test_netrw_FileUrlEdit.. fails on Windows
          (after 3e60f03d942d6bb0f7)
Solution: Skip the test on Windows (Yasuhiro Matsumoto).

The Test_netrw_FileUrlEdit_pipe_injection() test fails on Windows with
E303 because '|' is not a valid filename character on Windows.  Since
the pipe character cannot appear in a Windows filename, the command
injection vector this test guards against does not apply on Windows.

closes: vim/vim#19890

c91081d0e5

Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
2026-04-23 12:51:11 +08:00
zeertzjq
0b7f2ac405 vim-patch:3e60f03: runtime(netrw): use fnameescape() with FileUrlEdit()
3e60f03d94

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-04-23 12:51:11 +08:00
zeertzjq
1cdaa7da10 vim-patch:9.2.0089: netrw: does not take port into account in hostname validation
Problem:  netrw: does not take port into account in hostname validation
          (after v9.2.0073)
Solution: Update hostname validation check and test for an optional port
          number (Miguel Barro)

closes: vim/vim#19533

a6198523fb

Co-authored-by: Miguel Barro <miguel.barro@live.com>
2026-04-23 12:51:11 +08:00
zeertzjq
ab41543f8e vim-patch:9.2.0073: [security]: possible command injection using netrw
Problem:  [security]: Insufficient validation of hostname and port in
          netrw URIs allows command injection via shell metacharacters
          (ehdgks0627, un3xploitable).
Solution: Implement stricter RFC1123 hostname and IP validation.
          Use shellescape() for the provided hostname and port.

Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-m3xh-9434-g336

79348dbbc0

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-04-23 12:51:11 +08:00
zeertzjq
84cafb9c97 vim-patch:9.2.0037: netrw: need better tests for absolute paths
Problem:  netrw: need better tests for absolute paths
Solution: Use absolutepath(), instead of regex test (Miguel Barro).

closes: vim/vim#19477

bd1dc5b1a6

Cherry-pick a typo fix from latest Vim.

Co-authored-by: Miguel Barro <miguel.barro@live.com>
2026-04-23 12:51:11 +08:00
zeertzjq
ed12d56163 vim-patch:a2d87ba: runtime(netrw): Use right file system commands initialization for Windows
closes: vim/vim#19287
fixes:  vim/vim#12290

a2d87ba615

Co-authored-by: Miguel Barro <miguel.barro@live.com>
2026-04-23 12:51:11 +08:00
Justin M. Keyes
82198d0a66 ci: drop cirrus #39321
Problem:
cirrus will shutdown soon, and we are running out of minutes anyway,
which causes ci failures.

Solution:
Drop cirrus config.
2026-04-22 18:25:07 -04:00
altermo
451811b1be feat(treesitter): expand selection to sibling node #38938
Problem:
Can't expand treesitter-incremental-selection to the next and previous
sibling nodes.

Solution:
Pressing `]N` in visual mode will expand the selection to the next
sibling node, and `[N` will do the same with the previous node.
2026-04-22 17:10:24 -04:00
Justin M. Keyes
28ba068372 feat(:restart): v:starttime, v:exitreason #39282
Problem:
- The `ZR` feature makes it more obvious that we need some sort of flag so that
  an `ExitPre` / `QuitPre` / `VimLeave` handler can handle restarts differently
  than a normal exit. For example, it's common that users want `:mksession` on
  restart, but perhaps not on a normal exit.
- Nvim has no way to report its "uptime".

Solution:
- Introduce `v:starttime`
- Introduce `v:exitreason`
2026-04-22 13:40:41 -04:00
Barrett Ruth
fb6aeaba2d feat(eval): treat Lua string as "blob" in writefile() #39098
Problem:
vim.fn.writefile() treats Lua strings as Vimscript strings instead of a "binary clean" string.

Solution:
Treat Lua-originated strings as blob data.
2026-04-22 13:36:43 -04:00
glepnir
496374e951 fix(shada): bdelete'd buffers not stored in oldfiles #39070
Problem:
b98eefd added `!b_p_bl` to `ignore_buf()`, which also
skips bdelete'd buffers since bdelete unsets `b_p_bl`.

Solution:
Check `b_p_initialized` together with `b_p_bl` so that
bdelete'd buffers (which have b_p_initialized=false) are not
filtered out. Keep `b_p_bl` check only in `shada_get_buflist()`.
2026-04-22 13:05:41 -04:00
Yi Ming
558204d87b perf(lsp): clear table by table.clear() #39222
benchmark: https://gist.github.com/ofseed/6224529d77c016c36f7ab2f977059848

    local rounds = tonumber(arg[1]) or 1000
    local count = tonumber(arg[2]) or 1000

    -- Load the table.clear function.
    local clear = require("table.clear")

    local function fill(t, n)
      for i = 1, n do
        t[i] = i
      end
    end

    local function bench_reassign(n_rounds, n_items)
      local t = {}
      local start = os.clock()

      for _ = 1, n_rounds do
        t = {}
        collectgarbage("collect")
        fill(t, n_items)
      end

      return os.clock() - start
    end

    local function bench_reassign_no_gc(n_rounds, n_items)
      local t = {}
      local start = os.clock()

      for _ = 1, n_rounds do
        t = {}
        fill(t, n_items)
      end

      return os.clock() - start
    end

    local function bench_clear(n_rounds, n_items)
      local t = {}
      local start = os.clock()

      for _ = 1, n_rounds do
        clear(t)
        fill(t, n_items)
      end

      return os.clock() - start
    end

    -- Warm up LuaJIT before the real benchmark.
    do
      local t = {}
      for _ = 1, 2000 do
        clear(t)
        fill(t, count)
      end
    end

    collectgarbage("collect")

    local reassign_time = bench_reassign(rounds, count)
    collectgarbage("collect")

    local reassign_no_gc_time = bench_reassign_no_gc(rounds, count)
    collectgarbage("collect")

    local clear_time = bench_clear(rounds, count)

    print(string.format("rounds=%d count=%d", rounds, count))
    print(string.format("t = {} + GC   : %.6f s", reassign_time))
    print(string.format("t = {}        : %.6f s", reassign_no_gc_time))
    print(string.format("table.clear   : %.6f s", clear_time))
    print(string.format("vs + GC       : %.2fx", reassign_time / clear_time))
    print(string.format("vs no GC      : %.2fx", reassign_no_gc_time / clear_time))

benchmark result:

    rounds=1000 count=1000
    t = {} + GC   : 0.022469 s
    t = {}        : 0.002570 s
    table.clear   : 0.000387 s
    vs + GC       : 58.06x
    vs no GC      : 6.64x

`count` is how many items the table has, and `round` is how many rounds we fill
the table, clear, and then refill it. `table = {}` is clear the table by
resigning a new empty one, because this script does not run persistently like
nvim so GC is not triggered, so I added another extreme control group that
manually triggers GC.
2026-04-22 11:38:58 -04:00
luukvbaal
61fb88992d fix(cmdline): avoid 'incsearch' recursion after redraw #39303
Problem:  A vim.ui_attach() callback that redraws to show a 'verbose'
          regex message during 'incsearch' results in recusive redrawing.

Solution: Check that curwin was redrawn instead of just any window when
          determining if 'incsearch' highlighting was cleared.
2026-04-22 13:04:20 +00:00
Nick Krichevsky
e68e769352 fix(options): default 'titlestring' shows CWD #39233
Problem:
In the default 'titlestring', if the containing directory is the CWD, it renders as "."

Solution:
Add `:p` to the titlestring.
2026-04-22 05:56:23 -04:00
fleesk
e53e728c92 fix(pack): GIT_DIR/GIT_WORK_TREE env vars may interfere #39279
Problem:
With GIT_DIR/GIT_WORK_TREE set, the LSP on the vim.pack.update()
confirmation buffer does not show the correct git log on hover.

Solution:
Temporarily remove the git vars from the environment.
2026-04-22 04:46:48 -04:00
glepnir
44770bb924 fix(cmd): ++p, ++edit should match "word" boundary #39146
Problem: `:write ++patate foo` doesn't error out, instead it turns on
mkdir_p and uses "atate foo" as the filename. Same with ++edit.
The parser just does strncmp without checking what comes after.

Solution: require the next char after the option name to not be a
letter
2026-04-22 04:43:07 -04:00
zeertzjq
8f1e14ffa2 vim-patch:9.2.0356: Cannot apply 'scrolloff' context lines at end of file
Problem:  Cannot apply 'scrolloff' context lines at end of file
Solution: Add the 'scrolloffpad' option to keep 'scrolloff' context even
          when at the end of the file (McAuley Penney).

closes: vim/vim#19040

a414630393

Co-authored-by: McAuley Penney <jacobmpenney@gmail.com>
2026-04-22 10:14:52 +08:00
zeertzjq
1569a71c8a vim-patch:9.2.0385: Integer overflow with "ze" and large 'sidescrolloff' (#39289)
Problem:  Integer overflow with "ze" and large 'sidescrolloff'.
Solution: Check for overflow to avoid negative w_leftcol (zeertzjq).

closes: vim/vim#20026

33f3965087
2026-04-22 01:49:06 +00:00
zeertzjq
2445fab6fb vim-patch:9.2.0384: stale Insstart after cursor move breaks undo (#39290)
vim-patch:9.2.0384: stale Insstart after <Cmd> cursor move breaks undo

Problem:  A <Cmd> command executed from Insert mode can sync undo and
          move the cursor before the next edit. stop_arrow() saved the
          new cursor line for undo, but left Insstart at the previous
          insertion point. A line-start backspace could then delete
          lines above the saved line without saving the joined range,
          leaving a pending undo entry whose bottom resolved above
          its top and raising E340.
Solution: Update Insstart and Insstart_textlen after the pending undo
          save so the next edit starts from the command-updated cursor
          position (Jaehwang Jung).

closes: vim/vim#20031

AI-assisted: Codex

d4fb31762e

Co-authored-by: Jaehwang Jung <tomtomjhj@gmail.com>
2026-04-22 01:35:47 +00:00
Barrett Ruth
8efe4f9ac1 fix(incsearch): support c_CTRL-{G,T} with an offset (#39097)
vim-patch:9.2.0374: c_CTRL-{G,T} does not handle offset

Problem:  c_CTRL-{G,T} does not handle offset, when cycling between
          matches
Solution: Refactor parsing logic into parse_search_pattern_offset() and
          handle offsets, note: highlighting does not handle offsets
          yet (Barrett Ruth).

fixes:  vim/vim#19991
closes: vim/vim#19998

c62342e5cf
2026-04-22 01:24:49 +00:00
zeertzjq
ead1478b69 test(tui_spec): fix "Uncaught Error" with PUC Lua (#39288)
RUN      T339 TUI :restart ZR: Uncaught Error: test/client/uv_stream.lua:111: ECONNRESET
stack traceback:
	[C]: in function 'error'
	test/client/uv_stream.lua:111: in function <test/client/uv_stream.lua:109>
	[C]: in function 'run'
	test/client/session.lua:240: in function '_run'
	test/client/session.lua:216: in function '_blocking_request'
	test/client/session.lua:117: in function 'request'
	...t_xdg_terminal/test/functional/terminal/tui_spec.lua:223: in function <...t_xdg_terminal/test/functional/terminal/tui_spec.lua:215>
	[C]: in function 'pcall'
	test/testutil.lua:82: in function 'retry'
	...t_xdg_terminal/test/functional/terminal/tui_spec.lua:215: in function 'assert_restarted'
	...t_xdg_terminal/test/functional/terminal/tui_spec.lua:275: in function <...t_xdg_terminal/test/functional/terminal/tui_spec.lua:232>
	[C]: in function 'xpcall'
	/home/runner/work/neovim/neovim/test/harness.lua:693: in function 'run_callable'
	/home/runner/work/neovim/neovim/test/harness.lua:1008: in function 'run_test'
	/home/runner/work/neovim/neovim/test/harness.lua:1083: in function 'run_suite'
	/home/runner/work/neovim/neovim/test/harness.lua:1081: in function 'run_suite'
	/home/runner/work/neovim/neovim/test/harness.lua:1081: in function 'run_suite'
	/home/runner/work/neovim/neovim/test/harness.lua:1507: in function 'run_test_file'
	/home/runner/work/neovim/neovim/test/harness.lua:1577: in function 'run_iteration'
	/home/runner/work/neovim/neovim/test/harness.lua:1665: in function 'main'
	/home/runner/work/neovim/neovim/test/runner.lua:30: in main chunk
-- Tests exited non-zero: 255
CMake Error at /home/runner/work/neovim/neovim/cmake/RunTests.cmake:135 (message):
  functional tests failed with error: 255
2026-04-22 08:44:59 +08:00
luukvbaal
ff68fd6b8a fix(messages): "progress" kind for busy messages #39280
Problem:  The "Scanning:" completion, bufwrite, and indent (there may be
          more) messages which indicate progress can use the "progress" kind
          for their msg_show event. Indent message does not have a kind.

Solution: Emit these messages with the "progress" kind. Set the message id
          to the replaced kind so that a UI knows to replace it (and to provide
          a migration path in case a UI was distinguishing these messages for
          whatever reason).
2026-04-21 16:11:41 -04:00
bfredl
fe60268258 Merge pull request #39076 from bfredl/zig0.16
IT IS HAPPENING: Zig 0.16
2026-04-21 20:09:57 +02:00
Sanzhar Kuandyk
5891f2f3dc fix(:restart): reuse --listen addr on Windows #38539
Problem:
On Windows, :restart cannot immediately reuse the canonical --listen
address because named pipe release is asynchronous.

Solution:
Start the new Nvim server on a temporary address; in the new Nvim,
retry serverstart() with the original ("canonical") address until it
succeeds.
2026-04-21 12:49:16 -04:00
Justin M. Keyes
a1c8b81672 feat(normal): normal-mode ZR does :restart
Make it a normal-mode command instead of a default mapping.
2026-04-21 15:54:08 +02:00
zeertzjq
ac8459a09c fix(substitute): don't crash with very large count (#39272) 2026-04-21 11:38:15 +00:00
bfredl
52693e7af3 fix(build): more changes to make zig 0.16.0 work 2026-04-21 12:46:01 +02:00
zeertzjq
32e249dfa6 vim-patch:9.2.0371: filetype: ghostty config files are not recognized (#39267)
Problem:  filetype: ghostty config files are not recognized
Solution: Detect ghostty configuration files as ghostty filetype,
          include a simple ghostty filetype plugin (Bez Hermoso)

closes: vim/vim#20002

b30803b231

Co-authored-by: Bez Hermoso <bezalelhermoso@gmail.com>
Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-04-21 02:24:07 +00:00
zeertzjq
49d63ca548 vim-patch:9.2.0373: Ctrl-R mapping not triggered during completion (#39261)
Problem:  Ctrl-R mapping not triggered during completion.
Solution: Move Ctrl-R check out of vim_is_ctrl_x_key()
          (zeertzjq).

fixes:  vim/vim#20004
closes: vim/vim#20006

49e8630a28
2026-04-21 08:27:26 +08:00
Justin M. Keyes
4ceca862fc refactor(test): drop deprecated exc_exec #39242 2026-04-20 14:16:41 -04:00
luukvbaal
faa7c15b5a fix(ui2): don't dismiss expanded messages for non-typed key #39247
Problem:  Invalid check for non-typed key to dismiss expanded cmdline.
          Unable to delay the timer that removes a message from the msg
          window.
Solution: Check for empty string instead of nil to determine whether a
          key is typed.
          Restart the timer if it expires while the user is in the msg
          window. Allow entering the msg window with a mouse click.
2026-04-20 11:38:47 -04:00
Luuk van Baal
607fcfb37a fix(ui2): ensure msg window is visible after closing tab
Problem:  After closing a tabpage while the msg window is showing a
          message, it is hidden while the msg window still contains a
          message.
Solution: Unhide the msg window after entering a tabpage and it still
          contains a message.

Co-authored-by: Linykq <yukunlin590@gmail.com>
2026-04-20 14:20:20 +02:00
glepnir
01861c2f95 fix(api): expose fg_indexed/bg_indexed in nvim_get_hl #39210
Problem: fg_indexed/bg_indexed were dropped from nvim_get_hl output due
to a wrong short_keys guard. HL_FG_INDEXED also wasn't cleared in
hl_blend_attrs, and HLATTRS_DICT_SIZE was too small.

Solution: Remove the short_keys guard, clear HL_FG_INDEXED in
hl_blend_attrs, bump HLATTRS_DICT_SIZE to 24, and clarify docs that
these flags mean rgb is an approximation of the cterm palette index.
2026-04-20 05:12:52 -04:00
Justin M. Keyes
c7d4892ce6 Merge #39194 from justinmk/luavimfn 2026-04-20 04:23:54 -04:00
zeertzjq
2ee25ba41b vim-patch:9.2.0364: tests: test_smoothscroll_textoff_showbreak() fails
Problem:  tests: test_smoothscroll_textoff_showbreak() fails
          (after v9.2.0363)
Solution: Add missing CheckRunVimInTerminal

related: vim/vim#20011

618a327ce6

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-04-20 09:31:31 +08:00
Jaehwang Jung
79a7a4abe1 fix(smoothscroll): crash when resizing to textoff with showbreak
vim-patch:9.2.0362: division by zero with smoothscroll and small windows

Problem:  Resizing a smoothscrolled wrapped window to its textoff width
          with 'showbreak' can leave wrapped continuation lines with
          zero text width. win_lbr_chartabsize() still runs the partial max_head_vcol calculation in
          that state and divides by width2, crashing during redraw.
Solution: Skip that partial head calculation when the wrapped
          continuation width is zero, matching the other width2 guards
          in charset.c (Jaehwang Jung)

closes: vim/vim#20012

AI-assisted: Codex

0e31fb024c
2026-04-20 09:30:30 +08:00
luukvbaal
fe986e5dd0 feat(options): add 'winpinned' to pin a window #39157
Problem:
- Unable to "pin" a window to prevent closing without specifically
  being targeted.
- :fclose closes hidden windows (even before visible windows).

Solution:
- Add 'winpinned' window-local option. When set, window is skipped by
  :fclose and :only. Pin the ui2 cmdline window (which should always be
  visible), so that it is not closed by :only/fclose.
- Skip over hidden (and pinned) windows with :fclose.

Co-authored-by: glepnir <glephunter@gmail.com>
2026-04-19 20:36:55 -04:00
Justin M. Keyes
a38451be40 fix(excmd): nlua_call_excmd require() failure is a "lua_error"
Although `nlua_call_excmd` is semantically for implementing Ex-commands,
the `require()` should never fail, so that's a "Lua error".

But if the call itself fails (the later `semsg` call), that's an "Ex
cmd" error.
2026-04-20 02:31:09 +02:00
Jaehwang Jung
f2cc0a249d fix(drawline): hang while redrawing diff filler above fold #39219
Problem:
win_line() falls into infinite loop when a diff window has top filler
above its first visible buffer line, that first visible buffer line is a
closed fold, and the folded line uses normal non-empty foldtext.

Solution:
Allow flushing pending diff filler rows even when the underlying buffer
line is folded with foldtext.

AI-assisted: Codex

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2026-04-19 12:29:31 -04:00
Ashley Hauck
4b54bca3df feat(events): trigger MarkSet autocmd in :delmarks #39156
Problem:
`api.nvim_buf_del_mark` already emits a `MarkSet` event with `col` and `line` set to 0. However, `:delmarks` currently emits no events.

Solution:
Change `:delmarks` to emit the same `col==line==0` event.
2026-04-19 07:42:08 -04:00
Jan Edmund Lazo
9ded2fb7c8 vim-patch:8.2.3024: execute() function test fails
Problem:    execute() function test fails.
Solution:   Adjust test for different error.

2fb1b89d72

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2026-04-18 22:20:01 -04:00
glepnir
b351afb1b1 fix(lsp): show CompletionItem.detail in info popup #38904
Problem: completionItem/resolve response's `detail` field is silently
dropped. Only `documentation` is shown in the popup.

Solution: Prepend `detail` as a fenced code block before `documentation`
in the info popup, skipping if documentation already contains it.
2026-04-18 15:43:20 -04:00