Commit Graph

10620 Commits

Author SHA1 Message Date
Justin M. Keyes
55205b3231 backport: feat(lsp): use LspNotify for semantic tokens (#40242)
feat(lsp): use LspNotify for semantic tokens

Problem: The semantic token module is using its own debounce timer for
the buffer on_lines event. If its internal debounce is shorter than the
changetracking module's debounce, it's possible for semantic token
requests to fire for changed buffers before the textDocument/didChange
notification is sent to the server.

Solution: Trigger semantic token requests from the LspNotify autocmd
when the method is the didChange or didOpen notifications, which
enforces a strict happens-before relationship for the sync change
notification followed by a semantic token request.

Note: There is still an internal debounce mechanism in the semantic
token module to handle other debouncing needs specific to its
functionality, such as debouncing server refresh notifications and
handling WinScrolled events when using range requests.

Co-authored-by: jdrouhard <john@drouhard.dev>
2026-06-14 16:43:08 +00:00
neovim-backports[bot]
304f8ed67a backport: fix(net): set buftype=nofile (again) (#39932)
redux 24e00f2844

(cherry picked from commit 1be55d02f5)

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2026-06-14 11:25:45 -04:00
neovim-backports[bot]
dc6a9170eb backport: fix(lsp): trailing blank line when edit inserts past end of buffer (#40176)
Problem:
A text edit positioned entirely past the last buffer line, with
newText ending in a newline, leaves a stray blank line: the
past-the-end path appends the trailing empty fragment produced by
vim.split() and does not set has_eol_text_edit, so the end-of-buffer
cleanup is skipped. Formatting servers emit such edits whenever
formatting moves text to the end of a document.

Regression from ec94014cd1 (#20137), which split the past-the-end
fast path off the clamp path that sets the flag.

Solution:
Set has_eol_text_edit in the past-the-end path, like the adjacent
path that clamps end_row.

(cherry picked from commit d42f7ee9dc)

Co-authored-by: Aaron Tinio <aptinio@gmail.com>
2026-06-14 11:25:18 -04:00
Justin M. Keyes
ecda67662f backport fix(lsp): refresh codelens despite pending debounce #40177
Problem:
When a server sends workspace/codeLens/refresh while an automatic codelens
request is already scheduled, Nvim ignores the server refresh. This can leave
rendered codelens text stale until another buffer edit triggers a new request.

Solution:
Cancel the pending automatic request and send the server-requested refresh
immediately. This preserves request coalescing while giving explicit server
refreshes priority.

Co-authored-by: Tristan Knight <admin@snappeh.com>
2026-06-14 11:23:32 -04:00
Jay Madden
fded370b3e perf(lsp): overscan semantic_token range requests #40036
Problem:
Flickering may occur when paging up/down in big files, as ranges for semantic
tokens are requested. This happens with LSP servers like gopls which return
"/full" semantic tokens if the file is too big, where we fall back to
viewport-range token retrievals.

Solution:
Broaden the requested ranges to one viewport of "overscan" on each side plus
some padding if possible:

    (viewport_topline - viewport_height)..(viewport_botline + viewport_height)

(cherry picked from commit 3ed78daf83)
2026-06-11 21:40:42 +00:00
Tomas Slusny
ed7acd1391 fix(startup): use nvim.difftool for nvim -d only for directories #40185
Problem:
`nvim -u NONE -d <(xxd one) <(xxd two)` has weird behavior.
Process substitution `<(...)` is a pipe and not a seekable file.

Test case:

    cat /dev/random | head -c 10240 > one
    cp one two
    cat /dev/random | head -c 10240 >> two
    nvim -u NONE -d <(xxd one) <(xxd two)

Solution:
Workaround the issue by skipping `nvim.difftool` if the 2 args are not
directories; fall-through to the builtin diff handling.

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
(cherry picked from commit 2fd2361a9d)
2026-06-11 11:16:21 +00:00
Justin M. Keyes
35b57441b0 NVIM v0.12.3
Following is a list of commits (fixes/features only) in this release.
See `:help news` in Nvim for release notes.

BREAKING
--------------------------------------------------------------------------------
- f54f566bf8 diagnostic: deprecate `format` as a table

FEATURES
--------------------------------------------------------------------------------
- fd1b193d51 :restart: v:starttime, v:exitreason #39319
- c407e3e67b eval: treat Lua string as "blob" in writefile() #39098
- a0dcdcd8a0 treesitter: provide select()
- 49efe692f3 vim.pos: accept buf=0 for current buf #39414
- ad27075c8d vim.pos: pos:to_offset(), pos.offset() (#39639)
- b05675bccc `opts.scope` in `vim.ui.input` (#39906)

PERFORMANCE
--------------------------------------------------------------------------------
- 96d5dd4107 vim.pos: use numeric index internally #39447

FIXES
--------------------------------------------------------------------------------
- e230ff0439 vim._with may silence all cmdline-errors #34301
- 781c43ea05 api: adjust Visual position after nvim_buf_set_text #30690
- 5b8268356a api: don't update 'title' when renaming non-curbuf #39743
- 4df16ecdb9 api: `LuaRef` leak in `nvim_set_keymap` on LHS too long (>=66 bytes) (#39376)
- e5d6d2e769 api: leak `preview` callback `LuaRef` in `nvim_create_user_command` (#39377)
- f0baa18043 channel: stack-buffer-overflow with exit during connection (#39387)
- d9baaf7da1 ci: generate more data to stress output throttling test #39577
- f62ce1a42f difftool: handle filenames containing spaces #39740
- fb56d50032 eval: writestring() handling of null #39328
- 822778f7e5 excmd: use realtime for v:starttime, :uptime #39425
- 8fccb26cd3 fold: virtual lines duplicate foldopen (#39891)
- 10695f44af health: set 'tags' for help filetype #39742
- e069022215 help: fix CTRL character issue for :help {subject} #39537
- 445fe8a6b7 lsp: calc correct screen_width when opts.relative == 'editor' (#39977)
- 93dc301781 lsp: callHierarchy/outgoingCalls ranges are relative to caller, not callee #39336
- 5e6c8d4edf lsp: check window is still valid after async request #39396
- 8919b02eba lsp: dynamic registration for off-spec method #39544
- c4d3a3d363 lsp: filter code_action diagnostics to the cursor #38988
- 27d01f2dbb lsp: handle null id in JSON-RPC responses
- aedbae4ab6 lsp: handle self-mapped methods in supports_method #39383
- 0bd6e62509 lsp: malformed edit if apply_text_edits() is called twice (#39347)
- 378f5f49b3 lsp: show meaningful error on invalid completion response (#39476)
- c9ca59ad28 lsp: util.lua attempt to concatenate userdata #39510
- e67f9c5853 lua: avoid `__index` when deciding if a table is a list #39556
- 731f9743e2 lua: don't strip debuginfo in precompile module #39191
- b0bfce290f lua: fields of `nvim.spellfile.Opts` are optional #39902
- 34bf0472ab marks: don't use spell decorations from other lines (#39441)
- d1cf3ab4c3 marks: read from the correct variable in conceal_lines mark collection (#39991)
- 33b6b0bfe5 messages: avoid recursive rtp build due to msg_show #39888
- d725ead5ec messages: reset redirection message column after :echon #39472
- b490fba786 mouse: mouse=n should not adjust visual selection
- 17ddfde131 net: `:edit <uri>` should set buftype=nofile #39915
- dd95e434e3 pack: only use tags that strictly comply with semver spec #39342
- 585c93204f path: `nvim_get_runtime_file` fails on DOS 8.3 filename #40144
- 42f6c1c443 prompt: handle multi-element lists in prompt_appendbuf #39550
- 915880d252 shada: bdelete'd buffers not stored in oldfiles #39070
- e4a9bd55b2 shada: set correct buffer number for local marks on read #39712
- 2389cf2e39 shell: preserve CR when `:!` outputs to binary-mode buffer #39558
- 98098d8466 startup: emitting useless OptionSet
- ae9f7accdd statusline: no cmdline ruler for autocommand window
- 39e8c584d5 terminal: memory leak in pending TermRequest StringBuilder #39333
- fa69cac7e3 terminal: memory leak when pasting '=' register (#39738)
- 3a3405d964 test: only test for unibilium if a valid compilation string exists
- dcf9e8a98e treesitter: crash in ts_parser_delete after gc #39497
- 4f22640b86 treesitter: get_node_text() inconsistent trailing newline #39409
- 654c964d1a trust: hash unchanged empty buffers as empty files #39027
- 70f22713a1 ui2: entering the pager fails if `<ESC>` is remapped to `:fclose` (#39462)
- 13041a067e ui2: error E518 when typing "vim:" in cmdline #39599
- a0ee5811b1 unittest: preprocess failure when __typeof declarations present #40145
- b9d39f5bb2 vim.fs: fs.dir() may return nil "type" on some filesystems #39749
- be4e7cfd6a vim.hl: range(0,…) highlight not cleared after buffer-switch #40130
- 79fd0b6655 vim.range: empty ranges semantics vs regular ranges #39474
- 2ec758f403 vim.range: validate arguments on all cases #39415
- f83e0dcaf8 vim.secure: read() command injection vulnerability #39918

BUILD
--------------------------------------------------------------------------------
- a612ada984 version bump
- b1b489b316 docs: sort/lint class fields and keysets
- 4f6c711fc0 test: declaration specifier expected near '_Static_assert' #39788

VIM PATCHES
--------------------------------------------------------------------------------
- 964e797fdf 9.2.0395: tests: Test_backupskip() may read from $HOME (#39417)
- b013940391 9.2.0435: [security]: backticks in 'path' may cause shell execution on completion
- f9f2596288 9.2.0436: Buffer overflow when parsing overlong errorformat lines (#39578)
- 0aa77cb78c 9.2.0443: GUI: cancelling save dialog overwrites or discards unnamed buffer (#39617)
- 15a58bb02a 9.2.0444: Cannot set 'path' option via modeline
- 03af1ec931 9.2.0450: [security]: heap buffer overflow in spellfile.c read_compound() (#39660)
- 2902ec0541 9.2.0458: Crash with invalid shellredir/shellpipe value (#39691)
- 647b6be489 9.2.0461: Corrupted undofile causes use-after-free (#39707)
- c8e0af85e0 9.2.0500: filetype: some html files wrongly recognized as htmlangular (#39880)
- d9b8bac435 9.2.0508: completion: cannot complete user cmd :K with 'ignorecase' (#39944)
- 15a3318e13 9.2.0513: [security]: memory safety issues in spellfile.c (#39960)
- cc1982bd06 9.2.0517: quickfix: can set quickfixtextfunc in restricted/sandbox mode (#39970)
- dfd6cd477f bfebd12: runtime(javacc): Check for existence of javaFuncDef syn group before clearing it (#39731)
- a76bcbe3b8 partial:9.2.0315: missing bound-checks (#39334)
2026-06-11 00:06:57 +02:00
Justin M. Keyes
be4e7cfd6a fix(vim.hl): range(0,…) highlight not cleared after buffer-switch #40130
Problem:
When `vim.hl.range(0, …, { timeout = N })` is called, the deferred
`range_hl_clear` captures `buf=0`, which resolves to an arbitrary
"current buffer" at timeout. This may cause a stale highlight that never
gets cleared.

Solution:
Resolve `buf=0` explicitly, before `range_hl_clear` captures it.

(cherry picked from commit ec7dab077b)
2026-06-06 10:52:40 +00:00
abdulahmoda
b9d39f5bb2 fix(vim.fs): fs.dir() may return nil "type" on some filesystems #39749
Problem:
Currently, only some filesystems (Btrfs, ext2, ext3, ext4) have full
support of accessing the `dirent` entry-type. On other filesystems,
`uv.fs_scandir_next` may return `nil` for an existing but unsupported
entry-type.

This means consumers (such as `fs.dir()`), cannot know if `nil` means
"non-existent" or "unsupported".

Solution:
Fall back to `uv.fs_lstat` when `etype` is `nil`; return "unknown" if it
fails.

(cherry picked from commit 4b5f026ac9)
2026-05-29 18:56:59 +00:00
atusy
8fac963f65 docs(treesitter): describe pattern_id of captures
(cherry picked from commit ac352a6df6)
2026-05-29 15:56:13 +00:00
acehinnnqru
445fe8a6b7 fix(lsp): calc correct screen_width when opts.relative == 'editor' (#39977)
(cherry picked from commit a9d7cbd722)
2026-05-27 13:55:23 +00:00
Justin M. Keyes
f83e0dcaf8 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

(cherry picked from commit 799cbfff85)
2026-05-20 20:00:45 +00:00
Justin M. Keyes
17ddfde131 fix(net): :edit <uri> should set buftype=nofile #39915
(cherry picked from commit 24e00f2844)
2026-05-20 17:25:32 +00:00
Evgeni Chasnovski
b05675bccc backport: opts.scope in vim.ui.input (#39906)
feat(ui): vim.ui.input(opts.scope) #39570

Problem: There is no way for a `vim.ui.input` caller to indicate for
  which scope the input is. As in "This input is for something at cursor
  scope". This information can be useful for `vim.ui.input`
  implementation to tweak its behavior and presentation:
  - Show different floating window depending on the scope. For example:
    - Near cursor for "cursor" scope.
    - At line start for "line" scope.
    - In window corner for "buffer" and "window" scopes.
    - In whole editor corner for "tabpage", "editor", "project" scopes.
  - Navigate through history only for inputs with the same scope.

Solution: Document new `opts.scope` for `vim.ui.input`. Use it in the
  codebase.
2026-05-20 08:44:03 +00:00
Olivia Kinnear
b0bfce290f fix(lua): fields of nvim.spellfile.Opts are optional #39902
(cherry picked from commit ea8f1463dd)
2026-05-20 07:11:32 +00:00
zeertzjq
c8e0af85e0 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>
(cherry picked from commit f3bb21e71d)
2026-05-19 01:08:18 +00:00
Puneet Dixit
98098d8466 fix(startup): emitting useless OptionSet
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 18:24:50 +02:00
Justin M. Keyes
03d99a0659 backport: docs: misc
backport #39817
2026-05-17 16:04:49 +02:00
Jackson Ludwig
f62ce1a42f fix(difftool): handle filenames containing spaces #39740
Problem:
Using the `DiffTool` plugin (e.g. through `nvim -d ...` or `:DiffTool
<file1> <file2>` fails if a space is in one of the paths. This occurs
because the `diff` wraps the paths with quotes (`'`) if space
characters are present, which the line diff regex fails to parse.

Solution:
Update regex to handle quoted paths by matching the string within the
quotes, if it exists.

(cherry picked from commit 1e09b020e5)
2026-05-15 01:04:43 +00:00
Justin M. Keyes
25b522a75d backport: docs: misc, window (#39722)
- formalize `window-number` similar to `tabpage-number`.
- reference it from docs.
2026-05-11 21:06:59 +00:00
Marcus Caisey
10695f44af fix(health): set 'tags' for help filetype #39742
Problem:
The `:checkhealth` buffer uses the help syntax, so help tag links (e.g.
`|clipboard|`) are highlighted like they are in help buffers. However,
unlike in help buffers, `CTRL-]` doesn't jump to the relevant help file.

I expect that if the `:checkhealth` buffer looks like a help buffer,
then it should behave like one where it makes sense. This comment from
/r/neovim suggests that this was the intention:
https://www.reddit.com/r/neovim/comments/5ghv3r/see_clipboard_how/dascnry/.

Solution:
Set `'tags'` in `checkhealth` buffers so that `:tag` and friends look
for tags in the help tags files.

(cherry picked from commit c4285acb92)
2026-05-11 19:37:36 +00:00
zeertzjq
dfd6cd477f vim-patch:bfebd12: runtime(javacc): Check for existence of javaFuncDef syn group before clearing it (#39731)
fixes: vim/vim#20190

bfebd1209b

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 5e756aa825)
2026-05-11 10:02:23 +00:00
zeertzjq
2902ec0541 vim-patch:9.2.0458: Crash with invalid shellredir/shellpipe value (#39691)
Problem:  Crash with invalid shellredir/shellpipe value
          (bfredl)
Solution: Validate the option and allow only a single "%s".

fixes:  vim/vim#20157
closes: vim/vim#20159

84ae09dd79

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit ffe87d91f7)
2026-05-09 01:38:36 +00:00
Luis Calle
79fd0b6655 fix(vim.range): empty ranges semantics vs regular ranges #39474
Problem:
- Empty ranges have different `<`, `<=`, `has` and `intersect` semantics compared to regular ranges.
- `to_inclusive_pos` assumes that the end position of a range is exclusive, which is not true for empty ranges

Solution:
Special case empty ranges in these operations.

(cherry picked from commit 416f3482e7)
2026-05-08 10:17:30 +00:00
Justin M. Keyes
b3cd33d029 backport feat(tui): restore 'ttyfast' to control tty requests (#39667)
feat(tui): restore 'ttyfast' to control tty requests

Problem:
When running nvim on a remote machine over SSH, if there is high ping,
then bg detection may not complete in time. This results in a warning
every time nvim is started. #38648

Solution:
Restore 'ttyfast' option and allow it to control whether or not bg
detection is performed. Because this is during startup and before any
user config or commands, we use the environment variable
`NVIM_NOTTYFAST` to allow disabling `ttyfast` during initialization.

Co-authored-by: Kyle <50718101+kylesower@users.noreply.github.com>
2026-05-08 06:49:34 +00:00
Justin M. Keyes
cae8fd7a94 refactor: _meta/builtin_types.lua => vimfn_types.lua #39658
Problem:
`builtin_types.lua` seems to be about vimfn (aka "eval", aka
"vimscript", …) specifically, whereas `builtin.lua` is about the Lua
stdlib.

Solution:
Rename it to `vimfn_types.lua`, to align with `vimfn.gen.lua`.

(cherry picked from commit aea9aeee78)
2026-05-07 21:47:57 +00:00
Justin M. Keyes
1999c09953 backport build(docs): lint more quasi-keysets (#39656)
Problem:
Linter missed backtick and double-quote keynames in the quasi-keyset of
the `nvim_create_user_command` docstring.

Solution:
Update the linter to check backtick-surrounded and quote-surrounded key
names.
2026-05-07 17:32:50 +00:00
Quentin
94b0229fa5 docs: expand nvim_create_user_command docs #39540
(cherry picked from commit 97a557bd1e)
2026-05-07 13:57:57 +00:00
Eisuke Kawashima
382882976e docs: adjust modelines for HTML rendering #39649
Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
(cherry picked from commit 7e778205ab)
2026-05-07 13:06:40 +00:00
Justin M. Keyes
6e44bd3c71 backport fix(treesitter): drop select() kwargs (#39647)
fix(treesitter): drop select() kwargs

Problem:
Unnecessary kwargs.

Solution:
Use param instead of kwargs.
2026-05-07 11:21:05 +00:00
Yi Ming
f54f566bf8 feat(diagnostic)!: deprecate format as a table 2026-05-07 12:03:02 +02:00
Justin M. Keyes
33c6d51167 docs: rename "tabpage" 2026-05-07 12:03:02 +02:00
Justin M. Keyes
b982adfe10 docs: misc, rename "tabpage" 2026-05-07 12:03:02 +02:00
Nathan Zeng
a0dcdcd8a0 feat(treesitter): provide select()
Problem: No public method for treesitter incremental selection.

Solution: Add `vim.treesitter.select()`.
2026-05-07 12:03:02 +02:00
Justin M. Keyes
ad27075c8d feat(pos): pos:to_offset(), pos.offset() (#39639)
Problem:
For a given position, it is not easy to compare which of several other positions is closest to it.

Solution:
Add support for converting `vim.Pos` to a buffer byte offset.

This allows for sorting, e.g:
```lua
table.sort(positions, function(pos1, pos2)
  return pos1:to_offset() < pos2:to_offset()
end
```

Or a binary search, e.g:
```lua
vim.list.bisect(positions, pos, { key = function(pos) return pos:to_offset() end })
```

Co-authored-by: Yi Ming <ofseed@foxmail.com>
2026-05-07 05:16:53 -04:00
Justin M. Keyes
0197461265 backport fix(diagnostic): status() respects config.signs (#39601)
Problem:
`diagnostic.status` only follows the `config.status.format` setting to determine how to display diagnostic signs. However, `signs` can actually also be configured via `config.signs.text`.

Solution:
If the user has set symbols via `config.status.format`, let that determine the content of `signs`; otherwise, use `config.signs.text` for display.

TODO: drop support `type(config.status.format) == 'table'`; users should just configure `config.signs.text` directly.

Co-authored-by: Yi Ming <ofseed@foxmail.com>
2026-05-06 16:42:02 +00:00
Tomasz N
70f22713a1 fix(ui2): entering the pager fails if <ESC> is remapped to :fclose (#39462)
Problem:  Entering the pager fails if <ESC> is remapped to :fclose by user.
Solution: Avoid executing mappings with nvim_feedkeys() that closes expanded cmdline.
(cherry picked from commit 2b7a00746d)
2026-05-06 13:58:25 +00:00
STG
13041a067e fix(ui2): error E518 when typing "vim:" in cmdline #39599
Problem: `vim:`, etc. in cmdline are interpreted as modeline, causing error E518.

Solution: Set 'nomodeline' when creating the buffers.
(cherry picked from commit 0ea720f281)
2026-05-06 13:31:37 +00:00
zeertzjq
15a58bb02a vim-patch:9.2.0444: Cannot set 'path' option via modeline
Problem:  Cannot set 'path' option via modeline (zeertzjq, after v9.2.0435)
Solution: Revert the part that disallows setting 'path' via modeline.

closes: vim/vim#20137

88fb739918

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit d1c3d6fbaa)
2026-05-06 00:54:27 +00:00
zeertzjq
b013940391 vim-patch:9.2.0435: [security]: backticks in 'path' may cause shell execution on completion
Problem:  [security]: Backticks enclosed shell commands in the 'path'
          option value are executed during completion (q1uf3ng).
Solution: Skip path entries containing backticks, add P_SECURE to 'path'
          option, so that it cannot be set from a modeline (for symmetry with
          the 'cdpath' option)

Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-hwg5-3cxw-wvvg

Supported by AI.

190cb3c2b9

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit b06f8b174f)
2026-05-06 00:54:27 +00:00
Yi Ming
e67f9c5853 fix(lua): avoid __index when deciding if a table is a list #39556
Problem:
When a table has `__index`, `vim.islist` is unreliable.

Solution:
Index using `rawget`.

(cherry picked from commit 264fbc0ace)
2026-05-05 20:54:41 +00:00
David Balatero
4f22640b86 fix(treesitter): get_node_text() inconsistent trailing newline #39409
Problem:
`get_node_text()` returned inconsistent results between buffer and
string sources when a node's range ends at `end_col == 0` (i.e. the node
ends with a newline). The buffer path dropped the trailing newline; the
string path included it correctly.

Solution:
Append `'\n'` in `buf_range_get_text()` when `end_col == 0` and
`start_row ~= end_row`. The `start_row ~= end_row` guard excludes
zero-width nodes at column 0, which should return `""`.

Remove the workaround in the `#trim!` directive that manually
compensated for the missing newline.

Strip whitespace in `resolve_lang()` so injection language nodes ending
at `end_col == 0` (e.g. `">lua\n"`) still resolve correctly.

(cherry picked from commit 7ed5609439)
2026-05-03 13:53:04 +00:00
Tristan Knight
8919b02eba fix(lsp): dynamic registration for off-spec method #39544
Problem:
LSP clients previously did not handle dynamic registration for off-spec methods

Solution:
Update the client logic to assume support for dynamic registration when
the method is unknown. Adjust the registration provider fallback and
enhance tests to verify correct behaviour for unknown methods and their
registration options. This improves compatibility with servers using
custom dynamic registrations.

AI-assisted: OpenCode
(cherry picked from commit 344d984ed2)
2026-05-02 10:54:42 +08:00
Yochem van Rosmalen
e069022215 fix(help): fix CTRL character issue for :help {subject} #39537
Problem:
The argument to `:help` is normalized to fit the general tag format.
I.e. i^U-default, iCTRL-U-default and i_CTRL_U-default should all point
to the i_CTRL_U-default tag. Our normalization adds an underscore around
the CTRL keycode, e.g. iCTRL-GCTRL-J becomes i_CTRL-G_CTRL-J. That's not
necessary if the following part starts with a dash, like the case of
iCTRL-U-default.

Solution:
Do not insert an underscore if the following character is a dash/minus
(-).

(cherry picked from commit 84ae70c172)
2026-05-01 10:50:35 +00:00
Matthew Hughes
20a2398877 docs: Update instructions for debugging LSP (#39527)
docs: update instructions for debugging LSP

Previously, it was suggested to set:

    vim.lsp.log.set_format_func(vim.inspect)

This made sense before f72c13341a, when
`format_func` was called once per argument being logged, but since that
commit it's called with the log level followed by the other args, so the
suggested setting would call `vim.inspect(log_level, ....)` which would
just print the human readable name of the current log level and no other
details, for example with this set I saw in my logs:

    "DEBUG""DEBUG""DEBUG""DEBUG"

Instead just rely on the default formatter, which will:

> ... log the level, date, source and line number of the
caller, followed by the arguments.

(cherry picked from commit 578727c25e)
2026-04-30 22:05:37 +00:00
Justin M. Keyes
4b424a06c5 backport fix(lsp): send didClose, didOpen when languageId changes (#39519)
fix(lsp): send didClose, didOpen when languageId changes

Problem:
If a buffer's filetype changes after the LSP client has already
attached (e.g. from json to jsonc via a modeline), but the client
supports both filetypes, it stays attached. It does not notify the
server of the new languageId, causing the server to incorrectly process
the file using the old languageId.

Solution:
Save the languageId used during textDocument/didOpen, and send
textDocument/didClose + textDocument/didOpen when buffer's languageId
changed.

Lsp spec:
0003fb53f1/_specifications/lsp/3.18/textDocument/didOpen.md (L5)
> If the language id of a document changes, the client
> needs to send a textDocument/didClose to the server followed by a
> textDocument/didOpen with the new language id if the server handles
> the new language id as well.

AI-assisted: Gemini 3.1 Pro

Co-authored-by: phanium <91544758+phanen@users.noreply.github.com>
2026-04-30 13:09:55 +00:00
Justin M. Keyes
4ee47a56ec docs: misc 2026-04-30 02:08:19 +02:00
Till Bungert
822778f7e5 fix(excmd): use realtime for v:starttime, :uptime #39425
Problem:
`v:starttime`, `:uptime` use a monotonic high-resolution timer. This
only works as long as the timer keeps running (if the computer is
suspended the timer is paused). This is somewhat unintuitive, and
doesn't match the behavior of the `uptime` shell command.

Solution:
Implement `os_realtime` to get the real time since the
epoch in nanoseconds.
2026-04-29 23:41:41 +02:00
Olivia Kinnear
c9ca59ad28 backport: fix(lsp): util.lua attempt to concatenate userdata #39510
Problem:
Error when querying document symbols using python-lsp-server:

    lsp/util.lua:1955: attempt to concatenate field 'containerName' (a userdata value)

Solution:
Check for `vim.NIL`.

(cherry picked from commit 1799aaebda)
2026-04-29 16:13:47 -04:00
neovim-backports[bot]
378f5f49b3 backport: fix(lsp): show meaningful error on invalid completion response (#39476)
Problem: vim.NIL is truthy in Lua, so `#(result.items or result)`
crashes on `#vim.NIL` when servers return null.

Solution: skip spec-allowed result=null silently, raise an error
on items=null with the server name.

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_completion
(cherry picked from commit b9431b340f)

Co-authored-by: glepnir <glephunter@gmail.com>
2026-04-28 11:27:50 -04:00