Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
I would like auto-completion behaves like vscode. When you type the preview auto display and the first item is always selected. You only need
Plug 'neoclide/coc.nvim', { 'do': { -> coc#util#install() } }
set updatetime=300
set signcolumn=yes
" Close preview window after completion is done
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
" Use <Tab> for confirm completion.
" Coc only does snippet and additional edit on confirm.
inoremap <expr> <Tab> pumvisible() ? "\<C-y>" : "\<Tab>"
" Use <c-space> for trigger completion.
inoremap <silent><expr> <C-Space> coc#refresh()
" Use <C-x><C-o> to complete 'word', 'emoji' and 'include' sources
imap <silent> <C-x><C-o> <Plug>(coc-complete-custom)
" Use `[c` and `]c` for navigate diagnostics
nmap <silent> [c <Plug>(coc-diagnostic-prev)
nmap <silent> ]c <Plug>(coc-diagnostic-next)
" Remap keys for goto
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K for show documentation in preview window
nnoremap <silent> gh :call <SID>show_documentation()<CR>
function! s:show_documentation()
if &filetype == 'vim'
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Show signature help while editing
autocmd CursorHoldI * silent! call CocAction('showSignatureHelp')
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
" Remap for rename current word
nmap <F2> <Plug>(coc-rename)
" Use `:Format` for format current buffer
command! -nargs=0 CocFormat :call CocAction('format')
nmap <leader>r :CocFormat<CR>
" Use `:Fold` for fold current buffer
command! -nargs=? CocFold :call CocAction('fold', <f-args>)
As you can see I have to spend 1 more keystroke to select the first item and trigger completion with
How could I achieve the completion exp like vscode with coc.nvim?
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
noselect is added to completeopt by default.
You just need to add "coc.preferences.noselect": false to your coc-settings.json to change this.
To show the preview window, you need to add preview to your completeopt.
If the documentation of complete item comes from complete resolve, the preview window is not shown, that's because vim has bug with open preview window when popup menu is visible, should be resolved when floating window feature launched on neovim.
thanks for very fast response. can I set completeopt-=noselect instead? IMO we should let user set the completeopt instead of implicitly modifying user setting.
and I think CocConfig is great for extension config but not vim/neovim config. How could I sync my CocConfig across multi-devices?
BTW, after setting "coc.preferences.noselect": false, snippet confirm completion is not working.
IMO we should let user set the completeopt instead of implicitly modifying user setting
It is by design, because vim has menu,preview by default, and increment completion of coc works better with noselect enabled. Coc doesn't implicitly modifying user setting (it has to modify it on vim) on neovim, it use it's own completeopt on completion and restore the setting on complete done.
It doesn't require one more key stroke if you map <tab> to <C-n> on pumvisible, since you just press <tab> to select and vim would does insert for you, unless you need expand snippet which requires confirm selection.
and I think CocConfig is great for extension config but not vim/neovim config.
I would prefer coc config since it's has completion and validation support by using coc-json, unless vim script needs it.
How could I sync my CocConfig across multi-devices?
Copy the settings file opened by :CocConfig and run CocInstall for extensions you use.
BTW, after setting
"coc.preferences.noselect": false, snippet confirm completion is not working.
That's because coc does complete resolve by check the changed text on completion, it could be fixed.
I just want to mention here that i just want coc.nvim completion behaves like vscode.
When you are typing, the completion window pop up with selection on the first choice. if we hit
How could I sync CocConfig
I mean I want to use git to sync all of my dotfiles but I could not do that with cocconfig
I want to use tab to both confirm completion or expand the snippet.
It's fixed on master branch, build from source to make it works.
I mean I want to use git to sync all of my dotfiles but I could not do that with cocconfig
You can use link.
hi @chemzqm, unfortunately, git does not support link. the file only contains the path to the actual file.
hi @chemzqm, unfortunately, git does not support link. the file only contains the path to the actual file.
I mean you use link to link files from git.
Thanks, I got it.
Just noting that this option has been renamed "suggest.noselect" (per #462)
In my case is only worked when I open the coc json file no need to save it, Just open the file in vim. the Auto select the first item works. If I open any other file without open coc.json. It will not select the first item. What happened in my case?
link
I use the configuration here. Is there a conflict in it?
Add "suggest.enablePreselect": false to your coc-settings.json
See, it's simple. The default option in coc-settings.json is "suggest.noselect": true. You need to make it "suggest.noselect": false.
Most helpful comment
Just noting that this option has been renamed
"suggest.noselect"(per #462)