Commit Graph

4397 Commits

Author SHA1 Message Date
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
Luis Calle
a15e27fbcf fix(vim.pos): Range:intersect() drops buf #38898
new() only supports nargs=5 or nargs=2, but this was passing 4 args.

(cherry picked from commit 24811c0a14)
2026-04-09 15:55:36 +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
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
Justin M. Keyes
47e3efed99 refactor(filetype): move _get_known_filetypes, return a Set #38886
- `_get_known_filetypes` may be useful for other internal code, so move
  it to an internal function.
- Use a set instead of a list, for performance.
2026-04-08 23:26:07 +02: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
Luis Calle
f529bc74f9 docs: vim.range, vim.pos #38869
Problem:
`vim.Range` and `vim.Pos` have signature mismatches on the docs of some functions.

Solution:
Split the "module" functions from the "class" functions (just like it's done in other modules like `vim.version`) and regenerate the docs.

(cherry picked from commit c530fd8e75)
2026-04-08 16:19:48 +00:00
Dan Drennan
11a4a0077c fix(health): recognize Zig build optimization levels #38804
Problem: When Neovim is built with Zig, `:checkhealth` falsely reports
"Non-optimized debug build" for release builds. The extraction regex
stops at the first space, and the validation regex only lists CMake
build type names.

Solution: Fix the extraction regex to capture the full build type string
and add Zig optimization levels (ReleaseFast, ReleaseSafe, ReleaseSmall)
to the validation regex.

AI-assisted: Claude Code
(cherry picked from commit 65ef6cec1c)
2026-04-08 12:43:27 +00:00
glepnir
25170ca02d fix(diagnostic): virtual_lines should anchor at end_lnum, not lnum #38701
Problem: Multi-line diagnostics always render virtual lines below lnum.

Solution: Use end_lnum when placing the virt_lines extmark.
(cherry picked from commit af707dd242)
2026-04-06 18:05:35 +00:00
Christian Clason
ceaa8b648a feat(filetype): vim.filetype.inspect() returns copy of registry
Problem: No way of inspecting the (user-added) filetype detection rules.

Solution: Add `vim.filetype.inspect()` returning copies of the internal
`extension`, `filename`, `pattern` tables. Due to the dynamic nature of
filetype detection, this will in general not allow getting the list of
known filetypes, but at least one can see if a given extension is known.
2026-04-06 18:53:36 +02:00
Luis Calle
0a3add979a feat(vim.pos)!: require buf param on vim.pos, vim.range #38665
Problem: `buf` is optional even though its needed to perform conversions
and the ordering of `(buf, row, col)` is not consistent.

Solution: make `buf` mandatory on `vim.range` and `vim.pos` and enforce
the `buf, row, col` ordering

(cherry picked from commit 01be30f638)
2026-04-06 16:19:43 +00:00
Justin M. Keyes
f92a68d4bc docs: statusline
fix https://github.com/neovim/neovim/issues/38670

(cherry picked from commit 6b796696c3)
2026-04-06 01:24:32 +00:00
Evgeni Chasnovski
35a9bf8785 fix(pack): avoid eager vim.version call #38705
Problem: Commands that rely on Git may need its version to perform more
  targeted actions (like decide which arguments are safe to use).
  For performance, computing this version is delayed up until it is
  needed (like to not compute on regular startup), but not done before
  every Git operation (as it is too much and can be done better).

  This requires storing the Git version in a variable which is currently
  initiated via `vim.version.parse()` call (most probably because it was
  easier to handle Lua types this way).

  However, the problem is that this results in sourcing `vim.version`
  and computing `vim.version.parse` on every startup even if no Git
  operation would be done.

Solution: Don't call `vim.version.parse()` during `require('vim.pack')`
  and ensure its more precise lazy computation.
(cherry picked from commit 157c7bccb0)
2026-04-06 01:18:37 +00:00
Yi Ming
c692e848e9 fix(lsp): do not respond to codelens refresh if a request is already scheduled (#38801)
(cherry picked from commit 909fc0b992)
2026-04-05 21:15:28 +00:00
Yochem van Rosmalen
e7a07364ad fix(vim.net): check if vim.system's stdout is nil #38713
Problem:
Apparently vim.SystemCompleted.stdout can also be nil, even without a
custom stdout handler. (Although the docs can be interpreted otherwise).

Solution:
Explicitly check for nil and set the result body to an empty string if
stdout was nil.

(cherry picked from commit 398ee83f4f)
2026-04-05 19:24:57 +00:00
Evgeni Chasnovski
fdf94493cf fix(pack): use uv.available_parallelism() to compute number of threads #38717
Problem: Computing number of threads for parallel asynchronous
  computation using `uv.cpu_info()` can be slow. This is especially
  noticeable since it is pre-computed on every `require('vim.pack')` and
  not only when parallelism is needed.

Solution: Use `uv.available_parallelism()` to compute number of threads
  in a helper function.
(cherry picked from commit 3cba8df041)
2026-04-05 17:44:08 +00:00
luukvbaal
bac7c3a996 fix(ui2): update spill indicator when appending to expanded cmdline #38715
Problem:  When messages are appended to an already expanded cmdline,
          the spilled lines indicator is not updated.
Solution: Remove early return for updating virtual text while cmdline is
          expanded, guard updating "msg" virt_text at callsite instead.
(cherry picked from commit 2663f51890)
2026-04-05 14:10:13 +00:00
altermo
9f16ad8ca3 fix(treesitter): select reset to "v" visualmode()
(cherry picked from commit facc21cc63)
2026-04-02 13:49:39 +00:00
Justin M. Keyes
0142453543 backport: docs: misc #38692 2026-04-01 17:08:38 -04:00
Luis Calle
3de423eb20 perf(vim.pos): use nvim_buf_line_count instead of fetching all lines #38686
(cherry picked from commit 79a2235fd1)
2026-04-01 19:50:47 +00:00
phanium
dee6d2ad97 fix(ui2): vim.on_key should return nil instead of false (#38668)
(cherry picked from commit a2d9863c27)
2026-04-01 13:34:04 +00:00
zeertzjq
04fabbf32d vim-patch:9.2.0277: tests: test_modeline.vim fails (#38672)
Problem:  tests: test_modeline.vim fails (after v9.2.0276)
Solution: Rewrite the tests to use the existing s:modeline_fails()
          function, update documentation (zeertzjq).

8c8772c6b3
(cherry picked from commit 65e2218585)
2026-04-01 10:21:24 +00:00
neovim-backports[bot]
131a3cacb3 fix(ui2): prevent flicker when entering pager from expanded cmdline (#38662)
fix(ui2): flicker when entering pager from expanded cmdline #38639

Problem:  'showcmd' causes flickering when pressing "g<" to enter the
          pager when the cmdline is expanded for messages.
          Initial keypress for an incomplete mapping is not giving 'showcmd'
          feedback while cmdline is expanded for messages (which is only
          dismissed upon the vim.on_key callback after 'timeoutlen').

Solution: Delay dismissing expanded cmdline when vim.on_key() callback
          receives "g".
          Place 'showcmd' "last" virtual text during expanded cmdline.
(cherry picked from commit 75e5e37942)

Co-authored-by: luukvbaal <luukvbaal@gmail.com>
2026-03-31 20:41:20 -04:00
Yi Ming
8f7cbf6d66 fix(lsp): use winresetview() to avoid switching to normal mode (#38641)
(cherry picked from commit e31bfb81ce)
2026-03-31 16:54:30 +00:00
luukvbaal
14ee84e7a5 fix(cmdline): redraw cmdline after empty message (#38485)
Problem: Cmdline is not redrawn after an empty message clears it.
Remembered last drawn cursor position may be outdated but
equal to the current cmdline content with UI2.
Solution: Ensure cmdline is redrawn after an empty message clears it.
Compare wanted cursor position with actual cursor position.

(cherry picked from commit 1685ced335)
2026-03-31 13:25:43 +00:00
altermo
2d9619fac7 fix(treesitter): select with node ending with unicode char (#38557)
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
(cherry picked from commit 1bcf2d7f90)
2026-03-31 05:28:17 +00:00
zeertzjq
b2702913b9 fix(defaults): check for TUI on non-stdio channel on startup (#38581)
(cherry picked from commit da58fe8fd2)
2026-03-31 03:41:44 +00:00
Christian Clason
d83141c0f2 fix(ui2): allow empty argument for enable() #38605
Problem: `vim._core.ui2.enable` requires passing an empty table for
default options, unlike other (native) Lua API.

Solution: Initialize `opts` with empty table if `nil` is passed.
(cherry picked from commit e508aa0fa8)
2026-03-30 17:22:14 +00:00
Ayush Goyal
b924afb36b fix(ui2): correct buffer reference in msg:start_timer() (#38600)
Problem:  Mixing "buf" and "M.bufs.msg" in M.msg:start_timer().
          Cannot run `require("vim._core.ui2").enable(nil)`.
Solution: Replace "M.bufs.msg" with "buf". Allow `opts == nil`.

Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
(cherry picked from commit f50e7d8205)
2026-03-30 17:10:38 +00:00
skewb1k
edf4f5689d docs: fix syntax errors in examples #38606
(cherry picked from commit 2dce2af768)
2026-03-30 16:33:20 +00:00
Maria Solano
f2764a596d fix(lsp): reset document color processed version on clear (#38582)
(cherry picked from commit 92a667c07f)
2026-03-30 01:37:09 +00:00
Marcus Caisey
2eb14c54bc fix(lsp): highlight snippet preview when server can't completionItem/resolve (#38534)
Problem:
The snippet preview is not being highlighted by treesitter for
completion items from servers which don't support
`completionItem/resolve` (like gopls). This was broken by #38428.

Solution:
Call `update_popup_window` after updating the completion item with the
snippet preview.

I've added assertions to the `selecting an item triggers
completionItem/resolve + (snippet) preview` test case which covers the
snippet preview being shown since no tests failed when I removed the
`nvim__complete_set` call which actually populates the preview on this
codepath.
2026-03-29 14:48:11 -07:00