Commit Graph

32987 Commits

Author SHA1 Message Date
9f505b4d0f refactor: make two functions used only in memory.c static (#34339)
After #29450 try_to_free_memory() is only used in memory.c.
Also move do_outofmem_msg() closer to where it's used.
2025-06-06 13:49:22 +08:00
60d0b7d0c3 fix(diff): fix incorrect item size of dout_ga (#34338)
Related 267494151b
2025-06-06 04:34:28 +00:00
552983515f vim-patch:9.1.1435: completion: various flaws in fuzzy completion (#34335)
Problem:  completion: various flaws in fuzzy completion
Solution: fix the issues (Girish Palya)

- Remove the brittle `qsort()` on `compl_match_array`.
- Add a stable, non-recursive `mergesort` for the internal doubly
  linked list of matches.
- The sort now happens directly on the internal representation (`compl_T`),
  preserving sync with external structures and making sorting stable.
- Update fuzzy match logic to enforce `max_matches` limits after
  sorting.
- Remove `trim_compl_match_array()`, which is no longer necessary.
- Fixe test failures by correctly setting `selected` index and
  maintaining match consistency.
- Introduce `mergesort_list()` in `misc2.c`, which operates generically
  over doubly linked lists.
- Remove `pum_score` and `pum_idx` variables

fixes: vim/vim#17387
closes: vim/vim#17430

8cd42a58b4

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-06-06 02:46:01 +00:00
4e71d3bfab vim-patch:eb59129: runtime(typescript): remove Fixedgq() function from indent script (#34334)
Problem:
1. The `Fixedgq()` function is broken (see vim/vim#17412)
2. The `'formatexpr'` for Typescript is not documented, which causes
   confusion to users when they try to set `'formatprg'`, since
   `'formatexpr'` always takes precedence over `'formatprg'`. See also
   https://github.com/HerringtonDarkholme/yats.vim/issues/209
3. Typescript already has a very good and popular formatter called
   `prettier`, that can be easily integrated to Vim via `'formatprg'`
   (see vim/vim#16989). I don't think there are any good reasons to reinvent a
   half-baked version in Vim.

Solution:  Remove the Fixedgq() 'formatexpr' function.

fixes: vim/vim#17412
closes: vim/vim#17452

eb59129d2c
2025-06-06 07:47:55 +08:00
a9f544b712 Merge pull request #34333 from zeertzjq/vim-9.1.1431
vim-patch:9.1.{1431,1433}

N/A patch:
vim-patch:002548b: runtime(doc): Add missing 'wfb' (winfixbuf) tag
2025-06-06 06:57:51 +08:00
6171ab7f4e vim-patch:9.1.1433: Unnecessary :if when writing session
Problem:  Unnecessary :if in session where both branches have the same
          effect (after 9.1.1431).
Solution: Remove the superfluous :if (zeertzjq).

closes: vim/vim#17448

8f751d56f4
2025-06-06 06:37:36 +08:00
f89381e05c vim-patch:9.1.1431: Hit-Enter Prompt when loading session files
Problem:  Hit-Enter Prompt when loading session files
Solution: use set+= for 'shortmess' to keep the existing flags
          (Miguel Barro)

closes: vim/vim#17445

0ca5966196

Co-authored-by: Miguel Barro <miguel.barro@live.com>
2025-06-06 06:36:47 +08:00
2b21c9c23f fix(diagnostic): ensure autocmd always is always sent diagnostics 2025-06-05 13:02:56 +01:00
b6b35cb557 vim-patch:bb78ea2: runtime(mbsync): Add support for TLSType in syntax script
closes: vim/vim#17438

bb78ea23c6

Co-authored-by: Filippo Bonazzi <filippo.bonazzi@suse.com>
2025-06-05 09:16:38 +02:00
1c417b565e vim-patch:9.1.1432: GTK GUI: Buffer menu does not handle unicode correctly (#34313)
Problem:  GTK GUI: Buffer menu does not handle unicode correctly
Solution: Get rid of the BMHash() function (SUN Haitao)

fixes: vim/vim#17403
closes: vim/vim#17405

08896dd330

Co-authored-by: SUN Haitao <sunhaitao@devtaste.com>
2025-06-05 09:19:22 +08:00
5e470c7af5 fix(menu): fix listing of submenus (#34315)
Problem:  Listing submenus with :menu doesn't work.
Solution: Don't go to the parent of the return value of find_menu(), and
          handle empty path at the caller.

Related #8194, which actually only fixed the problem for menu_get(), not
for :menu Ex command.
2025-06-05 01:18:00 +00:00
b16dc698cf Merge pull request #34312 from zeertzjq/vim-d6c9ac9
vim-patch: doc updates
2025-06-05 07:05:27 +08:00
a5bbdbb5d5 vim-patch:dfed077: runtime(doc): fix small errors from rev 2090405de5bb66facc29c74
- update the netrw window to current version (and trim it slightly to 80
  chars)
- remove a trailing double quote

dfed077e06

Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Antonio Giovanni Colombo <azc100@gmail.com>
2025-06-05 06:32:13 +08:00
038fb30ece vim-patch:d6c9ac9: runtime(doc): clarify the effect of 'smarttab'
closes: vim/vim#17426

d6c9ac97a0

Co-authored-by: Damien Lejay <damien@lejay.be>
2025-06-05 06:31:09 +08:00
5e4700152b fix(extui): copy window config to new tabpage (#34308)
Problem:  When opening a new tabpage, extui windows are initialized with
          their default config. Window visiblity/dimensions on other
          tabpages may get out of sync with their buffer content.
Solution: Copy the config of the window to the new tabpage.
          No longer keep track of the various windows on each tabpage.
          Close windows on inactive tabpages instead (moving them could
          be more efficient but is currently not supported in the API).
2025-06-04 19:59:36 +02:00
03832842d5 build(deps): bump tree-sitter to v0.25.6 2025-06-04 19:31:08 +02:00
f577bb024e docs: getreg() type #34215
```lua
---@type string
local _a = vim.fn.getreg('a', 1)

---@type string[]
local _b = vim.fn.getreg('a', 1, 1)
```
2025-06-04 09:26:56 -07:00
442dade5be ci(release): drop manual shasum collection
This is now included for all GH release assets out-of-the-box, see
https://github.blog/changelog/2025-06-03-releases-now-expose-digests-for-release-assets/

These can be accessed programmatically through
  `gh release view --json assets <release tag>`
and then looking at the `digest` key.
2025-06-04 18:22:09 +02:00
7e393ff4f2 refactor(windows): redundant icon messages #34274
Problem:  Two separate window messages are used to get
          the original console icon and set a new
          one on windows, although the `WM_SETICON`
          message returns the original icon itself.

Solution: Replace the two `WM_GETICON` messages with
          two `WM_SETICON` messages, save the return
          values and remove the call to `os_icon_set`.
          Also, replace `os_icon_set` with `os_icon_reset`
          as its only usage is now resetting the
          icon to the original one.
2025-06-04 07:11:01 -07:00
dd9ac565d8 Merge pull request #34294 from glepnir/vim-9.1.1426
vim-patch:9.1.{1426,1428}: register completion improve
2025-06-04 13:46:19 +08:00
97ca92f9dd vim-patch:9.1.1428: completion: register completion needs cleanup
Problem:  completion: register completion needs cleanup
Solution: slightly refactor get_register_completion()
          (glepnir)

closes: vim/vim#17432

86d46a7018

Co-authored-by: glepnir <glephunter@gmail.com>
2025-06-04 13:27:38 +08:00
3d1f907912 vim-patch:2090405: runtime(doc): make examples verbatim to prevent conceal/tag parsing (#34299)
closes: vim/vim#17437

2090405de5
2025-06-04 05:55:24 +08:00
533cc0ab35 fix(vim.diagnostic): improve typing
Problem:

`vim.diagnostic.set()` doesn't actually accept a list of
`vim.Diagnostic` as internally `vim.diagnostic.set()` normalizes the
diagnostics and this normalization is assumed throughout the module.

Solution:

- Add a new type `vim.Diagnostic.Set` which is the input to `vim.diagnostic.set()`

- `col` is now an optional field and defaults to `0` to be consistent
  with `vim.diagnostic.match()`.

- Change `table.insert(t, x)` to `table[#table + 1] = x` for improved
  type checking.
2025-06-03 20:25:07 +01:00
9641ad9369 fix(diagnostics): diagnostic just after EOL is not highlighted #34085
Fixes #34013

Problem:
when diagnostic is set right after EOL, underline handler looks
inconsistent compared to other handlers, visually underline is shown
starting from the next line. On top of that it's also inconsistent with
open_float and jump.

Solution:
clamp starting column position in underline handler to be right before
EOL to make it visible and consistent with other handlers, open_float
and jump.
2025-06-03 07:22:36 -07:00
3991f14621 fix(glob): handling commas in letter pattern #34170 2025-06-03 06:36:44 -07:00
eeacd7bd71 fix(api): adjust fix for reconfiguring float "relative" (#34287)
Problem:  "win" is cleared in float config after 96330843, even with
          unchanged "relative".
Solution: Don't clear "win". Avoid erroring for deleted "win" by setting
          the parent win to curwin directly when "win" is zero or not
          present in config.
2025-06-03 13:27:07 +02:00
eb10852804 vim-patch:9.1.1426: completion: register contents not completed
Problem:  CTRL-X CTRL-R only completes individual words from registers,
          making it difficult to insert complete register content.
Solution: Add consecutive CTRL-X CTRL-R support - first press completes
          words, second press completes full register lines, similar to
          CTRL-X CTRL-L and CTRL-X CTRL-P behavior (glepnir).

closes: vim/vim#17395

d5fdfa5c9c

Co-authored-by: glepnir <glephunter@gmail.com>
2025-06-03 16:25:49 +08:00
ee84518b94 fix(excmd): don't allow range or args for :detach/:restart (#34280)
Also remove the CMDWIN and LOCK_OK flags, so that there is no need to
check for text_locked() and curbuf_locked().
2025-06-03 01:03:43 +00:00
049877d379 fix(tui): make :restart use new size after terminal resize (#34282) 2025-06-03 00:18:04 +00:00
304a9baebd vim-patch:3993cd6: runtime(vim): Update base-syntax, bug fixes (#34288)
- Contain :profdel arguments.
- Fix string highlighting immediately after lambda -> operators.

Reported by Aliaksei Budavei.

closes: vim/vim#17427

3993cd619a

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-06-02 23:58:11 +00:00
aa4fa24963 vim-patch:bfeefc4: runtime(doc): clarify the effect of exclusive single char selections (#34289)
closes: vim/vim#17410

bfeefc474a

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-06-02 23:54:29 +00:00
9c9c7ae30f Merge pull request #34247 from zeertzjq/vim-9.1.1301
vim-patch: various 'complete' features
2025-06-03 07:00:25 +08:00
525c02a89f vim-patch:9.1.1424: PMenu selection broken with multi-line selection and limits
Problem:  PMenu selection broken with multi-line selection and limits
          (Maxim Kim)
Solution: update completion match index when limiting the completion
          sources (Girish Palya)

fixes: vim/vim#17394
closes: vim/vim#17401

6c40df09e0

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-06-03 06:30:47 +08:00
9bfd0162dc vim-patch:9.1.1422: scheduling of complete function can be improved
Problem:  scheduling of complete function can be improved
Solution: call user completion functions earlier when just determining
          the insertion column (Girish Palya)

This change improves the scheduling behavior of async user-defined
completion functions (such as `F{func}`, `F`, or `'o'` values in the
`'complete'` option), particularly benefiting LSP clients.

Currently, these user functions are invoked twice:

1. First with `findstart = 1` to determine the completion start
   position.
2. Then with `findstart = 0` to retrieve the actual matches.

Previously, both calls were executed back-to-back. With this change, the
first call (`findstart = 1`) is performed earlier—before any matches are
gathered from other sources.

This adjustment gives event-driven completion sources (e.g., LSP
clients) more time to send their requests while Vim concurrently
collects matches from other sources like the current buffer.

Not sure about the real-world performance gains, but this approach
should, in theory, improve responsiveness and reduce latency for
asynchronous completions.

To test, try using yegappan LSP client:

```vim
set cpt+=o^10
autocmd VimEnter * g:LspOptionsSet({ autoComplete: false, omniComplete: true })
```

If you prefer to use 'native' auto-completion (without plugins), try the
following configuration:

```vim
set cot=menuone,popup,noselect,nearest
autocmd TextChangedI * InsComplete()
def InsComplete()
  if getcharstr(1) == '' && getline('.')->strpart(0, col('.') - 1) =~ '\k$'
    SkipTextChangedI()
    feedkeys("\<c-n>", "n")
  endif
enddef
inoremap <silent> <c-e> <c-r>=<SID>SkipTextChangedI()<cr><c-e>
inoremap <silent> <c-y> <c-r>=<SID>SkipTextChangedI()<cr><c-y>
def SkipTextChangedI(): string
  set eventignore+=TextChangedI
  timer_start(1, (_) => {
    set eventignore-=TextChangedI
  })
  return ''
enddef
inoremap <silent><expr> <tab> pumvisible() ? "\<c-n>" : "\<tab>"
inoremap <silent><expr> <s-tab> pumvisible() ? "\<c-p>" : "\<s-tab>"
```

closes: vim/vim#17396

98c29dbfd1

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-06-03 06:30:47 +08:00
bec1449cc5 vim-patch:9.1.1416: completion limits not respected for fuzzy completions
Problem:  completion limits not respected when using fuzzy completion
          (Maxim Kim)
Solution: trim completion array (Girish Palya)

fixes: vim/vim#17379
closes: vim/vim#17386

19ef6b0b4b

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-06-03 06:30:47 +08:00
2411f924a3 vim-patch:9.1.1410: out-of-bounds access with 'completefunc'
Problem:  out-of-bounds access with 'completefunc' (csetc)
Solution: check if it is safe to advance cpt_sources_index
          (Girish Palya)

fixes: vim/vim#17363
closes: vim/vim#17374

7c621052c3

Co-authored-by: Girish Palya <girishji@gmail.com>
Co-authored-by: @csetc
2025-06-03 06:30:47 +08:00
eeff6ca8ff vim-patch:9.1.1409: using f-flag in 'complete' conflicts with Neovim
Problem:  using f-flag in 'complete' conflicts with Neovims filename
          completion (glepnir, after v9.1.1301).
Solution: use upper-case "F" flag for completion functions
          (Girish Palya).

fixes: vim/vim#17347
closes: vim/vim#17378

14f6da5ba8

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-06-03 06:30:47 +08:00
13aec582b4 vim-patch:fa8b7db: runtime(doc): tweak documentation style in options.txt
closes: vim/vim#17229

fa8b7db99a

Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
2025-06-03 06:30:47 +08:00
857ff5cae9 vim-patch:9.1.1313: compile warning about uninitialized value
Problem:  compile warning about uninitialized value
          (Tony Mechelynck, after v9.1.1311)
Solution: initialize variable on declaration

b53d4fb63e

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-06-03 06:30:47 +08:00
b6acf6112b vim-patch:9.1.1311: completion: not possible to limit number of matches
Problem:  completion: not possible to limit number of matches
Solution: allow to limit the matches for 'complete' sources by using the
          "{flag}^{limit}" notation (Girish Palya)

This change extends the 'complete'  option to support limiting the
number of matches returned from individual completion sources.

**Rationale:** In large files, certain sources (such as the current
buffer) can generate an overwhelming number of matches, which may cause
more relevant results from other sources (e.g., LSP or tags) to be
pushed out of view. By specifying per-source match limits, the
completion menu remains balanced and diverse, improving visibility and
relevance of suggestions.

A caret (`^`) followed by a number can be appended to a source flag to
specify the maximum number of matches for that source. For example:
```
  :set complete=.^9,w,u,t^5
```
In this configuration:
- The current buffer (`.`) will return up to 9 matches.
- The tag completion (`t`) will return up to 5 matches.
- Other sources (`w`, `u`) are not limited.

This feature is fully backward-compatible and does not affect behavior
when the `^count` suffix is not used.

The caret (`^`) was chosen as the delimiter because it is least likely
to appear in file names.

closes: vim/vim#17087

0ac1eb3555

Cherry-pick test_options.vim change from patch 9.1.1325.

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-06-03 06:30:47 +08:00
c249389adb vim-patch:9.1.1302: Coverity warns about using uninitialized value
Problem:  Coverity warns about using uninitialized value
          (Coverity, Tony Mechelynck, after v9.1.1301)
Solution: initialize callback pointer to NULL

d2079cff48

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-06-03 06:30:47 +08:00
7651c43252 vim-patch:9.1.1301: completion: cannot configure completion functions with 'complete'
Problem:  completion: cannot configure completion functions with
          'complete'
Solution: add support for setting completion functions using the f and o
          flag for 'complete' (Girish Palya)

This change adds two new values to the `'complete'` (`'cpt'`) option:
- `f` – invokes the function specified by the `'completefunc'` option
- `f{func}` – invokes a specific function `{func}` (can be a string or `Funcref`)

These new flags extend keyword completion behavior (e.g., via `<C-N>` /
`<C-P>`) by allowing function-based sources to participate in standard keyword
completion.

**Key behaviors:**

- Multiple `f{func}` values can be specified, and all will be called in order.
- Functions should follow the interface defined in `:help complete-functions`.
- When using `f{func}`, escaping is required for spaces (with `\`) and commas
  (with `\\`) in `Funcref` names.
- If a function sets `'refresh'` to `'always'`, it will be re-invoked on every
  change to the input text. Otherwise, Vim will attempt to reuse and filter
  existing matches as the input changes, which matches the default behavior of
  other completion sources.
- Matches are inserted at the keyword boundary for consistency with other completion methods.
- If finding matches is time-consuming, `complete_check()` can be used to
  maintain responsiveness.
- Completion matches are gathered in the sequence defined by the `'cpt'`
  option, preserving source priority.

This feature increases flexibility of standard completion mechanism and may
reduce the need for external completion plugins for many users.

**Examples:**

Complete matches from [LSP](https://github.com/yegappan/lsp) client. Notice the use of `refresh: always` and `function()`.

```vim
set cpt+=ffunction("g:LspCompletor"\\,\ [5]). # maxitems = 5

def! g:LspCompletor(maxitems: number, findstart: number, base: string): any
    if findstart == 1
        return g:LspOmniFunc(findstart, base)
    endif
    return {words: g:LspOmniFunc(findstart, base)->slice(0, maxitems), refresh: 'always'}
enddef
autocmd VimEnter * g:LspOptionsSet({ autoComplete: false, omniComplete: true })
```

Complete matches from `:iabbrev`.

```vim
set cpt+=fAbbrevCompletor

def! g:AbbrevCompletor(findstart: number, base: string): any
    if findstart > 0
        var prefix = getline('.')->strpart(0, col('.') - 1)->matchstr('\S\+$')
        if prefix->empty()
            return -2
        endif
        return col('.') - prefix->len() - 1
    endif
    var lines = execute('ia', 'silent!')
    if lines =~? gettext('No abbreviation found')
        return v:none  # Suppresses warning message
    endif
    var items = []
    for line in lines->split("\n")
        var m = line->matchlist('\v^i\s+\zs(\S+)\s+(.*)$')
        if m->len() > 2 && m[1]->stridx(base) == 0
            items->add({ word: m[1], info: m[2], dup: 1 })
        endif
    endfor
    return items->empty() ? v:none :
        items->sort((v1, v2) => v1.word < v2.word ? -1 : v1.word ==# v2.word ? 0 : 1)
enddef
```

**Auto-completion:**

Vim's standard completion frequently checks for user input while searching for
new matches. It is responsive irrespective of file size. This makes it
well-suited for smooth auto-completion. You can try with above examples:

```vim
set cot=menuone,popup,noselect inf

autocmd TextChangedI * InsComplete()

def InsComplete()
    if getcharstr(1) == '' && getline('.')->strpart(0, col('.') - 1) =~ '\k$'
        SkipTextChangedIEvent()
        feedkeys("\<c-n>", "n")
    endif
enddef

inoremap <silent> <c-e> <c-r>=<SID>SkipTextChangedIEvent()<cr><c-e>

def SkipTextChangedIEvent(): string
    # Suppress next event caused by <c-e> (or <c-n> when no matches found)
    set eventignore+=TextChangedI
    timer_start(1, (_) => {
        set eventignore-=TextChangedI
    })
    return ''
enddef
```

closes: vim/vim#17065

cbe53191d0

Temporarily remove bufname completion with #if 0 to make merging easier.

Co-authored-by: Girish Palya <girishji@gmail.com>
Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: glepnir <glephunter@gmail.com>
2025-06-03 06:30:46 +08:00
0af6d6ff5e vim-patch:9.1.1147: preview-window does not scroll correctly
Problem:  preview-window does not scroll correctly
Solution: init firstline = 0 for a preview window
          (Girish Palya)

The 'info' window, which appears during insert-mode completion to display
additional information, was not scrolling properly when using commands like:
	win_execute(popup_findinfo(), "normal! \<PageDown>")
This issue made it impossible to navigate through info window contents using
keyboard-based scrolling.
The fix correctly updates the w_firstline value of the popup window, ensuring
proper scrolling behavior. Mouse scrolling was already working as expected and
remains unaffected.

closes: vim/vim#16703

12b1eb58ab

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-06-03 06:30:46 +08:00
33b0a004eb fix(extui): properly setup "more" window for changed buffer
Problem:  Buffer setup after moving the message buffer to the "more"
          window after ff95d7ff is incomplete.
Solution: Adjust and invoke tab_check_wins() to do the setup instead.
2025-06-02 16:32:48 +02:00
5e83d0f5ad fix(extui): reposition "more" window after entering cmdwin
Problem:  Closing the "more" window for an entered cmdwin in ff95d7ff9
          still requires special casing to properly handle "more" visibility.
Solution: Reposition the "more" window instead; anchoring it to the
          cmdwin.
2025-06-02 16:32:48 +02:00
963308439a fix(api): reconfiguring float "relative" does not clear "win" (#34271)
Problem:  Unable to change the "relative" of a flag after its target
          "win" no longer exists.
Solution: Unset target window if it is not present in config and
          reconfigured "relative" no longer expects a target window.
2025-06-02 14:59:19 +02:00
86835b3db3 feat(editor): ":restart" command #33953
Problem:
Developing/troubleshooting plugins has friction because "restarting"
Nvim requires quitting and manually starting again. #32484

Solution:
- Implement a `:restart` command which emits `restart` UI event.
- Handle the `restart` UI event in the builtin TUI client: stop the
  `nvim --embed` server, start a new one, and attach to it.
2025-06-02 05:54:17 -07:00
236243029d vim-patch:b577ad5: runtime(java): Match annotation- and interface-type names of "java.lang"
Complement the documented support for the recognition of all
public types of the "java.lang" package (":help java.vim").
(The original syntax item generator may have, inadvertently,
contributed via suppressing "NullPointerException"s to not
having annotation and interface types qualify in general.)

Also, re-link usage instructions for the alternative syntax
item generator to a rolling "master"'s version.

closes: vim/vim#17419

b577ad50d0

Co-authored-by: Aliaksei Budavei <0x000c70@gmail.com>
2025-06-02 10:03:12 +02:00
5fd03508aa vim-patch:95ea0b0: runtime(doc): make 'shiftwidth' setting more precise (#34266)
closes: vim/vim#17414

95ea0b0f8d

Co-authored-by: Damien Lejay <damien@lejay.be>
2025-06-02 08:26:34 +08:00
06f07a104b vim-patch:0aaf6f8: runtime(vim): Update base-syntax, improve :profile highlighting (#34265)
Match full :profile and :profdel commands.

closes: vim/vim#17420

0aaf6f8bbb

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-06-02 00:11:36 +00:00