Commit Graph

32623 Commits

Author SHA1 Message Date
Justin M. Keyes
21540d21ca fix(lsp): _get_workspace_folders does not handle root_dir() function (#36141)
backport #36071

* fix(lsp): type of root_dir should be annotated with string|fun|nil
* feat(lsp): support root_dir as function in _get_workspace_folders
* feat(lsp): let checkhealth support root_dir() function

Examples:

    vim.lsp: Active Clients ~
    - lua_ls (id: 1)
      - Version: <Unknown>
      - Root directories:
          ~/foo/bar
          ~/dev/neovim

Co-authored-by: atusy <30277794+atusy@users.noreply.github.com>
2025-10-12 01:25:54 +00:00
Till Bungert
4e4428dee8 fix: vim.lsp.omnifunc should not throw away other items #35346
(cherry picked from commit 28157738e3)
2025-10-11 20:03:40 +00:00
Sean Dewar
86b2c0f201 fix(float): crash from nasty :fclose autocmds (#36137)
Problem: :fclose may crash Nvim if autocommands close floats prematurely.
Alternatively, :fclose may call win_close for windows not in curtab if
autocommands change curtab or move windows between tab pages via
nvim_win_set_config (may not crash, but is wrong).

Solution: check win_valid before calling win_close.

(cherry picked from commit 3ccba4cdff)

Backports #36134.
2025-10-11 17:37:03 +00:00
Vlad
5c583a8616 test(plugin/shada_spec): always use UTC formatted date (#36128)
Problem

Similar to https://github.com/neovim/neovim/pull/33257, but for the date
component. When timezone is behind UTC the epoch date of individual
components mismatch causing the test to fail.

Solution

The `epoch` variable is created using `os.date` with a `!`, which means
format the date in UTC instead of local timezone:
https://www.lua.org/manual/5.1/manual.html#pdf-os.date.

Since the individual components like year, month, and day are expected
to match `epoch` they should all be created using a `!` as well.

(cherry picked from commit f0b9232ad8)
2025-10-11 07:06:11 +00:00
Vlad
4338eea269 fix(rpc): handle more cases when identifying loopback #36100
Problem:

On MacOS it is a relatively common pattern to set XDG_RUNTIME_DIR under
`/tmp` or `/var`. Both of these are symlinks to `/private/tmp` and
`/private/var`. When checking for loopback the input address is
normalized using `fix_fname`, however this is not applied to the
addresses of the sockets. As a result of one address being normalized
and the other not the comparison would fail.

Solution:

Normalize both sides of the comparison using `fix_fname`.

(cherry picked from commit abd0c882b3)
2025-10-10 01:30:32 +00:00
zeertzjq
aab8134f87 vim-patch:9.1.1839: Window may have wrong height if resized from another tabpage (#36093)
Problem:  Window may have wrong height if resized from another tabpage.
Solution: Improve check for whether a tabline has been added (zeertzjq).

fixes: vim/vim#18518
closes: vim/vim#18519

bd3b958027
(cherry picked from commit 28355050a8)
2025-10-09 00:23:32 +00:00
Sean Dewar
f2fb46ef9e fix(api): nvim_open_win default to half-size for splits (#36088)
Problem: after #35601, nvim_open_win incorrectly attempts to set the size of a
split window to 0 if it wasn't specified.

Solution: only attempt to set the size again if it was actually specified. This has the effect of defaulting to half the size of the parent window (or it may be equalized with other windows to make room), like before.

Fix #36080

(cherry picked from commit d7472c0617)
2025-10-08 16:56:29 +00:00
zeertzjq
816273ae94 test: add a test for #36059
(cherry picked from commit b9482a0a26)
2025-10-08 00:51:46 +00:00
zeertzjq
d21c23b8c9 vim-patch:9.1.1836: 'culopt' "screenline" not redrawn with line("w0") and :retab
Problem:  'cursorlineopt' "screenline" isn't redrawn when moving cursor
          and then using line("w0") and :retab that does nothing.
Solution: Call redraw_for_cursorcolumn() when setting a valid w_virtcol
          (zeertzjq).

closes: vim/vim#18506

a084914361
(cherry picked from commit ba47cb7eda)
2025-10-08 00:51:46 +00:00
Sean Dewar
e1fe0ed2df vim-patch:9.1.1831: stray vseps in right-most 'winfixwidth' window
Problem:  vertical separator of 'winfixwidth' windows may remain if they
          become right-most windows from closing windows to the right.
Solution: Don't implicitly rely on frame_new_width to fix vseps, as the
          call may be skipped for 'winfixwidth' windows to preserve
          their width; do it explicitly in winframe_remove (Sean Dewar).

Note that I prefer win_new_width here over setting w_width directly, which
would've previously been done by win_split_ins after frame_add_vsep, as this
wasn't true for winframe_remove.

Though the equivalent issue of bottom 'winfixheight' windows leaving stray
statuslines with &ls=0 doesn't seem to exist, test it anyway.

closes: vim/vim#18481

620c655677

Nvim: calling win_new_width over setting w_width directly is especially
important in making sure stuff like w_view_width is correct here.

Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
(cherry picked from commit 7923e847ca)
2025-10-05 23:13:59 +00:00
zeertzjq
7304fc275e fix(excmd): :trust executed even when inside false condition (#36032)
Problem:  :trust is executed even when inside false condition.
Solution: Make skip_cmd() return true for CMD_trust, as ex_trust() does
          not handle eap->skip itself.
(cherry picked from commit 2f35221774)
2025-10-05 03:00:48 +00:00
zeertzjq
9ce88d5cb9 Merge pull request #36022 from zeertzjq/backport
vim-patch:9.1.1823: diff: w_topline may be invalidated (#36018)
2025-10-04 20:40:38 +08:00
zeertzjq
ac48d9c3c9 vim-patch:9.1.1823: diff: w_topline may be invalidated (#36018)
Problem:  diff: w_topline may be invalidated
Solution: Update lnum in diff_set_topline()
          (Yee Cheng Chin).

This can happen in ex_diffupdate() for certain edge cases which cause
the logic to now be wrong. This was also the root cause for vim/vim#18437 where
Vim would crash due to a null pointer dereferencing (said pointer would
not be null under normal circumstances).

related: vim/vim#18437
closes: vim/vim#18484

dd9ed46a39

Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2025-10-04 20:07:22 +08:00
glepnir
479bb9cbab fix(api): nvim_open_win respects requested split window size (#35601)
Problem: requested window size passed to nvim_open_win for splits may be ignored
by win_split_ins if it decides to forcefully equalize window sizes instead (e.g:
in an attempt to make room for the new window).

Solution: try to set the size again if it differs from what was requested.

Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
2025-10-04 10:18:48 +01:00
zeertzjq
675fc52183 refactor(terminal): remove an unnecessary xmemdupz() for OSC 8 (#36012)
Instead, NUL-terminate the StringBuilder when needed.
Also deduplicate xmemdup() calls for schedule_termrequest().

(cherry picked from commit 04022c70f3)
2025-10-04 04:02:59 +00:00
zeertzjq
854b319060 fix(terminal): handle OSC 8 split into multiple fragments
Also fix off-by-one size passed to xmemdupz().

(cherry picked from commit 40bf38fefc)
2025-10-04 01:39:29 +00:00
zeertzjq
07184aa973 fix(tui): handle sequence larger than entire buffer
(cherry picked from commit f64475a226)
2025-10-04 01:39:29 +00:00
zeertzjq
2655998a07 Merge pull request #36005 from zeertzjq/backport
test(tui_spec): deduplicate (#36003)
2025-10-03 19:52:34 +08:00
zeertzjq
8173e3ed6b test(tui_spec): deduplicate (#36003) 2025-10-03 19:28:13 +08:00
zeertzjq
53dc08a19b Merge pull request #36000 from zeertzjq/backport
Backport to release-0.11
2025-10-03 17:17:40 +08:00
zeertzjq
dc5566fed5 test(tui_spec): avoid dangling Nvim process on test failure 2025-10-03 16:14:14 +08:00
zeertzjq
2af99811f7 test: remove a few more redundant clear() calls 2025-10-03 16:14:14 +08:00
zeertzjq
0837a1ec2e test: don't call clear() in both before_each() and after_each() 2025-10-03 16:14:14 +08:00
zeertzjq
4923d151b5 test: remove duplicate legacy/{increment,undolevels}_spec.lua
They are almost exact copies of parts of test_{increment,undo}.vim.
2025-10-03 16:14:14 +08:00
zeertzjq
f8aaba8495 test: make error clearer for RPC request after crash 2025-10-03 16:14:14 +08:00
zeertzjq
83a90c530b test: reduce some clear() calls
Use only a single clear() call in some test/functional/vimscript/ test
files whose test cases have very little side effect.

A downside of using a single clear() is that if a crash happens in one
test case, all following test cases in the same file will also fail, but
these functionalities and tests don't change very often.
2025-10-03 16:14:10 +08:00
zeertzjq
61aab4cfe0 vim-patch:9.1.0698: tests: "Untitled" file not removed when running Test_crash1_3 alone
Problem:  tests: "Untitled" file not removed when running Test_crash1_3 alone
          with TEST_FILTER (after v9.1.0695)
Solution: Use a TearDown function instead of another test.
          (zeertzjq)

closes: vim/vim#15578
closes: vim/vim#15577

d56c451e1c
(cherry picked from commit 532cc88604)
2025-10-02 01:51:27 +00:00
zeertzjq
a839200c0a vim-patch:9.1.0695: tests: test_crash leaves Untitled file around
Problem:  tests: test_crash leaves Untitled file around
Solution: cleanup at the end of the test_crash.vim test file

cd83173def

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 71662bbb49)
2025-10-02 01:51:27 +00:00
zeertzjq
8634a46165 vim-patch:9.1.0689: [security]: buffer-overflow in do_search() with 'rightleft'
Problem:  buffer-overflow in do_search() with 'rightleft'
          (SuyueGuo)
Solution: after reversing the text (which allocates a new buffer),
          re-calculate the text length

Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-v2x2-cjcg-f9jm

cacb6693c1

Add missing change from patch 8.1.1270.
Omit `call delete('Untitled')`: moved again in patch 9.1.0695.

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 69a9a25fcc)
2025-10-02 01:51:27 +00:00
zeertzjq
dd79bc8360 vim-patch:014c731: runtime(doc): make :h virtcol() more accurate (#35976)
The current description (especially the "unlimited width" part) is
inaccurate in several ways:
- The size of virtual text can depend on window width. In particular,
  the size of "above" virtual text can be equal to window width.
- A double-width character that doesn't fit adds 1 to the virtual column
  of the following characters.
- The size of 'showbreak' and 'breakindent' is counted.

related: vim/vim#5713
closes: vim/vim#18447

014c731fa5
(cherry picked from commit 43f7434bd5)
2025-10-02 00:07:28 +00:00
zeertzjq
6dda8e9572 vim-patch:9.1.1808: Option insecure flags not copied when splitting window
Problem:  Option insecure flags not copied when splitting window.
Solution: Move window-local insecure flags to winopt_T and copy them
          properly (zeertzjq).

closes: vim/vim#18434

b3740f4b00
(cherry picked from commit 42f1864b62)
2025-09-30 01:04:40 +00:00
zeertzjq
67688ab616 vim-patch:9.1.1807: :set doesn't clear local insecure flag like :setlocal does
Problem:  :set doesn't clear local insecure flag like :setlocal does.
Solution: Also clear the local insecure flag when using :set (zeertzjq).

This applies to local options like 'wrap', 'foldtext' and 'foldexpr',
whose global flags are actually never used.  For global-local options
like 'statusline' the behavior is already correct, so add some tests.

related: vim/vim#18434

fec5586a45
(cherry picked from commit ff564237d2)
2025-09-30 01:04:40 +00:00
zeertzjq
9c09983068 vim-patch:9.1.1802: 'nowrap' in a modeline may hide malicious code (#35946)
Problem:  'nowrap' in a modeline may hide malicious code.
Solution: Forcibly use '>' as 'listchars' "extends" if 'nowrap' was set
          from a modeline (zeertzjq).

Manual `:setlocal nowrap` disables this behavior.  There is a separate
problem with `:set nowrap` that also applies to some other options.

related: vim/vim#18214
related: vim/vim#18399
closes: vim/vim#18425

9d5208a931

Cherry-pick some test_modeline.vim changes from patches 9.0.{0363,0626}.

(cherry picked from commit 0fa0717d4e)
2025-09-30 00:22:52 +00:00
zeertzjq
7280b7027b Merge pull request #35931 from zeertzjq/backport
vim-patch:9.1.1798: Wrong display with 'sms' and long wrapped virt text at EOL (#35930)
2025-09-27 21:59:33 +08:00
zeertzjq
4db62d96bc vim-patch:9.1.1798: Wrong display with 'sms' and long wrapped virt text at EOL (#35930)
Problem:  Wrong display with 'smoothscroll' and long wrapped virtual
          text at EOL.
Solution: Handle w_skipcol inside long wrapped virtual text at EOL
          (zeertzjq).

closes: vim/vim#18408

d9318acc02
2025-09-27 21:30:21 +08:00
zeertzjq
958a5ef2e6 Merge pull request #35922 from zeertzjq/backport
fix(plines): count 'showbreak' in EOL inline virt_text in line size (#35921)
2025-09-26 13:06:58 +08:00
zeertzjq
47f6f21998 fix(plines): count 'showbreak' in EOL inline virt_text in line size (#35921) 2025-09-26 12:11:35 +08:00
zeertzjq
a1b9070754 test(unit): disable JIT when using mocks (#35913)
This fixes the flaky eval/typval_spec.lua tests.

(cherry picked from commit bfa3e111c2)
2025-09-25 22:56:38 +00:00
zeertzjq
7e724dfa2f vim-patch:9.1.1780: mbyte contains overlapping list of utf_classes table (#35869)
Problem:  mbyte contains overlapping list of utf_classes table
Solution: Update table to contain non-overlapping list (Yuta Yamamoto)

closes: vim/vim#18362

9fa8a114b2

Co-authored-by: Yuta Yamamoto <jichael.y.yuta1995@gmail.com>
(cherry picked from commit e887602eb5)
2025-09-22 01:29:26 +00:00
SkrrtBacharach
d8a7c86e73 fix(health): errors in :checkhealth with pyenv-virtualenv #35865
Problem:
pyenv-virtualenv sets a different path for VIRTUAL_ENV than the path to the
python binary it provides, but these paths both symlink to the same file, so
there should be no disparity. The python health-check reports an error, since it
only checks if these paths are equal, not where they point to (resolve to).

Solution:
- Resolve the python symlinks before checking if they are equal.
- Deduplicate some code.

(cherry picked from commit cfe10b4014)
2025-09-21 22:06:55 +00:00
zeertzjq
c84ba83cf1 fix(options): increase t_Co buffer size (#35859)
(cherry picked from commit c2136e3590)
2025-09-21 04:44:30 +00:00
Judit Novak
8e00534b1e fix(health): hard fail on invalid "python-*" bin #35382
Problem:
Scripts named with 'python-…' prefix may not be valid python bins. If
such a script is found in a venv, the Python healthcheck fails hard.

    .venv/python-argcomplete-check-easy-install-script
    .venv/bin/python3.13
    .venv/bin/python

Solution:
- Discard known false-positives such as `python-argcomplete*`.
- Call `health.warn()` instead of `assert()` in `python_exepath()`.

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
(cherry picked from commit 6152bcf42e)
2025-09-19 03:50:52 +00:00
zeertzjq
77fe01f200 vim-patch:9.1.1773: Crash in BufLeave after BufUnload closes other windows (#35830)
Problem:  Crash in BufLeave/WinLeave/TabLeave when closing window after
          BufUnload closes all other windows in the tab page.
Solution: Avoid duplicate BufLeave/WinLeave events. Trigger TabLeave
          before removing the buffer (zeertzjq).

related: vim/vim#14166
related: neovim/neovim#33603
closes: vim/vim#18330

0c70820015
(cherry picked from commit c9f6267402)
2025-09-19 00:38:20 +00:00
Tomasz N
556d8d0002 fix(lsp): treat 2-triggers-at-once as "last char wins" #35435
Problem:
If there are 2 language servers with different trigger chars (`-` and
`>`), and a keymap inputs both simultaneously (`->`), then `>` doesn't
trigger. We get completion items from server1 only.

This happens because the `completion_timer` for the `-` trigger is still
pending.

Solution:
If the next character arrived enough quickly (< 25 ms), replace the
existing deferred autotrigger with a new one that matches this later
character.

(cherry picked from commit e69b81ad94)
2025-09-17 23:52:30 +00:00
zeertzjq
eb4837206a fix(lsp): restore Client:stop() force-stopping behavior (#35800)
This fixes a regression from #33796.

I tried for several hours and cannot write a working test for this, but
this does fix the following warning in tests run with ASAN or TSAN:

    -------- Running tests from test/functional/plugin/lsp_spec.lua
    RUN      T4667 LSP server_name specified start_client(), stop_client(): 114.00 ms OK
    RUN      T4668 LSP server_name specified stop_client() also works on client objects: 97.00 ms OK
    RUN      T4669 LSP server_name specified does not reuse an already-stopping client #33616: 31.00 ms OK
    nvim took 2022 milliseconds to exit after last test
    This indicates a likely problem with the test even if it passed!

(cherry picked from commit 4ef5624729)
2025-09-17 02:02:44 +00:00
zeertzjq
d86658f9d9 test(lsp): make async format test work properly (#35794)
Overriding vim.lsp.handlers['textDocument/formatting'] doesn't work here
because fake_lsp_server_setup() uses a table with __index to specify
client handlers, which takes priority over vim.lsp.handlers[], and as a
result the overridden handler is never called, and the test ends before
the vim.wait() even finishes.

Instead, set a global variable from the handler that is actually reached
(by vim.rpcrequest() from client handler), and avoid stopping the event
loop too early.

(cherry picked from commit 8d5476691c)
2025-09-17 00:53:31 +00:00
zeertzjq
777551c599 test(swapfile_preserve_recover_spec): fix flaky test (#35782)
Invoke nvim_get_mode() to ensure that pending input is processed.

(cherry picked from commit 1bafba31f6)
2025-09-16 00:23:35 +00:00
Justin M. Keyes
693772100e feat(help): gx opens help tag in web browser (#35784)
Problem:
`gx` does not work on tags in help buffers to open the documentation of that tag in the browser.

Solution:
Get the `optionlink`, `taglink` and `tag` TS nodes and set extmark "url" property.
`gx` then discovers the extmark "url" and opens it.

Co-authored-by: Yochem van Rosmalen <git@yochem.nl>
2025-09-15 23:30:31 +00:00
zeertzjq
7aea000343 fix(paste): don't use :echo immediately before :redraw (#35773)
- If tick == 0 at the last chunk, the first :echo will print an empty
  string, which isn't really helpful, and may cause :redraw to move
  cursor to the message area for 'showmode'.
- If tick > 0 at the last chunk, there'll be another :echo that prints
  an empty string immediately after the :redraw.

(cherry picked from commit a5d6932686)
2025-09-15 22:42:43 +00:00
zeertzjq
91f050bd28 Merge pull request #35769 from zeertzjq/backport
fix(lua): don't leak handle when vim._watch.watch() fails (#35768)
2025-09-15 12:16:44 +08:00