completor.vim icon indicating copy to clipboard operation
completor.vim copied to clipboard

Minimum character to trigger the completion

Open fatih opened this issue 8 years ago • 3 comments

Right now completor tries to complete even if you write a single character. There should be an option to limit the input pattern. Example options from other plugins:

https://github.com/Shougo/deoplete.nvim/blob/master/doc/deoplete.txt#L648 https://github.com/Shougo/neocomplete.vim/blob/master/doc/neocomplete.txt#L290 https://github.com/Valloric/YouCompleteMe/blob/master/doc/youcompleteme.txt#L1861

Without this, it tries to complete everytime the user wants to write something, which is not performant.

fatih avatar Oct 24 '16 11:10 fatih

I can get this work if I modified my omni trigger from

let g:completor_php_omni_trigger = '([$\w]+|use\s*|->[$\w]*|::[$\w]*|implements\s*|extends\s*|class\s+[$\w]+|new\s*)$'

to

let g:completor_php_omni_trigger = '([$\w]{2,}|use\s*|->[$\w]*|::[$\w]*|implements\s*|extends\s*|class\s+[$\w]+|new\s*)$

You can see I changed my regexp counter from + to {2,}, that means it only trigger completor.vim to complete the word more than two characters.

I know it is not a general solution, but it works for me at this moment.

markwu avatar Oct 27 '16 15:10 markwu

I added a option to specify minimum characters:

let g:completor_min_chars = 2

maralla avatar Oct 29 '16 07:10 maralla

The trick to make the performance better is by being smart about caching instead of using min chars or changing the omni trigger patterns.

I have implemented this trick for asyncomplete at https://github.com/prabirshrestha/asyncomplete.vim/pull/3 and nvim-completion-manage also uses similar trick. It is based on my observation of how VsCode provides autocomplete. Currently asyncomplete is implemented in pure vimscript (which is supposed to be a slow at runtime) and doesn't have min_chars yet it doesn't feel slow at all. The algorithm is described in details at https://github.com/roxma/nvim-completion-manager/issues/30#issuecomment-283281158 if you are interested in implementation for completor.vim.

prabirshrestha avatar Apr 05 '17 05:04 prabirshrestha