Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keyword_length is not "number of characters that need to be typed to trigger auto-completion" #42

Open
davidq2010 opened this issue Apr 10, 2022 · 4 comments

Comments

@davidq2010
Copy link

From experimentation, keyword_length seems to be the min number of characters that a word must have to appear in the auto-completion list, not the number of characters that need to be typed to trigger auto-completion (which is what the README says). My understanding seems to be consistent with

if #word >= self.opts.keyword_length then
(although I'm a Lua beginner).

It would be really nice however if keyword_length actually was the number of chars to be typed to trigger auto-completion.

@scienceplease
Copy link

scienceplease commented Apr 17, 2022

I have to concur with @davidq2010 in that this behavior is very confusing and seems unintentional. The keyword_length option in the top level of a source's table determines the number of characters that will trigger the completion menu while keyword_length within option determines the minimum length of a completion candidate. It would be best to change the latter to something more descriptive like min_candidate_length and update the documentation.

local buffer_source = {
    name = 'buffer',
    keyword_length = 5,     -- Trigger completion menu on Nth character.
    option = {
        keyword_length = 5, -- Minimum length for completion candidates.
    }
} 

Top-level keyword_length for sources is documented in nvim-cmp and parsed out here.

@adworacz
Copy link

This was massively confusing me as well, thank you @scienceplease for the example, which really cleared up my understanding.

@svenXY
Copy link

svenXY commented Jul 20, 2022

same here - I completely agree with @scienceplease that a different keyword would help here.
Perhaps - unless I missed it - it could make sense to mention in the docs that top-level nvim-cmp source options are allowed /required and where to find them

@rlopzc
Copy link

rlopzc commented Feb 9, 2023

x2 on this. I just updated my config to add a root keyword_length to get the behaviour I wanted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants