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

Issue on pressing tab at the end of a word #534

Closed
HaoboGu opened this issue Mar 16, 2019 · 5 comments
Closed

Issue on pressing tab at the end of a word #534

HaoboGu opened this issue Mar 16, 2019 · 5 comments
Labels
question Further information is requested

Comments

@HaoboGu
Copy link

HaoboGu commented Mar 16, 2019

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!

@chemzqm
Copy link
Member

chemzqm commented Mar 16, 2019

should be moving the cursor to next tab position.

What does next tab position means?

@chemzqm
Copy link
Member

chemzqm commented Mar 16, 2019

The cursor is at the end of a word doesn't means the completion request would return empty results, it's sometimes.

@chemzqm chemzqm added the question Further information is requested label Mar 16, 2019
@kakig
Copy link

kakig commented Mar 16, 2019

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.

@chemzqm
Copy link
Member

chemzqm commented Mar 16, 2019

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>.

@chemzqm chemzqm closed this as completed Mar 16, 2019
@HaoboGu
Copy link
Author

HaoboGu commented Mar 18, 2019

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 !

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

No branches or pull requests

3 participants