Feature: Add per-source match limit support to 'complete' option#17087
Closed
girishji wants to merge 14 commits intovim:masterfrom
Closed
Feature: Add per-source match limit support to 'complete' option#17087girishji wants to merge 14 commits intovim:masterfrom
girishji wants to merge 14 commits intovim:masterfrom
Conversation
This was referenced Apr 10, 2025
41bed58 to
951eac5
Compare
M src/insexpand.c M src/optionstr.c
M src/insexpand.c
M src/insexpand.c
M src/insexpand.c
M runtime/doc/options.txt M src/insexpand.c
M src/insexpand.c
M src/insexpand.c
M runtime/doc/options.txt
M src/insexpand.c M src/optionstr.c
M runtime/doc/tags
chrisbra
reviewed
Apr 15, 2025
Co-authored-by: Christian Brabandt <[email protected]>
M src/insexpand.c
Contributor
Author
|
Thanks! |
Contributor
|
Hi @girishji, Is it supposed to work with If I prepend Maybe the doc should be updated? |
Contributor
|
Hm, I can see you use quite a few vim/src/testdir/test_ins_complete.vim Line 4124 in 8435cf6 |
Contributor
Contributor
Contributor
Author
|
Looks like a bug. Will look into this. |
zeertzjq
added a commit
to zeertzjq/neovim
that referenced
this pull request
May 31, 2025
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
vim/vim@0ac1eb3
Cherry-pick test_options.vim change from patch 9.1.1325.
Co-authored-by: Girish Palya <[email protected]>
zeertzjq
added a commit
to zeertzjq/neovim
that referenced
this pull request
Jun 2, 2025
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
vim/vim@0ac1eb3
Cherry-pick test_options.vim change from patch 9.1.1325.
Co-authored-by: Girish Palya <[email protected]>
zeertzjq
added a commit
to zeertzjq/neovim
that referenced
this pull request
Jun 2, 2025
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
vim/vim@0ac1eb3
Cherry-pick test_options.vim change from patch 9.1.1325.
Co-authored-by: Girish Palya <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.





This change extends the
'complete'('cpt') 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:In this configuration:
.) will return up to 9 matches.t) will return up to 5 matches.w,u) are not limited.This feature is fully backward-compatible and does not affect behavior when the
^countsuffix is not used.The caret (
^) was chosen as the delimiter because it is least likely to appear in file names.After limiting the matches to 5, the LSP-sourced matches (indented ones) become visible:
Without this change, only matches from the current buffer are visible, and LSP-sourced matches remain hidden: