cmp-buffer
cmp-buffer copied to clipboard
keyword_length is not "number of characters that need to be typed to trigger auto-completion"
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 https://github.com/hrsh7th/cmp-buffer/blob/f83773e2f433a923997c5faad7ea689ec24d1785/lua/cmp_buffer/buffer.lua#L324 (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.
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.
This was massively confusing me as well, thank you @scienceplease for the example, which really cleared up my understanding.
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
x2 on this. I just updated my config to add a root keyword_length
to get the behaviour I wanted