I am using the example vimrc given in README.md.
The question is, when there is no candidate for completion and the cursor is at the end of a word, tapping tab results nothing.
In my opinion, the ideal behavior for this case should be moving the cursor to next tab position, other than searching completion candidates in an empty list.
I believe this is caused by
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
in given vimrc configuration
How can I fix it without changing the normal behavior when the completion candidate list is not empty? Thanks!
should be moving the cursor to next tab position.
What does next tab position means?
The cursor is at the end of a word doesn't means the completion request would return empty results, it's sometimes.
should be moving the cursor to next tab position.
What does next tab position means?
It means inserting a tab character.
I am using the example vimrc given in README.md.
I believe this is caused by
...
Indeed. Check this wiki page: https://github.com/neoclide/coc.nvim/wiki/Completion-with-sources#improve-completion-experience
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
The code above should make it work the way you want.
When I comment that line out of vimrc I get the behaviour you described. It remaps tab back to tab when there is no completion window open.
The example in Readme is for trigger completion when there is word character before, but what you need is not trigger the completion, so you have to create your own keymap for <Tab>
.
inoremap <silent><expr> <TAB> \ pumvisible() ? "\<C-n>" : \ <SID>check_back_space() ? "\<TAB>" : \ coc#refresh() inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>" inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
The code above should make it work the way you want.
When I comment that line out of vimrc I get the behaviour you described. It remaps tab back to tab when there is no completion window open.
This works. Thank you @DzKaki !
Most helpful comment
It means inserting a tab character.
Indeed. Check this wiki page: https://github.com/neoclide/coc.nvim/wiki/Completion-with-sources#improve-completion-experience
The code above should make it work the way you want.
When I comment that line out of vimrc I get the behaviour you described. It remaps tab back to tab when there is no completion window open.