nvim-lua / completion-nvim

A async completion framework aims to provide completion to neovim's built in LSP written in Lua
Apache License 2.0
973 stars 79 forks source link

Add "minimum completion length" configuration option #375

Open mrcjkb opened 3 years ago

mrcjkb commented 3 years ago

Is your feature request related to a problem? Please describe. It is usually faster to type a 2-3 letter keyword than it is to select it from an auto-complete list. For example, with my current configuration, typing in results in the following completion list:

in    | UltiSnips
if    | Keyword
int   | Keyword
InternetDomainName - com.google.common.net | Class
...

Describe the solution you'd like For me, the if and int completions (and possibly the UltiSnips in snippet) are useless, as it is faster to just type them. It would be great to be able to configure a minimum length for completion items. Either globally or by source (e.g. so that a different minimum completion length could be set for snippet completions than for LSP completions).

Describe alternatives you've considered I may look into this myself when I have some time. Here is a good article that describes the problem: https://blog.jetbrains.com/blog/2021/05/28/code-completion-episode-1-scenarios-and-requirements/

ranjithshegde commented 3 years ago

@MrcJkb Do you mean the minimum amount of characters after which completion should be triggered? if so, have tried let g:completion_trigger_keyword_length = 3

mrcjkb commented 3 years ago

@MrcJkb Do you mean the minimum amount of characters after which completion should be triggered? if so, have tried let g:completion_trigger_keyword_length = 3

Yes, thanks for the hint. But I suppose that variable would affect all sources, wouldn't it? Ideally, I would like to be able to set the minimum amount of characters for different sources, e.g. 2 for UltiSnips and 5 for LSP.

ranjithshegde commented 3 years ago

Hmm, I doubt there is a way to do that yet. Maybe play around with let g:completion_sorting = "length". I dont know if length sorts ascending or descending, but worth a try?