Commit Graph

35381 Commits

Author SHA1 Message Date
Wayne Young
3eb8a2784e test(lsp): wait up to 1 second to read messages 2026-02-15 10:31:10 +00:00
zeertzjq
b614c15392 refactor(terminal): don't put cursor at bottom-left in Normal mode (#37873)
When the terminal process is suspended, putting cursor at bottom-left
hints that pressing a key will change the suspended state. However, when
returning to Normal mode, the user is more likely to interact with the
actual terminal output (e.g. copying it), so it's better to put cursor
at the old position which should be closer to the output.

Also, using is_focused() to check for mode is confusing. Just check
`State & MODE_TERMINAL` instead.
2026-02-15 17:25:22 +08:00
Justin M. Keyes
ead2b4f769 Merge #37870 from seandewar/prompt-crash 2026-02-15 03:57:23 -05:00
Sean Dewar
2a5d687cc9 fix(prompt): prompt_setprompt sets cursor col unnecessarily
Problem: prompt_setprompt adjusts the cursor's column number even when it's not
on the prompt's line.

Solution: only adjust when on the prompt's line.
2026-02-15 06:04:12 +00:00
Sean Dewar
b3096b5860 fix(prompt): ml_get error with invalid ': lnum
Problem: internal error E315 in init_prompt if ': has an invalid line number.

Solution: clamp the line number.
2026-02-15 01:41:12 +00:00
Sean Dewar
4afbc25432 fix(prompt): heap-buffer-overflows with invalid ': col
Problem: heap-buffer-overflow in init_prompt and prompt_setprompt if ': mark has
an invalid column number.

Solution: consider an out-of-bounds column number as a missing prompt.

Remove the check for NULL for old_line, as ml_get_buf can't return NULL.
2026-02-15 01:41:12 +00:00
Sean Dewar
1349233cd1 fix(prompt): heap-buffer-overflow in prompt_setprompt
Problem: prompt_setprompt may check the wrong buffer, which can lead to a
heap-buffer-overflow.

Solution: don't use curbuf.

Also replace all kCallbackNone initializers with CALLBACK_INIT.
2026-02-15 01:40:31 +00:00
zeertzjq
f8d59cfab9 fix(highlight): setting 'winhl' doesn't work with global ns (#37868)
Problem:  Setting 'winhighlight' doesn't after setting global namespace
          using nvim_win_set_hl_ns().
Solution: Check if using another namespace when setting 'winhighlight'
          instead of disabling 'winhighlight' in nvim_win_set_hl_ns().
2026-02-15 08:03:44 +08:00
Shadman
8ab511bba5 feat(prompt): plugins can update prompt during user input #37743
Problem:
Currently, if prompt gets changed during user-input with
prompt_setprompt() it only gets reflected in next prompt. And that
behavior is not also consistent. If user re-enters insert mode then the
user input gets discarded and a new prompt gets created with the new
prompt.

Solution:
Handle prompt_setprompt eagerly. Update the prompt display, preserve user input.
2026-02-14 12:18:08 -05:00
glepnir
fb6a2c964d docs: Lua error codes E970, E5107-E5116 #37577 2026-02-14 10:55:48 -05:00
Tristan Knight
b99cdd08de refactor(lsp): centralize provider capability resolution #37221
- Refactor LSP client to use unified provider-based capability lookup for
  diagnostics and other features.
- Introduce `_provider_value_get` to abstract capability retrieval,
  supporting both static and dynamic registrations.
- Update diagnostic handling and protocol mappings to leverage
  provider-centric logic.
2026-02-14 10:50:48 -05:00
Justin M. Keyes
a7177e34c3 fix(highlight): link HLF_8 to something more prominent #34910
Problem:
HLF_8 is used by :intro and :map. And none of the other HLF_x things
use the other Special groups. So we have a darkgray highlight that's
very common, and not easy to read.

Darkgray makes sense for "Conceal", "non-printing chars", etc. But not
for keycodes or similar common elements.

Solution:
Link SpecialKey to Special.
2026-02-14 09:17:08 -05:00
Justin M. Keyes
a512af0d74 build: zig tee, drop old XXD_URL #37863
Problem:
- tee was vendored in ceb7eb5230 but
  forgot to add it to `build.zig`.
- xxd was vendored in 5bb8734fb6 but
  the old XXD_URL is still referenced.

Solution:
- update `build.zig`
- remove XXD_URL
2026-02-14 08:55:20 -05:00
Evgeni Chasnovski
539b8027a3 fix(pack): explicitly close confirmation window #37861
Problem: Executing `nvim_buf_delete()` does not guarantee that the
  window which shows the buffer is going to close after `:write` or
  `:quit`. In particular, if there is no listed buffer present.

Solution: Explicitly close the window that was created for confirmation
  buffer. Use `pcall` to catch cases when the window was already closed
  or when it is the last window.
2026-02-14 08:26:36 -05:00
Christian Clason
cadddbff69 build(deps): bump luajit to 26fd1a7d6 2026-02-14 12:59:50 +01:00
Dmytro Pletenskyi
01666aae64 feat(diagnostic): fromqflist({merge_lines}) #37416
Problem:
`vim.diagnostic.fromqflist` ignores lines that are `item.valid == 0` (see
`getqflist`). Many qflists have messages that span multiple lines, which look
like this:

    collection/src/Modelling/CdOd/Central.hs|496 col 80| error: [GHC-83865]
    ||     • Couldn't match expected type: InstanceWithForm
    ||                                       (FilePath
    ||                                        -> SelectValidCdInstWithForm
    ...

calling `vim.diagnostic.fromqflist(vim.fn.getqflist)` gets a diagnostic message
like this:

    error: [GHC-83865]

only the first line is kept, but often, the remaing lines are useful as well.

Solution:
Introduce `merge_lines` option, which "squashes" lines from invalid qflist items
into the error message of the previous valid item, so that we get this
diagnostic message instead:

    error: [GHC-83865]
         • Couldn't match expected type: InstanceWithForm
                                           (FilePath
                                            -> SelectValidCdInstWithForm
2026-02-14 06:07:01 -05:00
Justin M. Keyes
0864939cc5 fix(restart): append -c <cmd> at end, drop -- [files…] #37846
Problem:
- `:restart <cmd>` prepends `-c <cmd>` before the original `-c` args (if
  any). So the original `-c` args may "override" it, which is
  surprising.
- Confusing logic: `v:argv` is partially prepared in `ex_docmd.c`, and
  then later `ui.c` skips other parts of it.

Current behavior is nonsense, for example this sequence:

    :restart echo "Hello"
    :restart +qall echo "Hello" | echo "World"

results in this v:argv:

    [
      'nvim'
      '-c'
      'echo "Hello" | echo "World"'
      '--embed'
      '-c'
      'echo "Hello"'
      ...
    ]

Whereas after this commit, v:argv is:

    [
      'nvim'
      '--embed'
      ...
      '-c'
      'echo "Hello" | echo "World"'
    ]

Solution:
- Append `-c <cmd>` at the _end_ of `v:argv`, not the start.
- Use a dummy placeholder `+:::` to mark where the "restart command"
  appears in `v:argv`.
- Do all `v:argv` preparation in `ex_docmd.c`. This simplifies `ui.c`.
- Drop `-- [files…]` from `v:argv` since it is probably more annoying
  than useful. (Users can use sessions to restore files on restart.)
2026-02-14 05:34:30 -05:00
Yochem van Rosmalen
b5ce7e74dc refactor(help): move local-additions to Lua #37831
Problem:
- ~200 line function of hard-to-maintain C code.
- Local Addition section looks messy because of the varying description
  formats.

Solution:
- Move code to Lua.
- Have a best-effort approach where short descriptions are right
  aligned, giving a cleaner look. Long descriptions are untouched.
2026-02-14 05:30:18 -05:00
zeertzjq
29c81ba27e refactor: fix coverity warnings (#37858)
** CID 643177:         (OVERRUN)
/src/nvim/ui.c: 433           in ui_detach_impl()
/src/nvim/ui.c: 433           in ui_detach_impl()

_____________________________________________________________________________________________
*** CID 643177:           (OVERRUN)
/src/nvim/ui.c: 433             in ui_detach_impl()
427       if (shift_index >= MAX_UI_COUNT) {
428         abort();
429       }
430
431       // Shift UIs at "shift_index"
432       while (shift_index < ui_count - 1) {
>>>     CID 643177:           (OVERRUN)
>>>     Overrunning array "uis" of 16 8-byte elements at element index 16 (byte offset 135) using index "shift_index" (which evaluates to 16).
433         uis[shift_index] = uis[shift_index + 1];
434         shift_index++;
435       }
436
437       if (--ui_count
438           // During teardown/exit the loop was already destroyed, cannot schedule.
/src/nvim/ui.c: 433             in ui_detach_impl()
427       if (shift_index >= MAX_UI_COUNT) {
428         abort();
429       }
430
431       // Shift UIs at "shift_index"
432       while (shift_index < ui_count - 1) {
>>>     CID 643177:           (OVERRUN)
>>>     Overrunning array "uis" of 16 8-byte elements at element index 16 (byte offset 135) using index "shift_index + 1UL" (which evaluates to 16).
433         uis[shift_index] = uis[shift_index + 1];
434         shift_index++;
435       }
436
437       if (--ui_count
438           // During teardown/exit the loop was already destroyed, cannot schedule.

** CID 643176:       Null pointer dereferences  (FORWARD_NULL)

_____________________________________________________________________________________________
*** CID 643176:         Null pointer dereferences  (FORWARD_NULL)
/src/nvim/ex_getln.c: 1014             in command_line_enter()
1008       kv_destroy(ccline.last_colors.colors);
1009
1010       char *p = ccline.cmdbuff;
1011
1012       if (ui_has(kUICmdline)) {
1013         if (exmode_active) {
>>>     CID 643176:         Null pointer dereferences  (FORWARD_NULL)
>>>     Passing null pointer "p" to "ui_ext_cmdline_block_append", which dereferences it.
1014           ui_ext_cmdline_block_append(0, p);
1015         }
1016         ui_ext_cmdline_hide(s->gotesc);
1017       }
1018       if (!cmd_silent) {
1019         redraw_custom_title_later();
2026-02-14 04:49:34 +00:00
zeertzjq
1a1a60bd05 fix(terminal): resuming doesn't work with command in fish (#37857)
Problem:  Resuming terminal process doesn't work with command in fish.
Solution: Send SIGCONT to the entire process group.

Use killpg() like what bash and zsh do on `fg`:
https://cgit.git.savannah.gnu.org/cgit/bash.git/tree/jobs.c?id=637f5c8696a6adc9b4519f1cd74aa78492266b7f#n3928
77045ef899/tree/Src/jobs.c (l2674)
77045ef899/tree/Src/signals.c (l538)

Install fish on CI to test this.
2026-02-14 10:49:39 +08:00
zeertzjq
a17d39314d docs(lua): correct vim.wait() interval description (#37856)
Use the wording from the wait() Vimscript function.
2026-02-14 09:05:08 +08:00
zeertzjq
73157c994d fix(messages): heap-buffer-overflow with shell command (#37855)
Problem:  heap-buffer-overflow when showing output of a shell command.
Solution: Use xmemrchr() instead of strrchr().

Ref: https://github.com/neovim/neovim/pull/37831#issuecomment-3900149476
2026-02-14 01:03:52 +00:00
zeertzjq
9cbc430cfb fix(terminal): missing refresh with partial mappings (#37839)
Problem:  Terminal buffers are not refreshed when processing keys that
          trigger partial mappings.
Solution: Process due terminal refreshes before redrawing.
2026-02-14 08:00:27 +08:00
zeertzjq
289695c14e vim-patch:48cee53: runtime(doc): Clarify :bd behaviour
closes: vim/vim#19389

48cee53615

Co-authored-by: Christian Brabandt <cb@256bit.org>
2026-02-14 07:59:51 +08:00
zeertzjq
97c39be164 vim-patch:10f5573: runtime(systemverilog): use correct matchit pattern for the covergroup block
A covergroup start with the "covergroup" keyword and ends with the
"endgroup" keyword. "group" is not even a reserved keyword in systemverilog.

Reference:
https://www.chipverify.com/systemverilog/systemverilog-covergroup-coverpoint#covergroup
https://github.com/MikePopoloski/slang/blob/master/docs/grammar.md#covergroup_declaration

closes: vim/vim#19393

10f5573672

Co-authored-by: TG <tarik.graba@telecom-paris.fr>
2026-02-14 07:59:51 +08:00
zeertzjq
d49fe235f7 vim-patch:dcc4175: runtime(go,gleam): Remove 'formatprg' from ftplugins
Effective use of 'formatprg' requires both an understanding of the
specific capabilities of the formatting tool and Vim's formatting
commands.  This is overly burdensome for some users.

Rather than address each complaint on a filetype by filetype basis,
remove 'formatprg' settings from all ftplugins.

It is expected that formatter plugins will be available in the near
future as a better solution. See vim/vim#17145 (Add "formatter" feature using
"compiler" as a template).

Note: 'formatprg' will be removed from older ftplugins after the release
of Vim 9.2. The setting was added to the go and gleam ftplugins during
the current development cycle and have not been included in a Vim
release.

See: vim/vim#18650 (rust.vim: stop setting formatprg to rustfmt)

closes: vim/vim#19108

dcc4175284

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2026-02-14 07:59:51 +08:00
zeertzjq
3432d87ce0 vim-patch:a39d7c2: runtime(sudoers): highlight usernames with hyphens, digits, underscores
The username/group/netgroup patterns used \l\+ which only matched
lowercase letters. Linux usernames commonly contain hyphens, digits,
and underscores (e.g. www-data, deploy01, test_user).

Update the pattern to \l[-a-z0-9_]* to allow matching the additional
characters "-_" and numbers.

fixes:  vim/vim#18963
closes: vim/vim#19396

a39d7c2617

Co-authored-by: Bozhidar Batsov <bozhidar@batsov.dev>
2026-02-14 07:59:51 +08:00
Riccardo Mazzarini
6657cc3671 fix(ui): repaint separator connectors after all window updates #37852
Problem:
When a window is redrawn, `draw_vsep_win`/`draw_hsep_win` paint plain
separator characters (`│`/`─`) along the window's entire edges,
including cells that are connector corners belonging to other windows.
Then `draw_sep_connectors_win` only fixes the corners of that same
window, not connectors in the middle of its edges that belong to
adjacent windows.

If the window that "owns" the connector corner isn't part of the redraw,
the connector is never repainted.

Solution:
Move connector drawing out of the per-window `win_update` and into a
separate pass in `update_screen` that runs after all windows have been
updated.
2026-02-13 18:39:05 -05:00
zeertzjq
6bc0b8ae87 feat(terminal): detect suspended PTY process (#37845)
Problem:  Terminal doesn't detect if the PTY process is suspended or
          offer a convenient way for the user to resume the process.
Solution: Detect suspended PTY process on SIGCHLD and show virtual text
          "[Process suspended]" at the bottom-left. Resume the process
          when the user presses a key.
2026-02-13 13:49:08 +00:00
zeertzjq
9c5ade9212 fix: wait() checks condition twice on each interval (#37837)
Problem:  wait() checks condition twice on each interval.
Solution: Don't schedule the due callback. Also fix memory leak when
          Nvim exits while waiting.

No test that the condition isn't checked twice, as testing for that can
be flaky when there are libuv events from other sources.
2026-02-13 21:02:40 +08:00
glepnir
a7a7cdbcda fix(cmd): filter stdin file "-" from v:argv on :restart #37165
Problem:
restart hangs when nvim was started with stdin input, "-" marker stays
in v:argv, causing the restarted instance to block reading from stdin.

Solution:
filter out the "-" argument when rebuilding v:argv during restart.
Stdin content is ephemeral and shouldn't be re-read after restart.
2026-02-13 06:29:48 -05:00
zeertzjq
1ed064625c vim-patch:1cf38bf: runtime(css): Add missing numeric units (#37843)
- Add missing numeric units to css syntax script
  (baseline 2015, 2020, 2022, 2023, 2026):
    dvb, dvh, dvi, dvmax, dvmin, dvw ic,
    lvb, lvh, lvi, lvmax, lvmin, lvw, svb, svh,
    svi, svmax, svmin, svw, vb, vi, x, cap, lh,
    rlh, rcap, rch, rex, ric

closes: vim/vim#19325

1cf38bfebe

Co-authored-by: DuckAfire <155199080+duckafire@users.noreply.github.com>
2026-02-13 17:11:49 +08:00
zeertzjq
ff142a7a74 vim-patch:9.1.2147: Compile warning in strings.c (#37842)
Problem:  Compile warning in strings.c
Solution: Use const qualifier (John Marriott).

closes: vim/vim#19387

388654af27

Co-authored-by: John Marriott <basilisk@internode.on.net>
2026-02-13 09:02:10 +00:00
zeertzjq
1a1690660e vim-patch:9bf9d43: runtime(doc): various netrw related corrections
closes: vim/vim#19391

9bf9d436ce

Co-authored-by: Peter Kenny <github.com@k1w1.cyou>
2026-02-13 16:39:18 +08:00
zeertzjq
937f64da70 vim-patch:partial:8ee0e0b: runtime(doc): Fix to two-space convention in user manual
closes: vim/vim#15802

8ee0e0b8e3

Co-authored-by: h-east <h.east.727@gmail.com>
2026-02-13 16:39:18 +08:00
glepnir
88dc44260f fix(api): preserve WinConfig style when converting float to split #37264
Problem: When a float window with style='minimal' is converted to a
split window and then changes buffer, the minimal style options get
overridden. This happens because merge_win_config() clears the style
field, so get_winopts() doesn't know to re-apply minimal style after
restoring options from the buffer's wininfo.

Solution: Save and restore the style field when clearing the config
during float-to-split conversion.
2026-02-12 20:23:30 -05:00
zeertzjq
cc7022c544 fix(terminal): scrollback may still be wrong on height increase (#37835)
Problem:  Terminal scrollback may be wrong when increasing height after
          outputting lines with full scrollback.
Solution: Ensure enough number of scrollback lines have been deleted.
2026-02-13 01:06:23 +00:00
zeertzjq
39d8a9c353 vim-patch:9.1.2146: filetype: cel files are not recognized (#37834)
Problem:  filetype: cel files are not recognized
Solution: Detect *.cel files as cel filetype (Stefan VanBuren).

Reference:
https://cel.dev/
e36c49febc/testing/src/test/resources/expressions/coverage_test_case/simple_expression.cel
d0d2dbabae/example.cel

closes: vim/vim#19381

fb5777fa20

Co-authored-by: Stefan VanBuren <svanburen@buf.build>
2026-02-13 08:34:00 +08:00
zeertzjq
844a683641 vim-patch:56033b9: runtime(sh): Fix some ksh-specific deficiencies in syntax script
- Amend syntax highlighting to allow for ksh93 discipline function names
  (e.g. 'foo.get()') and mksh's odd function naming idiosyncrasies
  (shNamespaceOne was introduced to enforce stricter naming rules for
  ksh93 namespaces).
- Remove 'bind' from ksh93 syntax (such a builtin has never been
  implemented in ksh93).
- 'xgrep' is only available in ksh93v- as an alternative way to
  invoke the builtin 'grep -X', so reflect that in the syntax
  highlighting.
- Forbid bash-style 'function name() {' syntax when highlighting
  ksh88 and ksh93 scripts.
- Fix bug causing ' ()' to be incorrectly validated in mksh scripts.
- Add the many ksh93/ksh2020 .sh.* variables to the list of special
  variables.
- Amend iskeyword to allow '.' so that '.sh.tilde.get' and such are
  valid function names/variable names. (For mksh functions starting
  with odd characters like '%' and '@' this would probably have too
  many bad side effects, so I've omitted such a change for that shell.)
- Add new syntax tests and regenerate syntax dump files

closes: vim/vim#19383

56033b9df3

Co-authored-by: Johnothan King <johnothanking@protonmail.com>
2026-02-13 08:29:18 +08:00
zeertzjq
ca701ad947 vim-patch:04c3c68: runtime(sshdconfig): Update syntax
We add new key exchange algorithms and new enums for PubkeyAuthOptions.

We also add new keywords from sshd_config.5 not present here and remove
keywords present here that are not present in the official
documentation, with the exception of those patched in by Debian and
Fedora, as well as ChallengeResponseAuthentication which is deprecated
but still functional.

closes: vim/vim#19347

04c3c6871e

Co-authored-by: Fionn Fitzmaurice <fionn@github.com>
2026-02-13 08:29:18 +08:00
zeertzjq
eaeb2419cf vim-patch:b27934b: runtime(django): add syntax support for partial
Add djangoStatement integrated in version 6. 'partialdef',
'endpartialdef', 'partial'.

[Template Reference: partial](https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#partial)((introduced in Django 6.0)
and 'filter'.

closes: vim/vim#19386

b27934bf8b

Co-authored-by: tecis <67809811+tecis@users.noreply.github.com>
2026-02-13 08:29:18 +08:00
Kevin Goodsell
fa24df3264 fix(bufwrite.c): handle invalid byte sequences #37363
Problem:

bw_rest was used as an extra buffer to save incomplete byte sequences
between calls to buf_write_bytes. Besides being unnecessarily
complicated, this introduced a number of issues:

1) The bytes stored in bw_rest could still be there at the end of
writing the file, never having been written, thus losing some of the
file content on write.

2) bw_rest was not cleared out after the "checking_conversion" phase,
leaving them to affect the written file content during the writing
phase, corrupting the file.

3) bw_rest could contain extra bytes that need to be written to the
output buffer during a buf_write_convert call, potentially before any
bytes are consumed. But some conversions are in-place, without a
separate output buffer. Writing bytes from bw_rest to the "output"
buffer actually overwrote bytes from the input buffer before they were
read, corrupting the data to be written.

4) The extra bytes in bw_rest that need to be written to the conversion
output buffer were not originally accounted for in the size calculation
for the output buffer, causing a buffer overflow (previously fixed in
Vim patch 9.1.2028).

Solution:

Rather than maintaining a separate buffer, the unconverted bytes at the
end of the buffer can just be shifted to the beginning of the buffer,
and the buffer size updated. This requires a bit of refactoring, and
buf_write_convert and buf_write_convert_with_iconv need to report the
number of bytes they consumed so that buf_write_bytes can handle the
remaining bytes.

Following conversion, bw_buf can be checked for any remaining bytes.
Leftover bytes in this case result in a conversion error, which is
better than silently dropping them.

A short section of dead code was removed from buf_write_convert, for
converting a non-UTF-8 buffer to UTF-8. Neovim buffers are always UTF-8.

A few additional tests for iconv conversions have been added. Vim's
iconv tests are disabled in Neovim because they use unsupported values
for 'encoding'.
2026-02-12 17:38:11 -05:00
Elijah Koulaxis
8a0cbf04d6 feat(iter): peek(), skip(predicate) for non-list iterators #37604
Problem:
Iter:peek() only works if the iterator is a |list-iterator| (internally, an `ArrayIter`).
However, it is possible to implement :peek() support for any iterator.

Solution:
- add `_peeked` buffer for lookahead without actually consuming values
- `peek()` now works for function, pairs(), and array iterators
- `skip(predicate)` stops at the first non matching element without consuming it
- keep existing optimized behavior for `ArrayIter` to maintain backward compatibility
- use `pack`/`unpack` to support iterators that return multiple values
2026-02-12 11:55:16 -05:00
phanium
179e7fccd7 fix(ui2): incomplete :echon message in g< pager #37819
Problem:
`:echo 1 | echon 2<cr>g<` shows "2", but should be "12".

Solution:
Don't clear temp msg (g<) if we are appending.
2026-02-12 11:10:37 -05:00
Justin M. Keyes
e8ace82093 Merge #37096 from justinmk/doc2 2026-02-12 08:15:21 -05:00
Michele Campeotto
d0822bbd15 fix(treesitter): highlight group for EditQuery captures #36265
fix(treesitter): more distinctive highlight for EditQuery captures

Problem: EditQuery shows captures in the source buffer using the Title
highlight group, which could be too similar to Normal.

Solution: Use a virtual text diagnostic highlight group: they are
displayed in a similar manner to the query captures so we can assume
that the color scheme should have appropriate styling applied to make
them visible.
2026-02-12 08:07:13 -05:00
Justin M. Keyes
d995142dbd fix(scripts): collect_typos.lua: show commit message on failure 2026-02-12 13:46:53 +01:00
Justin M. Keyes
8a901a52e1 fix(health): avoid silent failure 2026-02-12 13:46:53 +01:00
Justin M. Keyes
5870627a24 docs: vim.fs path expansion
fix #37583
2026-02-12 13:46:53 +01:00
Justin M. Keyes
ec93b786c5 refactor(api): api_buf_ensure_loaded 2026-02-12 13:46:53 +01:00