]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.1.1311: completion: not possible to limit number of matches v9.1.1311
authorGirish Palya <girishji@gmail.com>
Wed, 16 Apr 2025 18:18:33 +0000 (20:18 +0200)
committerChristian Brabandt <cb@256bit.org>
Wed, 16 Apr 2025 18:18:33 +0000 (20:18 +0200)
commit0ac1eb3555445f4c458c06cef7c411de1c8d1020
tree634a38537fa64fef07cee982f44f886e400f5345
parent1c2b25825037bf83862f7af71ce9177cf949daca
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: #17087

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/options.txt
runtime/doc/version9.txt
src/insexpand.c
src/optionstr.c
src/testdir/test_ins_complete.vim
src/testdir/test_options.vim
src/version.c