Commit Graph

4558 Commits

Author SHA1 Message Date
Tristan Knight
aedbae4ab6 fix(lsp): handle self-mapped methods in supports_method #39383
Problem:
The LSP client incorrectly checks for server capabilities when determining
support for self-mapped methods (e.g., 'shutdown'), which do not have
corresponding capabilities in the server's response. This leads to false
negatives when checking if such methods are supported.
This was handled correctly for dynamic registrations, but not for static.

Methods such as 'shutdown', do not have a related server capability and should
be assumed to be supported.

Solution:
Update the `supports_method` logic to always return true for self-mapped
methods.

(cherry picked from commit f83d0b9653)
2026-04-24 23:19:16 +00:00
Barrett Ruth
654c964d1a fix(trust): hash unchanged empty buffers as empty files #39027
Problem:
`vim.secure.trust()` hashes an unchanged empty buffer as
a newline, so trusting an empty file by buffer never works.

Solution:
Hash unchanged empty-buffers `''` so buffer-based
trust matches the on-disk empty file.

(cherry picked from commit 0a8218a2b4)
2026-04-23 23:38:56 +00:00
neovim-backports[bot]
0bd6e62509 fix(lsp): malformed edit if apply_text_edits() is called twice (#39347)
Problem:
Use vim.lsp.util.apply_text_edits to re-apply the same textedit causes
an incorrect edit, because apply_text_edits silently modifies the
parameter.

Solution:
- Avoid changing `text_edit._index`.
- Document this fun feature.

Helped-by: Riley Bruins <ribru17@hotmail.com>
Helped-by: Yi Ming <ofseed@foxmail.com>

(cherry picked from commit 790a8be5f3)

Co-authored-by: geril07 <62308020+geril07@users.noreply.github.com>
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2026-04-23 19:24:04 -04:00
Barrett Ruth
c4d3a3d363 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.

(cherry picked from commit ecb8402197)
2026-04-23 23:07:26 +00:00
Ashley Hauck
93dc301781 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)

(cherry picked from commit 7e006b06c4)
2026-04-23 23:07:07 +00:00
atusy
27d01f2dbb fix(lsp): handle null id in JSON-RPC responses
Problem:
LSP spec allows response message to have a null request-id.
This may happen when for example client sends unparseable request.
https://github.com/microsoft/language-server-protocol/issues/196

Solution:
Guard the server response branches against id=vim.NIL (json null),
and handle error responses with null id by logging a warning
and dispatching on error.

Problem:
CI (ubuntu asan, ubuntu tsan, windows) reports `uv_loop_close()
hang?` from the two new null-id response tests. The leaked
handle is the server-side accepted TCP socket created inside
`server:listen` callback. The tests closed only the listener
but not the accepted socket, so libuv could not finish shutting
down the loop and each test session took ~2s extra to exit.

Solution:
Hoist the accepted socket to the outer `exec_lua` scope and
close it at teardown before closing the listener. The close
runs synchronously inside `exec_lua`, so the loop has time to
dispose the handle before the session exits.

* test(lsp): close accepted socket on read-loop exit/error

Match the precedent in the handler test ("handler can return
false as response") and the shared `_create_tcp_server` helper
in `test/functional/plugin/lsp/testutil.lua`: close the
accepted socket from inside the `create_read_loop` exit/error
callbacks. The teardown close added in the previous commit
remains as belt-and-suspenders, so the socket is disposed
whether the server goes away first or the client does.
2026-04-23 23:00:25 +02:00
Evgeni Chasnovski
dd95e434e3 fix(pack): only use tags that strictly comply with semver spec #39342
Problem: Using `version=vim.version.range(...)` in plugin specification
  is meant to use semver-like tags. Whether a tag is semver-like was
  decided by a plain `vim.version.parse` which is not strict by default.
  This allowed treating tags like `nvim-0.6` (which is usually reserved
  for the latest revision compatible with Nvim<=0.6 version) like semver
  tags and resulted in confusing behavior (preferring `nvim-0.6` tag
  over `v0.2.2`, for example).

Solution: Use `vim.version.range(x, { strict = true })` to decide if the
  tag name is semver-like or not. This allows tags like both `v1.2.3`
  and `1.2.3` while being consistent in what Nvim thinks is a semver
  string.

  This is technically not a breaking change since it was documented that
  only tags like `v<major>.<minor>.<patch>` will be recognized as
  semver.

(cherry picked from commit f8c94bb8cf)
2026-04-23 15:55:14 +00:00
Justin M. Keyes
b46688feee backport feat(treesitter): expand selection to sibling node (#39323)
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.

Co-authored-by: altermo <107814000+altermo@users.noreply.github.com>
2026-04-22 21:40:12 +00:00
Justin M. Keyes
fd1b193d51 feat(:restart): v:starttime, v:exitreason #39319 2026-04-22 18:58:47 +00:00
neovim-backports[bot]
b6a3ad3979 backport: fix(ui2): ensure msg window is visible after closing tab (#39245)
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.


(cherry picked from commit 607fcfb37a)

Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
Co-authored-by: Linykq <yukunlin590@gmail.com>
2026-04-22 13:43:04 +00:00
zeertzjq
3e0ece4cde fix(:restart): avoid ERR/WRN logging on Windows with --listen (#39287)
Problem:  :restart leads to ERR/WRN logging on Windows with --listen.
Solution: Add a log_level flag to vim._with() and use it to suppress
          logging from serverstart()/serverstop() during restart.
(cherry picked from commit 208951cbc0)
2026-04-22 12:04:36 +00:00
Nick Krichevsky
4d4e196447 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.

(cherry picked from commit e68e769352)
2026-04-22 11:52:02 +00:00
neovim-backports[bot]
b3b5674ac7 fix(:restart): --listen reusage on windows #39281
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.

(cherry picked from commit 5891f2f3dc)

Co-authored-by: Sanzhar Kuandyk <92693103+SanzharKuandyk@users.noreply.github.com>
2026-04-22 06:22:12 -04:00
fleesk
6583833ee2 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.

(cherry picked from commit e53e728c92)
2026-04-22 09:24:45 +00:00
Justin M. Keyes
e767b4843b backport: refactor(test): drop deprecated exc_exec #39255 2026-04-21 16:22:05 +00:00
luukvbaal
c6b5eb30de 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.
(cherry picked from commit faa7c15b5a)
2026-04-20 19:13:17 +00:00
Justin M. Keyes
5ad64af44f docs: misc #39243 2026-04-20 11:46:26 +00:00
Justin M. Keyes
eaa8cff0bd fix(api): expose fg_indexed/bg_indexed in nvim_get_hl (#39240)
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.

(cherry picked from commit 01861c2f95)

Co-authored-by: glepnir <glephunter@gmail.com>
2026-04-20 09:46:55 +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
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
Aditya Malik
326a7d5afb docs(events): Lua types for autocmd event-data #38518
Problem:
  No LuaLS types for event-data fields (ev.data). Types are only
  documented ad hoc in scattered locations.

Solution:
  Add runtime/lua/vim/_meta/events.lua defining vim.event.<name>.data
  classes for events that provide ev.data. Reference the types from
  each event's help in autocmd.txt, lsp.txt, and pack.txt.
(cherry picked from commit 2cb240319b)
2026-04-18 20:35:15 +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
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
zeertzjq
891c6c9150 vim-patch:8.2.2440: documentation based on patches is outdated (#39144)
Problem:    Documentation based on patches is outdated.
Solution:   Add changes to documentation in a patch.

853886722c

Trailing space was removed in later patches.
Also fix a few more misplaced error numbers from #8155.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
(cherry picked from commit 39410ef42b)
2026-04-17 02:10:01 +00:00
Evgeni Chasnovski
ee6c718feb docs(pack): improve "Synchronize across machines" steps #39122
Problem: Sometimes automatic lockfile synchronization after `:restart`
  might fail, like due to bad/absent Internet connection. This would
  remove failed to install entries from the lockfile (since they are not
  on disk and lockfile is meant to lock the latest plugin version on
  disk).

Solution: Document that this should be treated as an unwanted update and
  use steps similar to "Revert plugin after an update" use case.
(cherry picked from commit 42e9d8dfd1)
2026-04-17 00:19:01 +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
Justin M. Keyes
a1712503d8 backport test: lint naming conventions (#39124)
test: lint naming conventions

Problem:
Naming conventions are not automatically checked.

Solution:
Add a check to the doc generator. Eventually we should extract this
somehow, but that will require refactoring the doc generator...

Note: this also checks non-public functions, basically anything that
passes through `gen_eval_files.lua` and `gen_vimdoc.lua`. And that's
a good thing.
2026-04-16 14:29:50 +00:00
Luis Calle
efc136850d refactor(lsp): fix typing for LSP methods #39099
Problem
Some variables use the wrong type (ClientToServer instead of ServerToClient)
and some use vaguer types that could be more strict.

Solution
Use the correct types.

(cherry picked from commit 530cfa1323)
2026-04-16 08:23:06 +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
Justin M. Keyes
373a248b0f refactor(api): rename buffer to buf (positional parameters) #39013
In 3a4a66017b, 4d3a67cd62, df8d98173c we renamed "buffer" to "buf"
in dict parameters and return-values.

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 d0af4cd909)
2026-04-15 14:09:12 +00:00
Justin M. Keyes
ccba8a8f2d docs: lsp, options, api
- revert bogus change to `_meta/builtin_types.lua` from 3a4a66017b

Co-authored-by: David Mejorado <david.mejorado@gmail.com>
2026-04-14 13:27:29 +02:00
Justin M. Keyes
53038d2c38 fix(lua): not obvious which _meta/ files are generated #39035
Problem:
- Not obvious which _meta/ are generated and which should be edited
  manually.
- The require guard (`error('Cannot require a meta file')`) is not
  consistently present in all meta files.

Solution:
- Update headers.
- Add require() guard to all meta files.
- Rename generated meta files with `.gen.lua`.

(cherry picked from commit 65b40e69ac)
2026-04-14 10:04:52 +00:00
neovim-backports[bot]
c630ca7459 refactor(options): generate "modeline disallowed" doc text (#39034)
Problem:
- Lots of redundant text in options docs for "not allowed in
  a modeline", even though we already have a flag that indicates that.
- `deny_in_modelines` is an old vestigial flag only used by 'encoding'
  (which never changes).

Solution:
- Generate docs based on the `secure` flag.
- Remove the `deny_in_modelines` flag (`kOptFlagNoML`).

(cherry picked from commit 829e9ec65e)

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2026-04-14 04:43:09 -04: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
Justin M. Keyes
5920a1d07f revert: "fix(lsp): only resolve LSP configs once" #38990
revert eb90f5d9e3

(cherry picked from commit 4eb95c8ed2)
2026-04-12 22:09:15 +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
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
Justin M. Keyes
b28f00bf9c docs: misc 2026-04-12 15:56:12 +02:00
Justin M. Keyes
5dbc956803 docs: vim.pos 2026-04-12 15:54:27 +02: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
skewb1k
df3d7e36d0 fix(pack): make 'stash' call compatible with older Git #38679
Problem:
On Git versions 2.13..2.26 there is a bug that prevents using
`stash --message`.

Solution:
Use the full `stash push --message` form to avoid that bug.

(cherry picked from commit 38aec2d3cd)
2026-04-11 22:45:34 +00:00
glepnir
18b1ff81a3 fix(lsp): check stale context in hover/signature callback #38724
Problem: hover/signature callback lacked consistency checks, so slow LSP servers
could open a float after the cursor had already moved away.

Solution: guard the callback with buf validity, buf version, and cursor
position checks before opening the float. Also fix table capacity calculation.

(cherry picked from commit af9a72d8c1)
2026-04-11 15:38:28 +00:00
Evgeni Chasnovski
1a5d41a48f fix(pack): more advice for out-of-sync lockfile #38931
Problem: If the lockfile points to the revision that is not on disk, the
  `:checkhealth vim.pack` suggests to run `vim.pack.update()`. Although
  usually it should resolve the problem, it is not always the case: like
  if the state on disk is already the latest available.

Solution: Add an extra suggestion with a more drastic measure by
  manually removing `rev` field from the lockfile for it to be repaired
  after the `:restart`.
(cherry picked from commit 94c0e54e5b)
2026-04-10 16:26:27 +00:00