Commit Graph

10973 Commits

Author SHA1 Message Date
Justin M. Keyes
d34cfe1cb8 fix(autoread): handle autocmd errors
Problem:
Any random ftplugin or other autocmd, can throw an error when
`:checktime` reloads a buffer. This causes a trace which makes it look
like an issue with `autoread.lua`.

    vim.schedule callback: …/runtime/lua/nvim/autoread.lua:146:
    FileType Autocommands for "*"..function <SNR>1_LoadFTPlugin[20] ..script
    …/runtime/ftplugin/help.lua: Vim(runtime):E5113: Lua chunk:
    …/runtime/lua/vim/treesitter.lua:216: Index out of bounds
    stack traceback:
    [C]: in function 'nvim_buf_get_text'
    …/runtime/lua/vim/treesitter.lua:216: in function 'get_node_text'
    …/runtime/lua/vim/treesitter/query.lua:558: in function 'handler'
    …/runtime/lua/vim/treesitter/query.lua:843: in function '_match_predicates'
    …/runtime/lua/vim/treesitter/query.lua:1082: in function '(for generator)'
    …/runtime/ftplugin/help.lua:91: in function 'runnables'
    …/runtime/ftplugin/help.lua:124: in main chunk
    [C]: in function 'checktime'
    …/runtime/lua/nvim/autoread.lua:146: in function <…/runtime/lua/nvim/autoread.lua:138>

Solution:
Use pcall() and surface the error via nvim_echo.
2026-06-14 22:00:38 +02:00
Justin M. Keyes
2abb9785d3 feat(autoread): surface autoread activity via 'busy' flag
Problem:
Old 'autoread' only did `:checktime` on focus-change and shell (":!")
commands, and only for non-hidden buffers. Since 'autoread' is now
driven by OS filewatcher events, buffers are updated much more eagerly.
This should be surfaced to the user somehow, either via a carefully
placed notification, or a minimal UI indicator.

A "notification" would be noisy, unless it is conditional on specific
circumstances (e.g. when "many" buffers are updated).

Solution:
Use the existing 'busy' buffer-local option as a subtle hint about
activity.
2026-06-14 22:00:38 +02:00
Justin M. Keyes
6f3446c970 Merge #40087 from ofseed/pos-util-follow-up
feat(pos): create a cursor position by using the current of a window
2026-06-14 12:42:52 -04:00
jdrouhard
3d6393540e feat(lsp): use LspNotify for semantic tokens #40224
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.
2026-06-14 11:10:59 -04:00
glepnir
2e8c60cb38 vim-patch:9.2.0624: C-N/C-P cannot be mapped in complete() completion (#40232)
Problem:  Keys valid in CTRL-X mode are never mapped while insert
          completion is active, so <C-N> and <C-P> cannot be remapped
          for completion started by complete().
Solution: Do not disable mappings in CTRL_X_EVAL mode.  In this mode a
          mapping cannot interfere with selecting the completion
          method, which is what the no-mapping rule exists for.

related: vim/vim#6440
related: vim/vim#16880
closes:  vim/vim#20489

076585e6ad

Co-authored-by: Thomas M Kehrenberg <tmke8@posteo.net>
2026-06-14 05:15:07 +00:00
zeertzjq
e997599894 vim-patch:9.2.0640: the "%" command jumps to parens and braces inside comments (#40229)
Problem:  The "%" command jumps to parens and braces inside comments,
          unlike the "=" operator (cindent), which ignores them.
Solution: When 'comments' defines C-style comments and "%" is not in
          'cpoptions', skip matching parens inside such comments, except
          when the cursor is inside a comment so a match there can still
          be found.

fixes:   vim/vim#20329
related: vim/vim#20111
closes:  vim/vim#20491

b8a109dcfb

Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 10:52:50 +08:00
zeertzjq
8ea5747f6d vim-patch:1fee3cd: runtime(beancount): Include Beancount runtime files
Include with adjustments from the upstream repo:
https://github.com/nathangrigg/vim-beancount

closes: vim/vim#20373

1fee3cd4b9

Co-authored-by: Bruno BELANYI <bruno@belanyi.fr>
2026-06-14 09:37:00 +08:00
zeertzjq
439a8d9714 vim-patch:ff7fcb8: runtime(pfmain): Add smtp_destination_rate_delay to syntax script
closes: vim/vim#20505

ff7fcb8f01

Co-authored-by: Leo Feyer <1192057+leofeyer@users.noreply.github.com>
2026-06-14 09:31:54 +08:00
Justin M. Keyes
aeea633deb test(autoread): make "debounce" test actually valid 2026-06-13 20:55:49 +02:00
Justin M. Keyes
1d33a81751 test(autoread): cleanup
- Merged into the main "reloads on external change" test.
- Reduce duplication.
- Wall-clock down from ~4.4s to ~1.4s (dropped 3s debounce test).
2026-06-13 20:54:00 +02:00
Evgeni Chasnovski
e9b9426d7d fix(filetype): vim.filetype.match fails if CWD goes missing #40190
Problem: Running `vim.filetype.match()` when current working directory
  was removed from disk throws a `vim.fs.abspath` assertion error.
  However, the matching might still be possible without trying to match
  against full path (like if it is a known extension).

Solution: Safely compute absolute path and ignore it if it errors.
2026-06-13 13:20:45 -04:00
John Reid
d52ebe317d feat(diagnostic): add virt_lines_overflow option for virtual_lines #40178
Problem: Diagnostic virtual lines are hardcoded with "scroll" for
virt_lines_overflow option.

Solution: Add a `overflow` option to `virtual_lines` config
to support "wrap", "scroll", "trunc", and "auto".
2026-06-13 04:20:20 -04:00
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
zeertzjq
8c4578cc4f vim-patch:78094ff: runtime(vim): Update base syntax, simplify function call matching (#40202)
- Explicitly match the dot accessor
- Exclude the qualifier when matching qualified function calls

The dot accessor lookbehind on builtin function calls was slow, matching
across expression based dictionary accessors was visually inconsistent,
and it's arguably more semantically correct.

closes: vim/vim#20481

78094ff1d7

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2026-06-12 18:38:27 +08: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
5469fa8038 fix(docs): numbered listitems 2026-06-11 13:35:19 +02:00
Justin M. Keyes
a6584b205c docs: misc 2026-06-11 13:35:19 +02:00
Tomas Slusny
2fd2361a9d 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>
2026-06-11 06:15:04 -04:00
zeertzjq
2b8e4f6988 vim-patch:9.2.0620: runtime(netrw): fix 2match pattern rebuild (#40179)
Problem:  unmarking a regular file when there are directories in the markings
          list also removes the 2match highlight from those directories.
Solution: correctly rebuild the match pattern from the remaining markings,
          using the right regex trailer for each entry in the list.

closes: vim/vim#20461

affd4b5964

Co-authored-by: J. Paulo Seibt <jpseibt@gmail.com>
2026-06-11 02:16:15 +00: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
Yi Ming
f79999270e feat(pos)!: match return value of to_cursor() with parameters of cursor()
Problem:
- `pos.cursor()` receives a table contains `row` and `col` as arguments,
  but `pos:to_cursor` returns `row` and `col` directly
  without wrapping them in a table.
- `pos.mark()`/`pos:to_mark` can already handle unpacked `row` `col`.

Solution:
Make `pos:to_cursor()` return a `row` and `col` in a table.
2026-06-08 19:52:51 +08:00
Yi Ming
2bd13177b8 feat(pos): create a cursor position by using the current of a window
Problem:
`vim.pos.cursor(vim.api.nvim_get_current_buf(win), vim.api.nvim_win_get_cursor(win))`
is too verbose to create a cursor position of a window,
but it is a common use case.

Solution:
Overload `vim.pos.cursor()`, so that it accepts `win` as an argument when `pos` is omitted.
2026-06-08 19:52:51 +08:00
zeertzjq
7367ab0d79 vim-patch:19a5020: runtime(doc): Fix paypal link
19a5020347

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-06-08 11:43:52 +08:00
zeertzjq
a28b619956 vim-patch:4eb50ba: runtime(nsis): Update NSIS plugin
closes: vim/vim#20439

4eb50ba61c

Co-authored-by: K.Takata <kentkt@csc.jp>
2026-06-08 11:43:36 +08:00
zeertzjq
413731d0b1 vim-patch:1fa6fed: runtime(javascript): add 'Symbol' as a type; add 'void' as a reserved word
closes: vim/vim#20440

1fa6fed846

Co-authored-by: Ilia Dubovik <askdubovik@gmail.com>
2026-06-08 11:43:14 +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
zeertzjq
e887cfb3b5 vim-patch:9.2.0597: [security]: possible code execution with python complete (#40117)
Problem:  [security]: another possible code execution with python complete
          (David Carliez)
Solution: Strip default expressions and annotations from generated
          source for pythoncomplete and python3complete.

Github Security Advisory:
https://github.com/vim/vim/security/advisories/GHSA-65p9-mwwx-7468

c8c63673bc

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-06-05 04:59:44 +02:00
bfredl
03aff28b73 feat(startup)!: "standalone" mode -ll is kill
This was originally used because we needed a lua interpreter to run the
standalone _busted_ lua application (except we used fuckery behind the
scenes to fake its binary dependencies with our own binary
dependencies). Now we longer do that, we instead run `test.harness` as a
standard nvim -l script. as this mode is no longer used in tests it
risks going to bitrot anyway.

NB: -ll mode still had some theoretical benefits like quicker
initialization and more "native" printing behavior, etc.
But we can incrementally work on "nvim -l" mode instead
of maintaining a separate special thing.
2026-06-04 14:35:41 +02: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
bfredl
d8e9593024 feat(build.zig): easier cross-complilation
invocation of cross-compilation changed, see news.txt blurb
2026-06-04 11:33:35 +02:00
Justin M. Keyes
85b607d797 Merge #40088 from justinmk/doc2
docs: misc, lsp
2026-06-03 16:57:13 -04:00
zeertzjq
b6511b717a vim-patch:dec5b3a: runtime(doc): Update mapping descriptions (#40104)
closes: vim/vim#20411

dec5b3a72a

Co-authored-by: nyngwang <nyngwang@gmail.com>
2026-06-03 20:28:41 +00:00
zeertzjq
845616ee93 vim-patch:8eceeba: runtime(kitty): Fix regex for kittyMapSeq region (#40103)
closes: vim/vim#20422

8eceebae71

Co-authored-by: bbnolauv <86621528+bbnolauv@users.noreply.github.com>
2026-06-03 22:12:22 +02: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
zeertzjq
31a8bf1a63 vim-patch:de18ef6: runtime(doc): Tweak documentation style (#40093)
closes: vim/vim#20412

de18ef6284

Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
2026-06-02 18:55:44 +00:00
zeertzjq
75ee4272a6 vim-patch:7895c9e: runtime(vim): Update ftplugin, add heredocs to b:match_words (#40091)
This depends on chrisbra/matchit#61 for full support of non-alphnum
heredoc markers.

closes: vim/vim#20399

7895c9e6b8

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2026-06-02 16:55:20 +00: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