mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
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>
This commit is contained in:
7
runtime/lua/vim/_meta/options.lua
generated
7
runtime/lua/vim/_meta/options.lua
generated
@ -1059,6 +1059,13 @@ vim.bo.cms = vim.bo.commentstring
|
||||
--- based expansion (e.g., dictionary `i_CTRL-X_CTRL-K`, included patterns
|
||||
--- `i_CTRL-X_CTRL-I`, tags `i_CTRL-X_CTRL-]` and normal expansions).
|
||||
---
|
||||
--- An optional match limit can be specified for a completion source by
|
||||
--- appending a caret ("^") followed by a {count} to the source flag.
|
||||
--- For example: ".^9,w,u,t^5" limits matches from the current buffer
|
||||
--- to 9 and from tags to 5. Other sources remain unlimited.
|
||||
--- The match limit takes effect only during forward completion (CTRL-N)
|
||||
--- and is ignored during backward completion (CTRL-P).
|
||||
---
|
||||
--- @type string
|
||||
vim.o.complete = ".,w,b,u,t"
|
||||
vim.o.cpt = vim.o.complete
|
||||
|
Reference in New Issue
Block a user