Commit Graph

4685 Commits

Author SHA1 Message Date
Oleksandr Chekhovskyi
400f247397 feat(autoread): use filewatchers for OS-driven change detection #37971
Problem:
The 'autoread' option only checks for file changes reactively — on
FocusGained, :checktime, CmdlineEnter, etc. — by polling timestamps.
External changes are not detected until the user interacts with Neovim.

Solution:
Add a core module (runtime/lua/nvim/autoread.lua) enabled from
runtime/plugin/autoread.lua that watches each buffer's file using
vim._watch.watch() (libuv fs_event). On change detection it calls
:checktime, which invokes the existing buf_check_timestamp() logic
for reload/prompt handling. Watchers are managed via autocmds tied
to buffer lifecycle events and respect the 'autoread' option (global
and buffer-local).
2026-06-12 18:25:15 -04:00
Jay Madden
3ed78daf83 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)
2026-06-11 17:16:54 -04:00
Justin M. Keyes
a6584b205c docs: misc 2026-06-11 13:35:19 +02:00
Aaron Tinio
d42f7ee9dc fix(lsp): trailing blank line when edit inserts past end of buffer #40133
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.
2026-06-10 23:25:13 +00:00
Tristan Knight
16549f2f40 fix(lsp): refresh codelens despite pending debounce #40154
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.
2026-06-10 19:18:48 -04:00
tao
b49492f13c fix(option): set 'shell…' options based on detected shell #40031
Problem:
* 'shellcmdflag' states that its default value is set according to the
  value of 'shell', but this behavior is not yet implemented on Windows.
  The same applies to 'shellpipe', 'shellredir', and 'shellxquote'.
* On Windows, Git is often installed in paths containing spaces, and we
  still do not correctly resolve the sh executable name as described in
  'shell'.
* On Windows, the default value of 'shellslash' is always `false`,
  which causes Unix-like shells to interpret `\` in paths returned by
  some functions as escape charaters.

Solution:
Use a simple rule table to detect common shells (e.g. `cmd`,
`powershell`, shells whose names contain `csh` or `sh`) and apply
best-effort defaults, while leaving more complex scenarios to user
configuration.
2026-06-10 17:28:17 -04:00
Tristan Knight
2899e350ff docs(lsp): bump protocol/meta to 3.18 #37273
fixes glob spec regression related to "zero or more" vs "one or more" for `*`
ref: https://github.com/microsoft/language-server-protocol/issues/2217
2026-06-10 17:02:12 -04:00
zeertzjq
268cd370be vim-patch:595d0a7: runtime(doc): wrong {str} length limit in matchfuzzy() docs (#40157)
Problem:  docs say {str} is capped at 256 and longer returns an empty list.
Solution: it's 1024, and {str} plus each candidate are just truncated to
          that, not rejected; fix the text.

closes: vim/vim#20453

595d0a77e4

Co-authored-by: glepnir <glephunter@gmail.com>
2026-06-10 01:18:26 +00:00
Justin M. Keyes
8f584031bc docs: misc #40126 2026-06-08 16:12:14 -04:00
jreidx
d9aa06eed8 feat(extmark): virt_lines_overflow "wrap" and "auto"
Problem: Extmark has support for horizontal scrolling and truncating, but not wrapping.

Solution: Extend virt_lines_overflow flags to support "wrap" and "auto" based on proposed changes in #18282.
2026-06-08 22:19:25 +08:00
zeertzjq
4ab670399b vim-patch:9.2.0596: cmdline completion popup cannot be scrolled with the mouse (#40142)
Problem:  In command-line completion with a popup menu ('wildoptions'
          contains "pum"), the info popup shown next to the menu could
          not be scrolled, unlike the Insert mode completion info popup
          which scrolls with the mouse wheel.
Solution: When the mouse pointer is on top of the info popup, scroll it
          with the mouse wheel in command-line mode as well, without
          closing the completion popup menu.

closes: vim/vim#20146
closes: vim/vim#20418

96dbab257a

Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-08 20:53:10 +08:00
Justin M. Keyes
ec7dab077b 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.
2026-06-06 10:26:12 +00:00
glepnir
11b9e6f193 fix(option): allow empty/blank edges in 'winborder' #40112
Problem:
The comma form of 'winborder' is split with copy_option_part(),
whose skip_to_option_part() eats spaces after a comma, and empty
fields are rejected.

Solution:
Split the comma form literally on ',', keeping empty fields and
single-space fields.
2026-06-05 06:37:07 -04:00
Yi Ming
fecc151d03 fix(lsp): always respond to requests, even on handler error #40076
Problem:
We perform validations after the request handler is called.
When these validations fail, `error()` and `assert()` will prevent the
subsequent code from running, meaning the server will never receive a response.

Solution:
Always respond to requests.
2026-06-04 07:02:19 -04:00
Justin M. Keyes
85b607d797 Merge #40088 from justinmk/doc2
docs: misc, lsp
2026-06-03 16:57:13 -04:00
zeertzjq
fa5ed94852 vim-patch:9.2.0589: filetype: xinitrc files are not recognized (#40102)
Problem:  filetype: xinitrc files are not recognized
Solution: Detect xinitrc and xserverrc files as sh filetype
          (Enrico Maria De Angelis)

Reference:
https://wiki.archlinux.org/title/Xinit#Configuration

closes: vim/vim#20419

5b76ddcc52

Co-authored-by: Enrico Maria De Angelis <enricomaria.dean6elis@gmail.com>
2026-06-03 22:12:11 +02:00
Justin M. Keyes
cbadc4f164 docs: misc, lsp
Problem:
This doc on `vim.lsp.completion.get()`:

    --- Used by the default LSP |omnicompletion| provider |vim.lsp.omnifunc()|, thus |i_CTRL-X_CTRL-O|
    --- invokes this in LSP-enabled buffers. Use CTRL-Y to select an item from the completion menu.
    --- |complete_CTRL-Y|

...makes two wrong claims:

1. "Used by the default LSP omnicompletion provider vim.lsp.omnifunc()"
    - `_omnifunc` does not call `M.get()`, it calls the internal `trigger()` directly.
2. "thus |i_CTRL-X_CTRL-O| invokes this in LSP-enabled buffers"
    - The two paths use different client sets:
        - `M.get()` reads `buf_handles[bufnr].clients` (clients
          explicitly registered via `vim.lsp.completion.enable(true, ...)`).
        - `_omnifunc` reads `lsp.get_clients({method='textDocument/completion'})` (every
          completion client, regardless of `enable()`).

Solution:
Update docs.

Co-authored-by: Koichi Shiraishi <zchee.io@gmail.com>
Co-authored-by: y9san9 / Alex Sokol <y9san9@gmail.com>
Co-authored-by: adv0r <>
2026-06-03 12:27:30 +02:00
Artem Krinitsyn
738cd366f9 fix(diagnostic): stack _tags hl-groups in a single extmark #38654
Problem:
Diagnostic highlight groups were applied by iterating and calling
`vim.hl.range` for each group individually. That resulted in multiple
extmarks with the same priority being created separately, which does not
allow `DiagnosticUnnecessary` and `DiagnosticDeprecated` with matching
options override `Diagnostic*` styling.

Solution:
Pass the list of hl-groups to `vim.hl.range` so they are applied
together in the correct order.
2026-06-02 18:36:03 -04:00
Yi Ming
cf9ad39267 fix(lsp): handle requests with null id #40073
Problem:
PR #38340 prevented messages we receive with id:null from being
incorrectly classified as notifications, but caused us to ignore all
messages with id:null, including requests.

Solution:
Handle requests with id:null. When we receive a request, we only need to
respond based on the `method` and `param`.

(The original so-called `notification_received` in the test was actually
semantically `request_or_notification_received`.)
2026-06-02 17:39:56 -04:00
Justin M. Keyes
7f233449f1 Merge #40083 from ofseed/pos-get-lines-improve
fix(pos): various improvements on `pos._util.get_lines()`
2026-06-02 09:56:49 -04:00
Justin M. Keyes
70f8c7bbf3 Merge #40057 from luukvbaal/hidenodraw
perf(redraw): don't redraw hidden windows
2026-06-02 08:51:08 -04:00
Yi Ming
a7408beae3 refactor(net): parameterize transport logging #40022 2026-06-02 08:41:36 -04:00
Yi Ming
241a725e17 fix(pos): get_lines() return empty table when file opening fails
Problem:
`get_lines()` may returns empty table when file opening fails,
so every existing caller use `get_line() or ''` to avoid nil result.

This also does not match the annotated return type of `get_line()`,
which is `string` instead of `string?`.

Solution:
Make `get_line()` return empty string when file opening fails.
2026-06-02 18:17:03 +08:00
Yi Ming
5beb751ef5 fix(pos): get_lines() never correctly fallbacks to empty string
Problem:
`nvim_buf_get_lines` will always returns a table,
so the `or` operator will never be used, letting `lines[row]` may be `nil`

Solution:
Fix it.
2026-06-02 18:15:48 +08:00
Yi Ming
d369979328 refactor(pos): remove unnecessary code of get_lines(), tidy up
Problem:
`get_lines()` actually supports passing a `integer` instead of `integer[]`,
but it is never used in this way, we use `get_line()` instead.

Solution:
Fix it. Also rename some variables to align with our current naming convention
and use `vim.fn.readblob()` instead  of a bunch of `uv` calls.
2026-06-02 18:15:44 +08:00
bfredl
49dc3d9424 build(zig): run oldtests in zig builds with new lua runner
The new lua based runner replaces Makefile, runnvim.sh and runnvim.vim

As it happens, we run a `--headless` nvim inside a `:terminal` layer,
this is pointless.
Also there is still a lot remnants for oldesttests, but we don't
have any except for test1.in which just checks the environment
for following, nonexistant oldesttests. so just skip that.

For now, the actual vimscript code which runs in vim-under-test is
completely unchanged.

On macos, luajit is finally working with the latest ziglua master.
Also fix some minor bugs regarding locales, such as incorrect
HAVE_WORKING_LIBINTL checks
2026-06-02 11:12:11 +02:00
zeertzjq
edcaf1887a vim-patch:partial:9.2.0573: Vim9: missing EX_WHOLE on some block keywords (#40071)
Problem:  Several Vim9 keywords lack EX_WHOLE and can be shortened in
          Vim9 script, inconsistent with endif/enddef/endfor/endwhile/
          endtry which already have it.  The error from :endd in a
          nested function also hardcodes "enddef" instead of reporting
          what the user typed.  fullcommand("ho") returns "horizontal"
          even though :ho is below the documented 3-char minimum.
Solution: Add EX_WHOLE to :class, :def, :endclass, :endinterface,
          :endenum, :public and :static.  In get_function_body() pass
          the user-typed command to the error message.  Force :ho to
          CMD_SIZE in find_ex_command() so fullcommand() reflects the
          modifier minimum.  Extend tests and documentation accordingly
          (Peter Kenny).

fixes:  vim/vim#20032
closes: vim/vim#20191

38d9a16eba

Co-authored-by: Peter Kenny <github.com@k1w1.cyou>
2026-06-01 01:04:30 +00:00
Luuk van Baal
253378f86a perf(redraw): don't redraw hidden windows
Problem:  Hidden windows are redrawn unnecessarily.
Solution: If a window is hidden, don't bother drawing it.
2026-05-31 23:15:39 +02:00
Justin M. Keyes
f5fae7aa5c docs: misc, options, pos/range 2026-05-30 12:57:24 +02:00
Justin M. Keyes
88f3f0eeec fix(health): sort "Active Features" by name 2026-05-30 12:57:24 +02:00
zeertzjq
37abcdd044 vim-patch:9.2.0562: filetype: SGF files are not recognized
Problem:  filetype: SGF files are not recognized
Solution: Detect *.sgf as sgf filetype
          (Borys Lykah)

Reference:
https://www.red-bean.com/sgf/index.html

closes: vim/vim#20349

dda45ba88f

Co-authored-by: Borys Lykah <lykahb@fastmail.com>
2026-05-30 11:49:08 +08:00
zeertzjq
8b5a8c12cd vim-patch:9.2.0560: filetype: busybox shebang lines are not recognized
Problem:  filetype: busybox shebang lines are not recognized
Solution: Add filetype detection pattern for #!busybox sh, detect
          ash as shell in the shebang lines (Christoffer Aasted).

closes: vim/vim#20358

69f402e97f

Co-authored-by: Christoffer Aasted <dezzadk@gmail.com>
2026-05-30 11:41:23 +08:00
zeertzjq
06c7859220 vim-patch:9.2.0559: filetype: Kaitai struct files are not recogonized
Problem:  filetype: Kaitai struct files are not recogonized
Solution: Detect *.ksy files as yaml filetype (Wu, Zhenyu)

Reference:
https://doc.kaitai.io/

closes: vim/vim#20353

73e619d699

Co-authored-by: Wu, Zhenyu <wuzhenyu@ustc.edu>
2026-05-30 11:38:58 +08:00
zeertzjq
915fd47601 vim-patch:9.2.0558: filetype: Popcap Reanimation files are not recognized
Problem:  filetype: Popcap Reanimation files are not recognized
Solution: Recognize *.reanim files as xml filetype (Wu, Zhenyu).

Reference:
https://github.com/wszqkzqk/PvZ-Portable

closes: vim/vim#20354

c83d2f888e

Co-authored-by: Wu, Zhenyu <wuzhenyu@ustc.edu>
2026-05-30 11:37:01 +08:00
zeertzjq
75a1e1a848 vim-patch:9.2.0557: filetype: Kawasaki Robots files are not recognized
Problem:  filetype: Kawasaki Robots files are not recognized
Solution: Detect *.pg as kawasaki_as filetype, add filetype detection
          for *.as as atlas or kawasaki_as filetype (KnoP-01).

In Kawasaki robots (https://kawasakirobotics.com/products-robots/)
AS language

*.pg is the extention for a program file and
*.as is for a complete backup.

closes: vim/vim#20370

dec3d6c7da

Co-authored-by: KnoP-01 <knosowski@graeffrobotics.de>
2026-05-30 11:34:48 +08:00
Olivia Kinnear
e728c100b5 feat(lua): support table lhs in vim.keymap.set()/del() #39948
Problem:
It is repetitive to map multiple keymaps to do the same thing. Here are some
cases where being able to do this would be useful:

    -- Visual movement for both j/k and down/up:
    vim.keymap.set({ 'n', 'x' }, { 'j', '<Down>' }, 'v:count == 0 ? "gj" : "j"', { expr = true })
    vim.keymap.set({ 'n', 'x' }, { 'k', '<Up>' }, 'v:count == 0 ? "gk" : "k"', { expr = true })
    -- Map multiple keys to `<Nop>` concisely:
    vim.keymap.set({ 'n', 'x' }, { '<Leader>', '<Localleader>', '<CR>' }, '<Nop>')
    -- Remove multiple keymaps at once:
    vim.keymap.del('n', { 'gri', 'grn', 'grr' })

Solution:
Support the `lhs` of `vim.keymap.set()` and `vim.keymap.del()` being a table, in
the same way that `modes` can be.
2026-05-29 14:45:33 -04:00
abdulahmoda
4b5f026ac9 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.
2026-05-29 14:24:22 -04:00
atusy
ac352a6df6 docs(treesitter): describe pattern_id of captures 2026-05-29 13:09:29 +02:00
zeertzjq
df1f8a60cf vim-patch:9.2.0551: filetype: Tolk files are not recognized
Problem:  filetype: Tolk files are not recognized
Solution: Detect *.tolk files as tolk filetype, include a syntax and
          filetype plugin (redavy)

Tolk is a new-generation language for writing smart contracts on TON
blockchain, which is vim/vim#1 in speed among other chains.

Reference:
https://docs.ton.org/blockchain-basics/tolk/overview

closes: vim/vim#20320

b9bba99712

Co-authored-by: redavy <hello.redavy@proton.me>
2026-05-29 09:06:12 +08:00
Yi Ming
5d85669a33 refactor: rename vim.transport to vim.net.transport #40021 2026-05-28 10:37:45 -04:00
Puneet Dixit
5acb2a1d33 docs(lsp): document on_list deduplication #39941
Problem:
Deduplicating LSP locations in the default handler changes list behavior for every user, while some configurations may intentionally return matching locations from multiple clients.

Solution:
Document how users can deduplicate locations in an on_list handler with vim.list.unique().

Co-authored-by: Deepak kudi <deepakkudi23@adsl-172-10-9-116.dsl.sndg02.sbcglobal.net>
Co-authored-by: Puneet Dixit <236133619+puneetdixit200@users.noreply.github.com>
2026-05-27 10:21:45 -04:00
luukvbaal
cad5a4cf5c fix(lsp): unwanted redraw for buffer not in window #40002
Problem:  Redrawing when a loaded buffer is not shown in any window on
          the current tabpage.
Solution: Check that buffer is shown in a (normal) window before redrawing.
2026-05-27 09:27:25 -04:00
zeertzjq
b3dfa86e02 vim-patch:9.2.0539: filetype: too many Bitbake include files are recognized (#40014)
Problem:  filetype: too many Bitbake include files are recognized
          (Brahmajit Das, after v9.1.1732)
Solution: Tighten the pattern to detect BitBake include files, update
          tests (Martin Schwan).

Be more strict when detecting BitBake inc files. In particular, only
match include keywords and variable assignments at the beginning of a
line (excluding whitespace).

Use non-capturing groups to slightly improve performance.

Use regex or-operators to exactly match BitBake assignment operators.
The previous expression would falsely match

    FOO .=. "bar"

, which is not valid BitBake syntax. The new capturing group is more
specific and matches only valid assignments.

fixes:  vim/vim#20288
closes: vim/vim#20335

2df68c8e4b

Co-authored-by: Martin Schwan <m.schwan@phytec.de>
2026-05-27 07:12:53 +08:00
zeertzjq
d214c24129 vim-patch:9.2.0538: Cannot keep leading whitespace in %{} statusline expr (#40007)
Problem:  A leading space in the result of a %{} item is sometimes
          stripped, and an all-digit result is converted to a number.
Solution: Add %0{} atom which inserts the expression result verbatim
          (glepnir)

fixes:  vim/vim#3898
closes: vim/vim#20315

e8d7a40b98

Co-authored-by: glepnir <glephunter@gmail.com>
2026-05-26 01:04:24 +00:00
acehinnnqru
a9d7cbd722 fix(lsp): calc correct screen_width when opts.relative == 'editor' (#39977) 2026-05-24 15:00:53 -07:00
zeertzjq
f53d9ac90b vim-patch:c7645fc: runtime(doc): add a few references to mouse behaviour (#39959)
fixes: vim/vim#20281

c7645fcda5

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-05-23 07:47:49 +08:00
Yi Ming
680ab13951 refactor(lsp): avoid using coroutine when parsing frames 2026-05-22 18:20:55 +08:00
Yi Ming
0e81835fae refactor(lsp): message stream abstraction for message framing 2026-05-22 18:20:51 +08:00
Yi Ming
929e644a5a refactor(lsp): move vim.lsp._transport to vim.net._transport 2026-05-22 18:19:19 +08:00
Justin M. Keyes
b576807410 Merge #39939 from marcuscaisey/lsp-completion-details 2026-05-22 04:39:55 -04:00