Commit Graph

4396 Commits

Author SHA1 Message Date
zeertzjq
93b3ea26ac vim-patch:9.2.0327: filetype: uv scripts are not detected (#38920)
Problem:  filetype: uv scripts are not detected
          (Asger Hautop Drewsen)
Solution: Detect uv scripts as python filetype if the shebang line
          contains "uv run"

Reference:
https://docs.astral.sh/uv/guides/scripts/#using-a-shebang-to-create-an-executable-file

fixes: vim/vim#19941

6c16ccaf61

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-04-10 07:28:24 +08:00
Yi Ming
f9e068117b refactor(lsp): share code by get_locations #38902
Problem:
`vim.lsp.buf.definition`/`vim.lsp.buf.declaration` use the same underlying code
via `get_locations`, whereas `vim.lsp.buf.reference` does not. This is because
`buf.reference` does not perform a jump when there is only one item.

Solution:
In #38510, I simplified the jump logic using `:cfirst`, so they can now share
code more easily. Additionally, this PR enables `buf.definition` to display the
corresponding qflist name.
2026-04-09 13:46:50 -04:00
Luis Calle
24811c0a14 fix(vim.pos): Range:intersect() drops buf #38898
new() only supports nargs=5 or nargs=2, but this was passing 4 args.
2026-04-09 11:01:28 -04:00
zeertzjq
9c5fba5df0 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().
2026-04-09 04:11:32 +00:00
Jordan
3a4a66017b feat(api): rename buffer to buf #35330
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: Justin M. Keyes <justinkz@gmail.com>
2026-04-08 20:34:47 -04:00
zeertzjq
eefb50e352 vim-patch:9.2.0323: filetype: buf.lock files are not recognized (#38897)
Problem:  filetype: buf.lock files are not recognized
Solution: Detect buf.lock files as yaml filetype
          (Stefan VanBuren)

Reference:
https://buf.build/docs/configuration/v2/buf-lock/

closes: vim/vim#19935

c2734dc03c

Co-authored-by: Stefan VanBuren <svanburen@buf.build>
2026-04-08 23:11:20 +00:00
glepnir
6473d007e7 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.
2026-04-08 17:10:52 -04:00
Sean Dewar
eaea0c0f9d 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 21:48:38 +01:00
Maria Solano
665ebce569 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.
2026-04-08 16:11:01 -04:00
ngicks
a165eee64f 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 13:33:00 -04:00
Justin M. Keyes
7e4d484c9d 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 13:31:37 -04:00
Barrett Ruth
20a3254ad4 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()`.
2026-04-08 12:30:35 -04:00
Luis Calle
c530fd8e75 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.
2026-04-08 11:38:27 -04:00
Dan Drennan
65ef6cec1c 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
2026-04-08 04:33:26 -04:00
zeertzjq
b36eafd5da vim-patch:794c304: runtime(doc): clarify incsearch feature and typed chars (#38830)
fixes: vim/vim#19886

794c304479

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-04-07 06:22:45 +08:00
glepnir
af707dd242 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.
2026-04-06 13:22:39 -04:00
Christian Clason
bdc72a0843 feat(filetype): vim.filetype.inspect() returns copy of registry #38831
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 12:48:42 -04:00
Luis Calle
01be30f638 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
2026-04-06 11:51:36 -04:00
Justin M. Keyes
42f6c55139 Merge #38796 from justinmk/doc2 2026-04-05 20:36:45 -04:00
Evgeni Chasnovski
157c7bccb0 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.
2026-04-05 20:35:14 -04:00
Justin M. Keyes
6b796696c3 docs: statusline
fix https://github.com/neovim/neovim/issues/38670
2026-04-06 02:29:29 +02:00
Olivia Kinnear
13faa0ef84 feat(defaults): :Open without args opens current file #38776
Problem:
Running `:Open` on an open buffer does not run `vim.ui.open()` on that file, requiring the user to type `:Open %`. This is inconsistent with most other vim commands which accept files, which default to the current buffer's file.

Solution:
Default to the current file when `:Open` is used without arguments.
2026-04-05 19:46:45 -04:00
Yi Ming
909fc0b992 fix(lsp): do not respond to codelens refresh if a request is already scheduled (#38801) 2026-04-05 13:54:27 -07:00
Yochem van Rosmalen
398ee83f4f 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.
2026-04-05 13:11:59 -04:00
Evgeni Chasnovski
3cba8df041 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.
2026-04-05 13:06:00 -04:00
luukvbaal
2663f51890 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.
2026-04-05 09:48:38 -04:00
zeertzjq
20e46cb38d vim-patch:af58a9f: runtime(doc): adjust :h 'autowrite' and :h 'autowriteall'
- Don't go over 78 columns.
- Change the first "and" to "or", as "or" is used below.
- Change "takes one" to "switches", as "one" may be mistaken as
  referring to the command instead of the user.
- Use backticks in :h 'autowriteall' like in :h 'autowrite'.

closes: vim/vim#19859

af58a9f5e9
2026-04-04 06:04:28 +08:00
zeertzjq
76a917a81e vim-patch:9.2.0267: 'autowrite' not triggered for :term
Problem:  'autowrite' not triggered for :term
Solution: Trigger autowrite for :term command
          (rendcrx)

closes: vim/vim#19855

466b5f531a

Co-authored-by: rendcrx <974449413@qq.com>
2026-04-04 06:04:25 +08:00
zeertzjq
333e3178ec vim-patch:9.2.0287: filetype: not all ObjectScript routines are recognized (#38731)
Problem:  filetype: not all ObjectScript routines are recognized
Solution: Also detect "%RO" and "iris" patterns inside *.rtn files
          (Hannah Kimura)

closes: vim/vim#19873

863e85e00a

Co-authored-by: Hannah <hannah.kimura@intersystems.com>
2026-04-03 18:26:04 +08:00
Yi Ming
0eb2eb4106 refactor(lsp): remove implicit rpc error tostring #38707
Problem:
LSP error responses implicitly rely on a custom `__tostring` function
(`vim.lsp.rpc.format_rpc_error`) for formatting. This causes errors that are not
created via `vim.lsp.rpc.error` to behave inconsistently with those that are.

Furthermore, we usually use `log.error` to print these errors, which uses
`vim.inspect` under the hood, so the custom `__tostring`  provides little
benefit.

This increases the difficulty of refactoring the code, as it tightly couples RPC
error handling with the LSP.

Solution:
Convert every potential `__tostring` call to an explicit one. Since we don't
describe this behavior in the documentation, this should not be a breaking
change.
2026-04-02 08:53:29 -04:00
altermo
facc21cc63 fix(treesitter): select reset to "v" visualmode() 2026-04-02 14:29:09 +02:00
Justin M. Keyes
68c26b344b docs: misc #38584 2026-04-01 17:04:41 -04:00
Justin M. Keyes
202f67dce3 Merge #38560 refactor vim.lsp.rpc 2026-04-01 16:46:59 -04:00
Luis Calle
79a2235fd1 perf(vim.pos): use nvim_buf_line_count instead of fetching all lines #38686 2026-04-01 15:28:31 -04:00
phanium
a2d9863c27 fix(ui2): vim.on_key should return nil instead of false (#38668) 2026-04-01 15:07:26 +02:00
Yi Ming
dbd93de62a refactor(lsp): better encapsulation and readability, inline unnecessary 2026-04-01 18:16:40 +08:00
zeertzjq
65e2218585 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
2026-04-01 08:43:03 +00:00
luukvbaal
75e5e37942 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.
2026-03-31 15:01:58 -04:00
Yi Ming
e31bfb81ce fix(lsp): use winresetview() to avoid switching to normal mode (#38641) 2026-03-31 09:31:30 -07:00
luukvbaal
1685ced335 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.
2026-03-31 14:16:55 +02:00
altermo
1bcf2d7f90 fix(treesitter): select with node ending with unicode char (#38557)
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2026-03-31 13:03:18 +08:00
zeertzjq
da58fe8fd2 fix(defaults): check for TUI on non-stdio channel on startup (#38581) 2026-03-31 11:17:33 +08:00
Christian Clason
e508aa0fa8 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.
2026-03-30 16:47:02 +00:00
Ayush Goyal
f50e7d8205 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>
2026-03-30 16:36:45 +00:00
skewb1k
2dce2af768 docs: fix syntax errors in examples #38606 2026-03-30 11:49:30 -04:00
Yi Ming
57797ed7d4 feat(lsp): respect 'switchbuf' for jump commands, drop reuse_win #38510
Problem:
LSP jump operations such as `buf.definition`/`buf.type_definition` do
not follow the 'switchbuf' option. Instead their behavior is controlled
by `vim.lsp.LocationOpts.reuse_win`. When `reuse_win=true`, the effect
is very similar to `set switchbuf=useopen`.

Note that functions like `buf.definition` open the quickfix
window when there are multiple results, and jumping between quickfix
entries already follows 'switchbuf', so unifying the behavior is more
intuitive.

Solution:
Follow the 'switchbuf' option and drop `reuse_win`.

We can achieve this behavior by using :cfirst when the quickfix list has
only one item, rather than customizing the jump logic as before.
2026-03-30 10:54:55 -04:00
Yi Ming
4784f96e59 refactor(lsp): merge vim.lsp.rpc.Client and vim.lsp.rpc.PublicClient 2026-03-30 10:59:51 +08:00
Maria Solano
92a667c07f fix(lsp): reset document color processed version on clear (#38582) 2026-03-29 18:20:27 -07: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
Justin M. Keyes
d9d3822a7b docs: misc #38532
Close #38431
Close #38521
Close #38530

Co-authored-by: tayheau <thopsore@pasteur.fr>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Olivia Kinnear <git@superatomic.dev>
2026-03-29 11:56:37 -04:00