Commit Graph

7257 Commits

Author SHA1 Message Date
Sean Dewar
d7472c0617 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
2025-10-08 16:22:29 +00:00
zeertzjq
c881bc537e vim-patch:9.1.1817: popup: there are some position logic bugs (#36075)
Problem:  popup: there are some position logic bugs
Solution: Refactor position logic and fix a few bugs
          (Girish Palya).

This change does the following:

- Simplified and rewrote horizontal positioning logic (was overly
  complex).
- Split horizontal and vertical positioning into separate functions.
- Fixed missing truncation marker (e.g. `>`) when items were truncated
  and `pummaxwidth` was not set.
- Fixed occasional extra space being added to menu items.
- Update tests

closes: vim/vim#18441

e3ed5584ed

Cherry-pick pum_display_{rtl,ltr}_text() changes from patch 9.1.1835.

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-10-08 13:47:50 +08:00
zeertzjq
b9482a0a26 test: add a test for #36059 2025-10-08 08:16:17 +08:00
zeertzjq
ba47cb7eda 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
2025-10-08 08:16:17 +08:00
zeertzjq
236d831d77 fix(cmdline): don't treat c_CTRL-D as wildmenu (#36067)
Remove WM_LIST, which was previously added in #7110, but now statusline
and messages no longer interfere with each other thanks to the message
grid, etc., and terminal refreshing no longer calls update_screen()
directly since #9883.

Tests from #7110 and #10107 still pass.
2025-10-08 06:29:00 +08:00
altermo
9e1d3f4870 feat(runtime): undotree #35627
Problem
No builtin way to visualize and navigate the undo-tree.

Solution
Include an "opt" plugin.
2025-10-07 14:32:22 -07:00
Evgeni Chasnovski
3b860653ca fix(pack): handle lockfile in case of install errors #36064
Problem: If plugin was intended to install but there were errors (like
  if there is a typo in `src`), lockfile still includes its entry.
  This leads to all source of problems (like not correct `get()` output,
  not working `update()`, etc.).

Solution: Explicitly account for plugins that were not installed.
  Alternative solution might be to write a safe
  `lock_set(plug, field, value)` wrapper (which sets field for a correct
  `plugins` entry in the lockfile Lua table) and use it after install
  to detect the change in `version`. However, this always requires
  an extra pass through plugins on every startup, which is suboptimal.
  Optimizing for the "happy path" should be a priority in `add()`.
2025-10-07 12:24:23 -07:00
Sean Dewar
7923e847ca 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>
2025-10-05 23:30:23 +01:00
Evgeni Chasnovski
98e3a571dd feat(pack): add code actions in confirmation buffer
Problem: No way to granularly operate on plugins when inside
confirmation buffer.

Solution: Implement code actions for in-process LSP that act on "plugin
at cursor":
  - Update (if has updates).
  - Skip updating (if has updates).
  - Delete.

  Activate via default `gra` or `vim.lsp.buf.code_action()`.
2025-10-05 19:20:06 +03:00
Evgeni Chasnovski
2728b4efe0 feat(pack): add [[ and ]] mappings in confirmation buffer
Problem: No easy/robust way to jump between plugin sections.

Solution: Add `[[` and `]]` mappings.
2025-10-05 19:20:05 +03:00
Maria Solano
b938638d2d fix(lsp): deprecate vim.lsp.protocol.Methods (#35998) 2025-10-04 21:09:13 -07:00
zeertzjq
2f35221774 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.
2025-10-05 10:21:44 +08:00
Evgeni Chasnovski
dc8235c48c feat(pack): prefer using revision from lockfile during install
Problem: Installing plugin always pulls latest `version` changes
  (usually from the default branch or "latest version tag"). It is more
  robust to prefer initial installation to use the latest recorded
  (i.e. "working") revision.

Solution: Prefer using revision from the lockfile (if present) during
  install. The extra `update()` will pull the latest changes.
2025-10-04 16:15:54 +03:00
Evgeni Chasnovski
cfbc03a954 feat(pack)!: make update() include not active plugins by default
Problem: Running `update()` by default doesn't include not active
  plugins, because there was no way to get relevant `version` to get
  updates from. This might be a problem in presence of lazy loaded
  plugins, i.e. ones that can be "not *yet* active" but still needed to
  be updated.

Solution: Include not active plugins by default since their `version` is
  tracked via lockfile.
2025-10-04 16:13:39 +03:00
Evgeni Chasnovski
a31f63f661 feat(pack)!: update get() to return revision regardless of opts.info
Problem: The revision data is returned behind `opts.info` flag because
  it required extra Git calls. With lockfile it is not the case.

Solution: Use lockfile to always set `rev` field in output of `get()`.
2025-10-04 16:13:38 +03:00
Evgeni Chasnovski
2c0b70e559 fix(pack)!: use lockfile in get() for data about non-active plugins
Problem: `get()` doesn't return `spec.version` about not-yet-active
  plugins (because there was no way to know that without `add()`).

Solution: Use lockfile data to set `spec.version` of non-active plugins.
2025-10-04 16:13:36 +03:00
Evgeni Chasnovski
d7db552394 feat(pack): add initial lockfile tracking
Problem: Some use cases require or benefit from persistent on disk
  storage of plugin data (a.k.a. "lockfile"):

  1. Allow `update()` to act on not-yet-active plugins. Currently if
    `add()` is not yet called, then plugin's version is unknown
    and `update()` can't decide where to look for changes.

  2. Efficiently know plugin's dependencies without having to read
    'pkg.json' files on every load for every plugin. This is for the
    future, after there is `packspec` support (or other declaration of
    dependencies on plugin's side).

  3. Allow initial install to check out the exact latest "working" state
    for a reproducible setup. Currently it pulls the latest available
    `version.`

  4. Ensure that all declared plugins are installed, even if lazy loaded.
    So that later `add()` does not trigger auto-install (when there
    might be no Internet connection, for example) and there is no issues
    with knowing which plugins are used in the config (so even never
    loaded rare plugins are still installed and can be updated).

  5. Allow `add()` to detect if plugin's spec has changed between
    Nvim sessions and act accordingly. I.e. either set new `src` as
    origin or enforce `version.` This is not critical and can be done
    during `update()`, but it might be nice to have.

Solution: Add lockfile in JSON format that tracks (adds, updtes,
  removes) necessary data for described use cases. Here are the required
  data that enables each point:

    1. `name` -> `version` map.
    2. `name` -> `dependencies` map.
    3. `name` -> `rev` map. Probably also requires `name` -> `src` map
       to ensure that commit comes from correct origin.
    4. `name` -> `src` map. It would be good to also track the order,
       but that might be too many complications and redundant together
       with point 2.
    5. Map from `name` to all relevant spec fields. I.e. `name` -> `src`
       and `name` -> `version` for now. Storing data might be too much,
       but can be discussed, of course.

  This commit only adds lockfile tracking without implementing actual
  use cases. It is stored in user's config directory and is suggested to
  be tracked via version control.

  Example of a lockfile:

  ```json
  {
    # Extra nesting to more future proof.
    "plugins": {
      "plug-a": {
        "ref": "abcdef1"
        "src": "https://github.com/user/plug-a",
        # No `version` means it was `nil` (infer default branch later)
      },
      "plug-b": {
        "dependencies": ["plugin-a", "plug-c"],
        "src": "https://github.com/user/plug-b",
        "ref": "bcdefg2",
        # Enclose string `version` in quotes
        "version": "'dev'"
      },
      "plug-c": {
        "src": "https://github.com/user/plug-c",
        "ref": "cdefgh3",
        # Store `vim.version.Range` via its `tostring()` output
        "version": ">=0.0.0",
      }
    }
  }
  ```
2025-10-04 16:13:32 +03:00
glepnir
19f5f05ac2 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 09:07:27 +01:00
zeertzjq
40bf38fefc fix(terminal): handle OSC 8 split into multiple fragments
Also fix off-by-one size passed to xmemdupz().
2025-10-04 08:35:15 +08:00
zeertzjq
f64475a226 fix(tui): handle sequence larger than entire buffer 2025-10-04 07:54:50 +08:00
zeertzjq
8151fc59cf vim-patch:9.1.1820: completion: some issues with 'acl' (#36007)
Problem:  completion: some issues with 'acl' when "preinsert" and
          "longest" is in 'completeopt' (musonius, after v9.1.1638)
Solution: Fix various issues (see details below) (Girish Palya)

This commit addresses multiple issues in the 'autocompletedelay' behavior with
"preinsert" and "longest":

- Prevents spurious characters from being inserted.
- Ensures the completion menu is not shown until `autocompletedelay` has
  expired.
- Shows the "preinsert" effect immediately.
- Keeps the "preinsert" effect visible even when a character is deleted.

fixes: vim/vim#18443
closes: vim/vim#18460

f77c187277

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-10-03 13:10:05 +00:00
zeertzjq
97ab7dd784 test(tui_spec): deduplicate (#36003) 2025-10-03 10:25:04 +00:00
Riley Bruins
ac15b384a6 refactor(treesitter): use scratch buffer for string parser #35988
This commit changes `languagetree.lua` so that it creates a scratch
buffer under the hood when dealing with string parsers. This will make
it much easier to just use extmarks whenever we need to track injection
trees in `languagetree.lua`. This also allows us to remove the
`treesitter.c` code for parsing a string directly.

Note that the string parser's scratch buffer has `set noeol nofixeol` so
that the parsed source exactly matches the passed in string.
2025-10-02 15:33:18 -07:00
Riley Bruins
b4016f4525 fix(treesitter): don't add final newline if not present #35970
**Problem(?):** Buffers that (for whatever reason) aren't meant to have
a final newline are still parsed with a final newline in `treesitter.c`.

**Solution:** Don't add the newline to the last buffer line if it
shouldn't be there. (This more closely matches the approach of
`read_buffer_into()`.)

This allows us to, say, use a scratch buffer with `noeol` and `nofixeol`
behind the scenes in `get_string_parser()`.

...which would allow us to track injection trees with extmarks in that
case.

...which would allow us to not drop previous trees after reparsing a
different range with `get_parser():parse()`.

...which would prevent flickering when editing a buffer that has 2+
windows to it in view at a time.

...which would allow us to keep our sanity!!!

(one step at a time...)
2025-10-01 17:31:52 -07:00
zeertzjq
6d550f3cdb test(terminal/mouse_spec): forwarding works with resized grid (#35969) 2025-10-01 01:24:02 +00:00
glepnir
198c9e9bca fix(shada): preserve marks after delete across sessions (#35795)
Problem: Marks are lost after `:bdelete` because `ignore_buf()` filters
out unlisted buffers during shada mark processing.

Solution: Revert to original buffer checks for mark operations, avoiding
`!buf->b_p_bl` condition that incorrectly ignores deleted buffers.
2025-09-30 05:28:35 +00:00
zeertzjq
f30a33858f vim-patch:9.1.1800: completion: strange behaviour with 'ac' completeopt=longest,preinsert
Problem:  completion: strange behaviour with 'ac'
          completeopt=longest,preinsert (zeertzjq)
Solution: Let preinsert take precedence (Girish Palya)

fixes: vim/vim#18410
closes: vim/vim#18428

d35e5e4237

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-09-30 09:32:33 +08:00
zeertzjq
7b9c063d11 vim-patch:9.1.1797: completion: autocompletion can be improved
Problem:  completion: autocompletion can be improved
Solution: Add support for "longest" and "preinsert" in 'autocomplete';
          add preinserted() (Girish Palya)

* Add support for "longest" in 'completeopt' when 'autocomplete'
  is enabled. (Note: the cursor position does not change automatically
  when 'autocomplete' is enabled.)
* Add support for "preinsert" when 'autocomplete' is enabled. Ensure
  "preinsert" works the same with and without 'autocomplete'
* introduce the preinserted() Vim script function, useful for defining
  custom key mappings.

fixes: vim/vim#18314
closes: vim/vim#18387

c05335082a

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-09-30 09:32:33 +08:00
glepnir
fcf752476a fix(cmd): :update writes new file buffers only for real files #35939
Problem: :update should write new file buffers, but previous fix
affected special buffer types (acwrite, nofile, etc.).

Solution: Add bt_nofilename() check to only write new files for
buffers representing real filesystem paths.
2025-09-27 20:28:05 -07:00
glepnir
69cae6259e fix(cmd): :update does not write new, unmodified buffer #35929
Problem: update command does not write new buffers that have
filenames but no corresponding file on disk, even when using ++p flag.

Solution: allow update to write when buffer has filename but file
doesn't exist.
2025-09-27 10:24:24 -07:00
zeertzjq
2aab242a01 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 13:28:40 +00:00
zeertzjq
42aae632be fix(plines): count 'showbreak' in EOL inline virt_text in line size (#35921) 2025-09-26 04:08:38 +00:00
zeertzjq
a0a86fdc04 test: make preload of functional/testnvim.lua explicit (#35919)
Before functional/testnvim.lua was moved from functional/testutil.lua in
052498ed42, it was explicitly preloaded,
but now it is preloaded implicitly via functional/ui/screen.lua.

Also fix warnings about unused variables in other preload.lua files.
2025-09-26 09:05:07 +08:00
zeertzjq
eb7c12d3e3 test: remove a few more redundant clear() calls (#35903) 2025-09-24 14:25:54 +08:00
zeertzjq
b256e0476b test(lua/secure_spec): clean up properly (#35902)
- Remove "state" directory after each test, so that a failure in one
  test won't interfere with later tests.
- Still make sure the trust file is empty at the end of each test.
2025-09-24 12:30:57 +08:00
zeertzjq
a62fb57e58 test: don't call clear() in both before_each() and after_each() (#35901) 2025-09-24 11:41:43 +08:00
zeertzjq
94f1abf89c test(tui_spec): avoid dangling Nvim processes on test failure (#35900)
Also don't wait indefinitely for all Nvim processes to exit.
2025-09-24 02:21:42 +00:00
zeertzjq
d2257402e3 test: don't block to wait for previous session's exit (#35885)
This reduces the time taken by clear() by over 20% with ASAN.
2025-09-23 23:25:29 +00:00
luukvbaal
3d5ef97a98 fix(message): no wait return for delayed exception error #35881
Problem:  Wait return for delayed exception error message.
Solution: Check that error was actually shown.
2025-09-23 13:35:08 -07:00
zeertzjq
b9dd3167f4 test: remove duplicate legacy/{increment,undolevels}_spec.lua
They are almost exact copies of parts of test_{increment,undo}.vim.
2025-09-22 14:03:42 +08:00
zeertzjq
6d280804f7 test: make error clearer for RPC request after crash 2025-09-22 14:03:42 +08:00
zeertzjq
777dafdc46 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-09-22 14:03:42 +08:00
zeertzjq
c2136e3590 fix(options): increase t_Co buffer size (#35859) 2025-09-21 04:12:37 +00:00
zeertzjq
f60f67c2de test: fix 'autocompletedelay' test flakiness (#35856) 2025-09-21 01:27:44 +00:00
zeertzjq
a70997442e vim-patch:9.1.1779: completion: 'autocomplete' cannot be enabled per buffer (#35853)
Problem:  completion: 'autocomplete' cannot be enabled per buffer
          (Tomasz N)
Solution: Make 'autocomplete' global or local to buffer (Girish Palya)

fixes: vim/vim#18320
closes: vim/vim#18333

0208b3e80a

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-09-21 00:56:38 +00:00
Shadman
04f476733c test: fix prompt_buffer_spec flakiness (#35838)
Remove incorrect use of source_script().
2025-09-19 11:14:49 +00:00
zeertzjq
e2166661d4 vim-patch:9.1.1772: completion: inconsistent selection of first item with 'autocomplete' (#35835)
Problem:  completion: inconsistent selection of first item with
          'autocomplete' (Tomasz N)
Solution: Check for 'autocomplete' option in ins_compl_new_leader()
          (Girish Palya).

fixes: vim/vim#18326
closes: vim/vim#18329

86e8e909f2

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-09-19 10:47:53 +08:00
zeertzjq
0763a85f43 vim-patch:9.1.1771: complete: some redraw issues with 'autocomplete'
Problem:  complete: some redraw issues with 'autocomplete'
Solution: Fix the issues (Girish Palya)

This commit contains the following changes:
* Fix that wildtrigger() might leave opened popupmenu around vim/vim#18298
* Remove blinking message on the command line when a menu item from a loaded
  buffer is selected during 'autocomplete'
* Add a test for PR vim/vim#18265 to demonstrate why the PR is required for correct
  'autocomplete' behavior

fixes: vim/vim#18298
closes: vim/vim#18328

ee9a2f0512

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-09-19 09:58:24 +08:00
zeertzjq
dd306bd48a vim-patch:9.1.1621: flicker in popup menu during cmdline autocompletion
Problem:  When the popup menu (PUM) occupies more than half the screen
          height, it flickers whenever a character is typed or erased.
          This happens because the PUM is cleared and the screen is
          redrawn before a new PUM is rendered. The extra redraw between
          menu updates causes visible flicker.
Solution: A complete, non-hacky fix would require removing the
          CmdlineChanged event from the loop and letting autocompletion
          manage the process end-to-end. This is because screen redraws
          after any cmdline change are necessary for other features to
          work.
          This change modifies wildtrigger() so that the next typed
          character defers the screen update instead of redrawing
          immediately. This removes the intermediate redraw, eliminating
          flicker and making cmdline autocompletion feel smooth
          (Girish Palya).

Trade-offs:
This behavior change in wildtrigger() is tailored specifically for
:h cmdline-autocompletion. wildtrigger() now has no general-purpose use
outside this scenario.

closes: vim/vim#17932

da9c966893

Use pum_check_clear() instead of update_screen().
Cherry-pick Test_wildtrigger_update_screen() change from patch 9.1.1682.

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-09-19 09:58:24 +08:00
zeertzjq
b5e6f44c08 test(ui/messages2_spec): close unfinished timers at end of test (#35817)
The vim._extui.messages module uses multiple timers that last 2 or 4
seconds. If these timers aren't finished when a test ends, there will
be a 2-second delay on exit with ASAN or TSAN.
2025-09-18 08:01:21 +08:00