Commit Graph

10290 Commits

Author SHA1 Message Date
Jaehwang Jung
9966afbc9d 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>
(cherry picked from commit f2cc0a249d)
2026-04-19 21:30:33 +00:00
Justin M. Keyes
43398547ec backport docs: misc (#39206)
docs: misc


(cherry picked from commit 54398c5874)
2026-04-19 12:36:19 +00:00
Ashley Hauck
15991abaa7 backport: feat(events): trigger MarkSet autocmd in :delmarks (#39218)
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 12:20:56 +00:00
Jaehwang Jung
5907307662 fix(lsp): skip codelens refresh redraw for deleted buffer #39193
Problem:
After on_refresh() sends a textDocument/codeLens request, the buffer may
be deleted before the response arrives. The response callback then tries
to redraw that deleted buffer and raises Invalid buffer id error.

Solution:
Check buffer validity before redrawing.

AI-assisted: Codex
Co-authored-by: Yi Ming <ofseed@foxmail.com>
(cherry picked from commit 97caa88972)
2026-04-18 22:34:59 +00:00
glepnir
34cbfeca9c 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.

(cherry picked from commit b351afb1b1)
2026-04-18 20:42:42 +00:00
Evgeni Chasnovski
9aadbed770 fix(lua): make vim._with() work with buf=0 and win=0 context #39151
Problem: Using `buf=0`/`win=0` context in `vim._with` should be
  equivalent to using explicit buffer/window identifier respectively.

Solution: Explicitly adjust context in case of `buf=0` or `win=0`.
(cherry picked from commit 3a4cc5db0b)
2026-04-18 20:34:47 +00:00
zeertzjq
20c6edbc12 test(tui_spec): don't run tty-test in a shell (#39186)
(cherry picked from commit 48d11681c2)
2026-04-18 12:30:01 +00:00
luukvbaal
f2a5c90cbc fix(marks): adjust marks when unloading "nofile" buffer #39118
Problem:  Marks are not adjusted unloading a buffer that doesn't exist
          on disk. E.g. extmarks are still valid (and will be beyond the
          end of the buffer if the buffer is reloaded), even though the
          text is lost.
Solution: Adjust marks for a cleared buffer when unloading a buffer that
          doesn't exist on disk.
(cherry picked from commit 68f7acaaae)
2026-04-18 11:49:58 +00:00
Evgeni Chasnovski
c6578ea28b fix(vim.filetype): match() fails if g:ft_ignore_pat is not defined #39158
Problem: Calling `vim.filetype.match({ filename = '...', buf = ... })`
  during startup results in an error due to not yet defined
  `g:ft_ignore_pat`.

Solution: Add a guard to check `g:ft_ignore_pat` related properties only
  if the variable is defined. This also allows to simplify other tests
  which did not depend on `g:ft_ignore_pat` but required it explicitly
  set to work.
(cherry picked from commit 6b9b4a1377)
2026-04-18 11:44:54 +00:00
Justin M. Keyes
55d3d1bbeb backport: test(lsp): extract buf/util parts from lsp_spec.lua (#39170)
test(lsp): extract buf/util parts from lsp_spec.lua

Problem:
`test/functional/plugin/lsp_spec.lua` had grown into a large catch-all file that mixed core LSP client lifecycle coverage, `vim.lsp.buf.*` behavior, and `vim.lsp.util.*` behavior in one place.

Solution:
Split the large tests into more focused test files without changing test coverage or intended behavior.

After this change, `lsp_spec.lua` is more focused on core LSP client/config/dynamic-registration behavior.

Co-authored-by: Yi Ming <ofseed@foxmail.com>
2026-04-18 03:01:28 +00:00
zeertzjq
d3ef77639a fix(terminal): forward streamed bracketed paste properly (#39152)
(cherry picked from commit 4eaf782bb6)
2026-04-17 23:22:18 +00:00
zeertzjq
f93561723c test: include test path in summary (#39141)
Ref: https://github.com/neovim/neovim/pull/38486#discussion_r3088483987
(cherry picked from commit fefad0721a)
2026-04-17 14:08:02 +00:00
zeertzjq
e4dc08da1a fix(completion): update CursorColumn during completion (#39159)
Since Nvim uses a compositor, redrawing windows won't lead to flicker in
the popup menu, so the pum_visible() checks in move.c can be removed.

(cherry picked from commit 724fccd46f)
2026-04-17 13:45:21 +00:00
altermo
111c7f434e fix(treesitter): TSNode:id() with NUL byte causes unreliable select() #39134
Problem:
`TSNode:id()` returns the underlying c pointer as a string, which may include
NUL bytes. In PUC Lua, `('%s'):format('\0a\0')` returns `''` and not `'\0a\0'`
(i.e. treats the string as a c-string (which terminates at the NUL byte)).

This resulted in two different nodes being able to have the same id.

Solution:
Use concatenation `..` instead of `string.format()`.

(cherry picked from commit bb2284d75e)
2026-04-16 22:48:50 +00:00
luukvbaal
b08c289a45 fix(ui2): dialog paging is inconsistent #39128
Problem:  - Paging keys in the dialog window consume input when the user
            may not expect it. The dismissable title hint intended to
            mitigate that results in having to press Escape twice to
            abandon the prompt.
          - Mimicked "msgsep" float border is taking up unnecessary
            space when window takes up the entire screen.

Solution: - Use (conventional, albeit less convenient) keys intended
            for scrolling to page the dialog window:
            <(Mousewheel/Page)Up/Down>, <Home/End>.
          - Only set the float top border when separation is actually
            necessary, i.e. window does not reach the first row.
(cherry picked from commit f0a8e6f337)
2026-04-16 21:01:25 +00:00
Evgeni Chasnovski
5f23c0a1cf test(pack): increase retry timeout for startup test #39125
Problem: Unreliable test on Windows which sometimes fails with too many
  failed retries.

Solution: Increase timeout in hopes that it will be enough to make it
  pass more frequently. This should not affect fast and already working
  platforms.
(cherry picked from commit df6a0827fb)
2026-04-16 15:18:20 +00:00
Barrett Ruth
2ea9ed32e4 fix(treesitter): restore highlighting on 32 bit systems #39091
Problem: Treesitter highlighting regressed on 32-bit builds because ranges that should cover the whole buffer were corrupted when passed into Lua.

Solution: Round-trip those range values through Lua and validate them so treesitter sees the same ranges on 32 and 64-bit builds.
(cherry picked from commit 3838a2579e)
2026-04-16 08:39:41 +00:00
zeertzjq
9c11229832 vim-patch:9.2.0357: [security]: command injection via backticks in tag files (#39102)
Problem:  [security]: command injection via backticks in tag files
          (Srinivas Piskala Ganesh Babu, Andy Ngo)
Solution: Disallow backticks before attempting to expand filenames.

Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-cwgx-gcj7-6qh8

Supported by AI

c78194e41d

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 0e07b2a1e2)
2026-04-16 03:33:53 +00:00
Justin M. Keyes
099489b985 backport: refactor: update usages of deprecated "buffer" param #39090 2026-04-15 19:46:07 +00:00
Justin M. Keyes
94f6cbb8bb Merge #39088 test: replace busted with local harness 2026-04-15 14:47:12 -04:00
Justin M. Keyes
df0f88a5a9 refactor(api): rename "window" to "win" (positional parameters) #39083
continues d0af4cd909.

This commit renames positional parameters. This is only "cosmetic", but
is intended to make it extra clear which name is preferred, since people
often copy existing code despite the guidelines in `:help dev-naming`.

(cherry picked from commit 71ac4db335)
2026-04-15 18:12:34 +00:00
Lewis Russell
11d0e7e5fc test: replace busted with local harness
Replace the busted-based Lua test runner with a repo-local harness.

The new harness runs spec files directly under `nvim -ll`, ships its own
reporter and lightweight `luassert` shim, and keeps the helper/preload
flow used by the functional and unit test suites.

Keep the file boundary model shallow and busted-like by restoring `_G`,
`package.loaded`, `package.preload`, `arg`, and the process environment
between files, without carrying extra reset APIs or custom assertion
machinery.

Update the build and test entrypoints to use the new runner, add
black-box coverage for the harness itself, and drop the bundled
busted/luacheck dependency path.

AI-assisted: Codex
(cherry picked from commit 55f9c2136e)
2026-04-15 19:47:10 +02:00
Lewis Russell
0039785724 fix(lua): make vim.deep_equal cycle-safe
AI-assisted: Codex
(cherry picked from commit e289f9579c)
2026-04-15 19:43:25 +02:00
Lewis Russell
243a5ac5fd test(vterm): retain ffi callback structs
AI-assisted: Codex
(cherry picked from commit 08ecb3a734)
2026-04-15 19:43:25 +02:00
zeertzjq
d672f0f494 vim-patch:partial:9.2.0348: potential buffer underrun when setting statusline like option (#39063)
Problem:  potential buffer underrun when settings statusline like option
          (q1uf3ng)
Solution: Validate that p > out before accessing p[-1]

closes: vim/vim#19961

91b402f575

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit e0eb967f8a)
2026-04-15 00:52:51 +00:00
zeertzjq
8ba79b4601 vim-patch:9.2.0345: Wrong autoformatting with 'autocomplete' (#39060)
Problem:  Wrong autoformatting with 'autocomplete'.
Solution: Don't trigger autoformatting when ending autocompletion
          without selecting an item (zeertzjq).

fixes:  vim/vim#19954
closes: vim/vim#19970

efbd482116
(cherry picked from commit 65680f59d1)
2026-04-15 00:15:27 +00:00
Barrett Ruth
d86d9759e5 fix(gf): handle local file: URI paths #38915
Problem:
`gf` and `<cfile>` treat `file:/absolute/path` as a literal path and
open `file:/...` instead of the local file.

Solution:
Strip the local `file:` prefix before path resolution in the hyperlink
path code.

(cherry picked from commit e827c3b648)
2026-04-14 23:40:16 +00:00
Justin M. Keyes
465aa2af1d test: n.rmdir() save-and-restore CWD #39048
(cherry picked from commit faad7c73ac)
2026-04-14 16:18:05 +00:00
Evgeni Chasnovski
843cfd7295 test(pack): use n.rmdir() to delete directories #39046
Problem: using `vim.fs.rm(dir_path, { force = true, recursive = true })`
  can result in an error on Windows if the process has a handle to it.

Solution: Use `n.rmdir()` helper in cases when its possible side effects
  (like changing working directory) does not matter.
(cherry picked from commit b8a24bfadf)
2026-04-14 14:33:53 +00:00
luukvbaal
4a18c05f87 fix(cmdline): avoid Ex-mode NULL cmdline_block event #39043
Problem: Attempting to emit cmdline_block event with NULL cmdbuff after
<C-\><C-N> in Ex-mode.

Solution: Don't emit cmdline_block event when cmdbuff is NULL.
(cherry picked from commit f0f9620b38)
2026-04-14 14:02:14 +00:00
Justin M. Keyes
570d8fd128 backport: feat(api): rename buffer to buf in retval #39015
In 3a4a66017b, 4d3a67cd62
we renamed "buffer" to "buf" in dict parameters.

This commit also renames such keys in dict return-values.
2026-04-13 18:38:44 -04:00
zeertzjq
aac55faa2c test(terminal/channel_spec): wait some time for shell to start (#38995)
Problem:
The retry on Windows doesn't seem to actually work, as the test still
occasionally fails on Windows. Meanwhile the test can fail on Linux as
well:

FAILED   test/functional/terminal/channel_spec.lua @ 123: chansend sends lines to terminal channel in proper order
test/functional/terminal/channel_spec.lua:131: retry() attempts: 1
test/functional/terminal/channel_spec.lua:134: Failed to match any screen lines.
Expected (anywhere): "echo "hello".*echo "world""
Actual:
  |^ech$ o "hello"                                                                                      |
  |echo "world"                                                                                        |
  |hello                                                                                               |
  |$ world                                                                                             |
  |$                                                                                                   |
  |                                                                                                    |
  |                                                                                                    |
  |                                                                                                    |
  |                                                                                                    |
  |                                                                                                    |
  |                                                                                                    |
  |                                                                                                    |
  |                                                                                                    |
  |                                                                                                    |
  |                                                                                                    |
  |                                                                                                    |
  |                                                                                                    |
  |                                                                                                    |
  |term://~/work/neovim/neovim/build/Xtest_xdg_terminal//32516:sh [-]                                  |
  |                                                                                                    |

Solution:
Use a wait before the chansend() instead.

(cherry picked from commit b081cc3aeb)
2026-04-12 23:29:14 +00:00
Lars Debor
6250019537 fix(lsp): show_document can't position cursor past EOL in insert-mode #38566
Problem: vim.lsp.util.show_document insert mode is unable
to set the cursor after the target character position if the target character
is at end of line.

Solution: Move cursor after the target character (in append position)
in this case.

(cherry picked from commit 891bb0e6ce)
2026-04-12 16:40:51 +00:00
glepnir
38be4475c6 fix(pum): info float width grows on reselect with 'linebreak' #38680
Problem: win_linetabsize() includes wrap overhead from 'linebreak'
based on current window width, but the result sizes the window,
causing a feedback loop.

Solution: Temporarily set w_view_width to Columns before measuring.
(cherry picked from commit fcdb148437)
2026-04-12 16:33:50 +00:00
Emilv2
fe09c71c34 fix(lsp): send didOpen on save to all clients+groups #37454
Problem: _get_and_set_name edits the name for the whole group,
thus only one client per group gets the didOpen message.

Solution: move the logic to _changetracking and loop over every
client per group.

(cherry picked from commit 37eb1b9979)
2026-04-12 15:20:42 +00:00
glepnir
4053141cb3 fix(api): nvim_get_hl drops groups defined with link_global #38492
Problem: hlgroup2dict passes &ns_id to ns_get_hl twice. The first call
(link=true) sets *ns_hl = 0 when link_global is set, so the second call
and the sg_cleared guard both see ns_id == 0 and bail out. The group is
silently dropped from the result.

Solution: use a temporary copy of ns_id for each ns_get_hl call so the
original value is preserved.

(cherry picked from commit 49086862fc)
2026-04-12 13:50:40 +00:00
Barrett Ruth
452a9b895c fix(normal): pass count to 'keywordprg' as arg1 #38965
Problem:
If `'keywordprg'` begins with `:`, `3K` turns the count into an Ex
range. Commands that don't support that then fail. Vim passes the count
as the first arg (see #19436, vim/vim#10745).

Solution:
Pass `[count]` as the first arg for `'keywordprg'`.

(cherry picked from commit 6e95d1ad13)
2026-04-12 13:12:00 +00:00
glepnir
36bade7efb fix(highlight): preserve inherited colors when update=true breaks links #38750
Problem: Breaking a link with update=true loses colors inherited from
the linked group.

Solution: Copy color indices from the linked group so inherited colors
remain visible in :hi output.

(cherry picked from commit 01567ad4f6)
2026-04-11 15:36:14 +00:00
zeertzjq
e203257fff vim-patch:9.2.0331: spellfile: stack buffer overflows in spell file generation (#38948)
Problem:  spell_read_aff() uses sprintf() into a fixed-size stack buffer
          without bounds checking. store_aff_word() uses STRCAT() to
          append attacker-controlled strings into newword[MAXWLEN] without
          checking remaining space. Both are reachable via :mkspell with
          crafted .aff/.dic files (xinyi234)
Solution: Replace sprintf() with vim_snprintf() in spell_read_aff().
          Replace STRCAT() with STRNCAT() with explicit remaining-space
          calculation in store_aff_word().

closes: vim/vim#19944

07faa961a0

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 4f7b6083e5)
2026-04-11 00:01:47 +00:00
zeertzjq
1b36b75832 fix(messages): truncate warning messages only in display (#38901)
For now, add a private "_truncate" flag to nvim_echo, using a truncation
method similar to showmode().

(cherry picked from commit 9c5fba5df0)
2026-04-09 04:31:49 +00:00
Justin M. Keyes
ed47b27ad4 backport: feat(api): rename buffer to buf (#38899)
feat(api): rename buffer to buf

Problem:
`:help dev-name-common` states that "buf" should be used instead of
"buffer" but there are cases where buffer is mentioned in the lua API.

Solution:
- Rename occurrences of "buffer" to "buf" for consistency with the
  documentation.
- Support (but deprecate) "buffer" for backwards compatibility.

Co-authored-by: Jordan <46637683+JordanllHarper@users.noreply.github.com>
2026-04-09 01:23:13 +00:00
Sean Dewar
8669e34bba fix(api): nvim_clear_autocmds() "event" type check
Problem: nvim_clear_autocmds() does not type check "event" correctly.

Solution: fix it.
2026-04-08 23:19:13 +01:00
Sean Dewar
b28e5e4898 docs(api): nvim_exec_autocmds() default "pattern"
Problem: nvim_exec_autocmds() documentation incorrectly describes the default
for "pattern" as *, when it's actually the current file name (like :doautocmd).

Solution: correct it. Add a test.
2026-04-08 23:19:13 +01:00
Justin M. Keyes
cc0a4a653c Merge pull request #38894 backports 2026-04-08 18:12:01 -04:00
glepnir
7ffee0dfbf fix(lsp): apply_text_edits causes unwanted BufDelete events #38778
Problem:
Since 2f6d1d3c88, `apply_text_edits`
unconditionally sets `buflisted=true`, causing spurious BufDelete events
if plugins restore the original 'buflisted' state on unlisted buffers:
65ef6cec1c/src/nvim/option.c (L2159-L2169)

Solution:
- Don't set 'buflisted' in `apply_text_edits`. Set it more narrowly, in
  `apply_workspace_edit` where the semantics requires affected buffers
  to be visible to the user.
- Also skip setting 'buflisted' if it would not be changed, to avoid
  redundant `OptionSet` events.

(cherry picked from commit 6473d007e7)
2026-04-08 21:58:27 +00:00
ngicks
78234f2d54 feat(vim.version): add __eq to vim.VersionRange #38881
Problem: vim.VersionRange had no __eq metamethod, so comparing 2 distinct
but same value instances always returned false. In vim.pack.add this caused
redundant lockfile rewrites, even when the resulting lockfile content was
unchanged.

Solution: Add __eq metamethod on vim.VersionRange
2026-04-08 23:26:03 +02:00
neovim-backports[bot]
df726644b8 fix(lsp): check filetype registry in health (#38885)
fix(health): misleading warnings re filetypes registered w/ vim.filetype.add() #38867

Problem:
`:checkhealth vim.lsp` validates configured filetypes against
`getcompletion('', 'filetype')`. This only reflects runtime support
files.

This causes false warnings in `:checkhealth vim.lsp` for configured
filetypes that are known to the Lua filetype registry, including
values added with `vim.filetype.add()` and built-in registry-only
filetypes.

Solution:
Build the healthcheck's known-filetype set from both
`getcompletion('', 'filetype')` and `vim.filetype.inspect()`.

(cherry picked from commit 20a3254ad4)

Co-authored-by: Barrett Ruth <62671086+barrettruth@users.noreply.github.com>
2026-04-08 17:24:15 -04:00
Maria Solano
c76bbd0a54 fix(diagnostics)!: restore is_pull namespace argument #38698
Problem:
The current LSP diagnostic implementation can't differ between a pull
diagnostic with no identifier and a set of diagnostics provided via push
diagnostics.

"Anonymous pull providers" are expected by the protocol https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnosticOptions
, depending on how the capability was registered:
- Dynamic registrations have an identifier.
- Static registrations will not.

Solution:
Restore the `is_pull` argument removed in
https://github.com/neovim/neovim/pull/37938, keeping the identifier of
pull diagnostic collections.

(cherry picked from commit 665ebce569)
2026-04-08 20:46:16 +00:00
luukvbaal
5ac95da8ea fix(statusline): no window-local highlights for last line 'ruler' #38879
Problem:  When the 'ruler' is in the last line of the screen, it takes
          local highlight definitions of the current window, tripping an
          assert (since c1648cf8).
Solution: Don't use window-local highlight definitions when the ruler is
          not part of a statusline.

Co-authored-by: glepnir <glephunter@gmail.com>
(cherry picked from commit b35a2e58e9)
2026-04-08 16:39:56 +00:00
glepnir
ca0e3818c0 fix(pum): crash with 'pumborder' and wide item (#38852)
Problem: pum_col goes negative when item width + border exceeds screen.

Solution: account for border_width in pum_compute_horizontal_placement()
instead of adjusting pum_col after the fact

(cherry picked from commit 8603fc9180)
2026-04-08 01:49:56 +00:00