10588 Commits

Author SHA1 Message Date
zeertzjq
c8dbb04da9 vim-patch:9.2.0510: setline() mapping may trigger autoindent (#39961)
Problem:  setline() insert mode mapping may trigger autoindent,
          corrupting the newly inserted line content (Evgeni Chasnovski)
Solution: Only strip autoindent whitespace when the rest of the line is
          all whitespace (glepnir).

fixes:  vim/vim#19363
closes: vim/vim#20290

e3dedac77b

Co-authored-by: glepnir <glephunter@gmail.com>
2026-05-23 08:57:36 +08:00
zeertzjq
7a1bad27ca vim-patch:9.2.0513: [security]: memory safety issues in spellfile.c (#39960)
Problem:  [security]: memory safety issues in spellfile.c
          (tacdm)
Solution: Add recursion limit to read_tree_node(), add length limit
          check in tree_count_words(), use alloc_clear() in
          spell_read_tree().

Github Security Advisory:
https://github.com/vim/vim/security/advisories/GHSA-3h95-3962-mmvf

25e4e46c58

Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 00:51:47 +00:00
Luuk van Baal
b58ce1ab79 fix(statusline): no cmdline ruler for autocommand window
Problem:  Cmdline ruler may be drawn for autocommand window.
Solution: Check that the current window is not an autocommand window
          when deciding whether to draw the ruler.
2026-05-22 17:54:24 +02:00
Justin M. Keyes
b576807410 Merge #39939 from marcuscaisey/lsp-completion-details 2026-05-22 04:39:55 -04:00
zeertzjq
dee602e659 vim-patch:9.2.0508: completion: cannot complete user cmd :K with 'ignorecase' (#39944)
Problem:  completion: cannot complete user cmd :K with 'ignorecase'
          (rendcrx)
Solution: Skip the short-circuit when 'ignorecase' is set
          (Yasuhiro Matsumoto)

The set_cmd_index() short-circuit for the :k command treats ":k<X>" as
":k {X}" (mark argument), which makes ":kz<Tab>" never reach the
command-name expansion path. With 'ignorecase' the same prefix on other
letters (":gz<Tab>") completes a user command like :Gz, so the result is
inconsistent. Skip the short-circuit when 'ignorecase' is set; default
behaviour is preserved so the existing :k tests still pass.

fixes:  vim/vim#20241
closes: vim/vim#20275

b54e57ee54

Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
2026-05-22 08:07:55 +08:00
Marcus Caisey
c75365d22a refactor(lsp): centralise complete item info generation logic
Problem:
The logic for generating the complete item `info` is spread across
`_lsp_to_complete_items`, the `CompleteChanged` event handler, and
`CompletionResolver:request`. This has previously caused the `info`
shown for resolved (via `completionItem/resolve`) and unresolved items
to differ.

Solution:
Centralise the logic in a new `complete_item_info` function which is now
solely responsible for determining:
1. The `info` to show.
2. The markup kind of the `info`.
3. Whether the `info` is complete.

This simplifies the interaction between the 3 functions mentioned in the
problem:
- `_lsp_to_complete_items` calls `complete_item_info` and passes along
  the markup kind and whether the item needs resolving via the complete
  item's `user_data`.
- The `CompleteChanged` consumes the markup kind and whether the
  item needs resolving from the complete item's `user_data`.
- `CompletionResolver:request`, like `_lsp_to_complete_items` calls
  `complete_item_info` again and updates the current `info` if it's
  changed.
2026-05-21 18:22:13 +01:00
Marcus Caisey
d6d03716cf fix(lsp): show detail in popup when server can't completionItem/resolve
Problem:
`CompletionItem.detail` is only shown in the info popup if the server
supports `completionItem/resolve`.

Solution:
If the server doesn't support `completionItem/resolve`, prepend the
complete item `info` with `CompletionItem.detail` in a fenced codeblock,
same as we do when the server supports `completionItem/resolve`.

To ensure that completion items are displayed in the same way,
regardless of whether the server supports `completionItem/resolve`, i've
extracted out the test logic from the `selecting an item triggers
completionItem/resolve + (snippet) preview` case so that we can run the
same tests against a server which supports `completionItem/resolve` and
one which doesn't. Hopefully this should prevent the two behaviours
diverging again.
2026-05-21 18:22:13 +01:00
Marcus Caisey
ce7df01391 fix(lsp): resolve CompletionItem if resolvable fields aren't populated
Problem:
If `CompletionItem.documentation` is populated but `detail` is not, then
`detail` is not resolved.

Solution:
Ensure that we resolve a `CompletionItem` if either `detail` or
`documentation` are not populated.

I've also removed `detail` from the popup menu since otherwise it will
be populated in both the popup menu and the info popup after the
`CompletionItem` has been resolved. I think the info popup is the best
place for it anyway as when there is a completion item with a long popup
menu entry (when `detail` is a medium/long function signature for
instance), the whole popup menu gets widened and this steals horizontal
space that could be used to display the `documentation`. Now with
`detail` and `documentation` in the info popup, they share the same
horizontal space. This also aligns with how VSCode, nvim-cmp, blink.cmp,
and mini.nvim display `detail`.
2026-05-21 18:15:14 +01:00
Marcus Caisey
10a53e7637 fix(lsp): generate snippet preview from resolved textEdit.newText
Problem:
When a resolved `CompletionItem` with kind `Snippet` populates
`textEdit` instead of `insertText`, the contents are not previewed.

Solution:
Generate the snippet preview from `textEdit.newText` as well.
2026-05-21 17:47:08 +01:00
glepnir
26df751add fix(float): :bufdelete in floatwin may change focus #39858
Problem:
(Followup to 54f22a8f01c0feb27a531b52aedf5cdbd5e51b24.)
Deleting another buffer from a floatwin could move focus into the holder
window and fire BufEnter for the buffer being deleted.

Solution:
Use switch_win_noblock() instead of buf_jump_open_win() before
recursing into do_buffer_ext().
2026-05-21 05:06:50 -04:00
Justin M. Keyes
9aa4608401 refactor: introduce nvim_on internally #39883
Problem:
`nvim_create_autocmd` is too verbose and its `callback` requires extra
"nesting".

Solution:
Introduce `nvim_on`. Start using it internally. Then we can get a feel
for how it should look before making it public.
2026-05-20 17:33:01 -04:00
Justin M. Keyes
799cbfff85 fix(vim.secure): read() command injection vulnerability #39918
Problem:
Malicious filename can execute code because of ":" cmdline expansion.

Solution:
Use `fnameescape()`.

fix https://github.com/neovim/neovim/issues/39914
2026-05-20 15:27:43 -04:00
Natanael Copa
584dfdb76d fix(test): support multiple --filter-out #39885
fixes regression introduced in commit 55f9c2136e (test: replace busted
with local harness)
2026-05-20 09:03:45 -04:00
luukvbaal
53da0c5060 fix(messages): avoid recursive rtp build due to msg_show #39888
Problem:  If there are pending messages when starting to build the
          runtime search path, a msg_show callback may invoke
          runtime_search_path_validate() recursively.
Solution: Avoid msg_show callback by ensuring messages are flushed.
2026-05-20 08:13:41 -04:00
Matei Stroia
526ae1cc1b fix(fold): virtual lines duplicate foldopen (#39891)
Problem:
Virtual lines above a line where a fold starts show `foldopen` in
`foldcolumn`.

Solution:
Check if the line below the virtual one is inside a fold that starts
higher up or if it's the start of a fold. In the latter case, don't show
anything in `foldcolumn` for the virtual line.

refactor: lint
2026-05-20 19:56:39 +08:00
Olivia Kinnear
f0c3cc2398 fix(pack): collect "Removed plugin" into one message #39840 2026-05-20 06:45:05 -04:00
Justin M. Keyes
1f75fef951 Merge #39889 from ofseed/pos-util
refactor(pos,range): drop `to_cursor`, extract `vim.pos._util`
2026-05-20 05:35:09 -04:00
Yi Ming
b1c1f32089 refactor(pos,range): extract vim.pos._util
Problem:
- To share logic, creating a `vim.Range` currently creates two `vim.Pos` values
  as intermediates, which causes unnecessary table allocations.
- `pos.lua` and `range.lua` contain some overlapping logic.

Solution:
Add `vim.pos._util`, a module for handling
positions represented directly by `row` and `col`.
2026-05-20 16:23:03 +08:00
Barrett Ruth
5181984db9 fix(api): nvim_exec_autocmds({buf=x}) runs in buffer context #39061
Problem: `nvim_exec_autocmds({ buf = ... })` matches the target buffer, but callbacks and modelines run with the caller buffer current rather than the target buffer.

Solution: Execute the buffered path in prepared target-buffer context and restore the caller afterward.
2026-05-20 03:48:55 -04:00
zeertzjq
3bc21c0903 vim-patch:9.2.0502: runtime(netrw): bookmark handling can be improved (#39900)
Problem:  To goto or delete a bookmark, one needs to prefix a count
          for the bookmark number (e.g., "2gb" to open bookmark#2).
          As the bookmark list gets or deletes entries, the numbers
          keep changing, requiring listing the bookmarks with qb to
          discover the desired bookmark number. Typing gb or mB
          without a count targets g:netrw_bookmarklist[-1].
Solution: If no count is given to gb or mB, list all bookmarks and
          prompt for a number using inputlist(), similar to tag jump
          with g].

closes: vim/vim#20211

35b767a090

Co-authored-by: J. Paulo Seibt <jpseibt@gmail.com>
2026-05-20 01:12:12 +00:00
Nick Krichevsky
24f7182390 fix(mouse): mouse=n should not adjust visual selection
Problem:

When mouse=n is set
  - Dragging the mouse enters visual mode, and then stops listening for
    mouse events.
  - Double/Triple/Quad clicking performs selections.
  - Clicking in visual mode moves the cursor (though not through the TUI).

Solution:

Explicitly gate mouse actions that affect visual mode with a check for
MOUSE_VISUAL. This matches the behavior described in :help mouse.

> If enabled for "v" (Visual mode) then double-click selects word-wise,
> triple-click makes it line-wise, and quadruple-click makes it
> rectangular block-wise.
2026-05-19 11:45:56 +02:00
Barrett Ruth
353d2a4e4a feat(normal): lines textobject "il", "al" #39845
`al` to select the whole buffer linewise.
`il` to select the current line without surrounding whitespace.
2026-05-19 05:08:23 -04:00
zeertzjq
f3bb21e71d vim-patch:9.2.0500: filetype: some html files wrongly recognized as htmlangular (#39880)
Problem:  filetype: some html files are wrongly recognized as htmlangular
Solution: Use the \< atom to anchor ng-template and ng-content to start
          of word (truffle)

Prevent false-positive htmlangular detection on words containing
'ng-template' or 'ng-content' as a substring (e.g. 'song-template',
'sing-content'). Anchor both branches with \< to require a word start,
matching the \<DTD\s\+XHTML\s idiom used five lines below.

related: neovim/neovim#39778.
closes:  vim/vim#20246

354ab1a69e

Co-authored-by: truffle <truffleagent@gmail.com>
2026-05-19 08:42:05 +08:00
glepnir
450ba41436 fix(api): adjust Visual position after nvim_buf_set_text #30690
Problem:
Visual selection could end up in the wrong place after
nvim_buf_set_text or nvim_buf_set_lines. In some delete cases,
Visual.lnum was already clamped before the line shift happened, so the
adjustment got skipped.

Solution:
Split fix_cursor_cols into reusable fix_pos_col logic and reuse it
for Visual updates. Also adjust Visual.lnum before changed_lines so
the shift uses the original position before final clamping.
2026-05-18 13:08:26 -04:00
Justin M. Keyes
d8ec793379 Merge #39822 from ofseed/pos-mark
feat(pos,range): pos:to_mark(), pos.mark(), range:to_mark(), range.mark()
2026-05-18 10:45:21 -04:00
Yi Ming
ff43f1950e feat(lsp)!: deprecate vim.lsp.util.character_offset() 2026-05-18 22:19:07 +08:00
Yi Ming
856bc6d284 fix(range): handle inclusive/exclusive positions on multibyte characters 2026-05-18 22:19:07 +08:00
Justin M. Keyes
b20fa21ac5 Merge #39832 from justinmk/doc2
docs: misc, remove legacy/textobjects_spec.lua
2026-05-18 09:25:05 -04:00
bfredl
e932d6ff17 fix(api): regressions with lua return values #39837
fixes #39834
fixes #39833
fixes #39851
2026-05-18 09:05:49 -04:00
zeertzjq
7b46848f14 vim-patch:9.2.0494: User commands cannot handle single args with spaces (#39854)
Problem:  User commands cannot handle single args with spaces
Solution: Add the -nargs=_ attribute (Maxim Kim)

-nargs=_ allow user commands to have a single argument with spaces.

For example given the following Test command and TestComplete function:

```
vim9script
def TestComplete(A: string, _: string, _: number): list<string>
    var all = ["qqqq", "aaaa", "qq aa"]
    return all->matchfuzzy(A)
enddef
command! -nargs=_ -complete=customlist,TestComplete Test echo <q-args>
```

`:Test q a<tab>` should successfully complete `qq aa`

fixes:  vim/vim#20102
closes: vim/vim#20189

f0e874a129

Co-authored-by: Maxim Kim <habamax@gmail.com>
2026-05-18 17:44:26 +08:00
glepnir
3ffe29d679 fix(lsp): preserve trigger chars on completion #39850
Problem:
After 767fbd8, typing trigger chars would open completion but the
chars were removed.

Solution:
Use filterText fallback so selected item respects typed trigger chars.
2026-05-18 05:25:41 -04:00
Justin M. Keyes
920fcaeeb7 test: remove legacy/textobjects_spec.lua
It is redundant with `test/old/testdir/test_textobjects.vim`.
2026-05-18 11:20:26 +02:00
zeertzjq
878718fa76 vim-patch:9.2.0496: [security]: Code Injection in cucumber filetype plugin
Problem:  [security]: Code Injection in cucumber filetype plugin
          (Christopher Lusk)
Solution: Use rubys Regexp.new() with the untrusted pattern

Github Security Advisory:
https://github.com/vim/vim/security/advisories/GHSA-4473-94jm-w5x9

a65a52d684

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-05-18 08:11:18 +08:00
zeertzjq
a7d3835cb9 vim-patch:9.2.0495: [security]: runtime(netrw): code injection via NetrwBookHistSave()
Problem:  [security]: runtime(netrw): code injection via
          NetrwBookHistSave()
Solution: Properly quote the directory name using string() function
          (Srinivas Piskala Ganesh Babu)

Github Security Advisory:
https://github.com/vim/vim/security/advisories/GHSA-crm5-rh6j-2c7c

f08ab2f4d7

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-05-18 08:11:18 +08:00
Kyle
84d5c5f4bf feat(tui): $NVIM_TERMDEFS can override builtin terminfo #39555
Problem:
- Windows users can't use terminfo to configure their terminal
  capabilities. #37274
- Terminfo definitions sometimes get out of date or are simply
  inaccurate.
- Eventually, we may want to drop terminfo, relying primarily on
  built-in definitions. Users will still need some flexibility.

Solution:
Support $NVIM_TERMDEFS environment variable, which is JSON data that
defines "terminfo" definitions that override our builtin terminfo.
2026-05-17 13:02:46 -04:00
Puneet Dixit
fff9897ce3 fix(startup): emitting useless OptionSet #39830
Problem:
During startup, we manually trigger a useless and misleading `OptionSet`
event, which doesn't set `v:option_*` values (this is a limitation of
`nvim_exec_autocmds`).
ad4bc2d90c/runtime/lua/vim/_core/defaults.lua (L939).

Solution:
The `nvim_exec_autocmds('OptionSet',…)` call does not serve any purpose
since 5cbb9d613b, so just drop it.
2026-05-17 12:18:24 -04:00
glepnir
767fbd88ff fix(lsp): fallback to filterText for non-matching PlainText items #39695
Problem:
PlainText completion items used `textEdit.newText` or `insertText` as
the completion word even when they did not match the typed prefix. This
could break popup completion behavior like 'completeopt+=longest'.

Solution:
Fall back to `filterText` when `newText` or `insertText` does not match
the typed prefix.
2026-05-17 11:58:49 -04:00
Justin M. Keyes
a562fb33ca Merge #39820 from echasnovski/pack-get-more 2026-05-17 11:51:39 -04:00
Justin M. Keyes
846b8b2420 refactor: group nvim_buf_call, nvim_win_call tests #39828 2026-05-17 11:20:54 -04:00
Evgeni Chasnovski
8f379be261 feat(pack): update get() to be able to fetch data from plugin source
Problem: There is currently no convenient way to programmatically check
  for new updates from plugin source. Running `vim.pack.update()` is one
  approach, but it opens a confirmation buffer that requires a manual
  action to close.

Solution: Add `opts.offline` to `vim.pack.get()` that will first fetch
  new updates from plugin source before computing the output.
2026-05-17 18:17:13 +03:00
Evgeni Chasnovski
b9c4329c35 feat(pack): update get() to return revision of a pending update
Problem: No convenient way to programmatically get the revision that
  would be checked out after `vim.pack.update()` (with `offline=true`).
  Doing this manually requires resolving `spec.version` which is not
  trivial.  This data can be useful for custom reporting of pending
  updates or third party confirmation step.

Solution: Make `get()` include a new field for the revision that points
  at the state after applying pending update. This is also the same as
  the revision of resolved `spec.version`.
2026-05-17 18:14:01 +03:00
Barrett Ruth
38c18ad3a8 fix(vimscript): normalize multi-slash heads in fnamemodify() #39805
Problem: `fnamemodify(..., ':h')` mishandles POSIX leading slash runs longer than `//`.

Solution: Collapse those slash runs to `/` before computing the head.
2026-05-17 10:54:59 -04:00
bfredl
0aa7d2f4d5 feat(api): nvim_buf_call, win_call can has multiple return values #39801
from the "because we can and it is not much code" department. (diffcount
excluding tests is actually negative)

fixes https://github.com/neovim/neovim/issues/39636#issuecomment-4397141270
2026-05-17 10:25:22 -04:00
Justin M. Keyes
e572c9c80a feat(api): tab-local option scope #39811
Problem:
2d795face6 added support for tab-local options ('cmdheight')
to `nvim_get_option_value`, but not to:

    nvim_get_option_info2()
    nvim_set_option_value(…, { tab = … })
    gettabwinvar()

Solution:
- Update `options.lua` to model tab-local options. Introduce `kOptScopeTab`.
- Handle tab scope in the options layer so it works for all options APIs.

Note:
- No change to `gettabvar()`. Not sure if needed/wanted.

fix https://github.com/neovim/neovim/issues/31140
2026-05-17 10:24:46 -04:00
Justin M. Keyes
c55b6128f8 docs: misc #39817 2026-05-17 10:02:12 -04:00
Ayose C.
3ace049c6a feat(vim.hl): vim.hl.hl_op() #39777
Problem:
vim.hl.on_yank() only works for TextYankPost, not TextPutPost.

Solution:
Introduce hl_op().
Deprecate on_yank().
2026-05-17 09:56:37 -04:00
Evgeni Chasnovski
8d100483e0 feat(pack): update get() to take rev from actual repo if info=true
Problem: `vim.pack.get()` always uses lockfile as the source for the
  `rev` field. This is fast, but may be misleading in case of
  a corrupted lockfile.

Solution: Compute revision from Git repo on disk if `info=true`
  (default), use lockfile otherwise. This does increase execution time
  (as a result of one extra `git ...` call for every plugin), but
  `info=true` is already designed to be informative and not necessarily
  fast.
2026-05-17 10:49:48 +03:00
yashlala
7d99104058 feat(events): add TabMoved autocommand event #24137
Problem:
No way to handle a "tab moved" event.
Use-case: tabline plugins may cache tab labels, and need to know when to
invalidate their cache.

Solution:
Add a `TabMoved` event that triggers whenever tabs are reordered via `:tabmove`
or via mouse click-and-drag.
2026-05-16 13:55:42 -04:00
Guilherme Batalheiro
0b96b3cd52 fix(shada): set correct buffer number for local marks on read #39712
Problem:
After closing and reopening Neovim, ]' and [' fail with E92: Buffer 0
not found for marks restored from ShaDa. Direct jumps like 'a work
because mark_get_local() rewrites fnum before returning, but ]' uses
getnextmark() which does not, leaving fnum = 0.

Solution:
Set .fnum = buf->b_fnum when restoring local marks from ShaDa.
2026-05-16 13:53:34 -04:00
glepnir
54f22a8f01 fix(excmd): :bufdelete may fail from floating window #39800
Problem: with a float focused and the target buf only shown in the
last non-float window, do_buffer_ext goes down the buf != curbuf
path. close_windows can't touch the last non-float, b_nwindows stays
> 0, close_buffer is skipped, returns OK silently.

Solution: if a non-float still holds buf after close_windows, jump
into it and recurse. Then buf == curbuf and the existing replacement
path takes over.
2026-05-16 12:25:18 -04:00