diff --git a/.vimrc b/.vimrc index efbe7f3e18a20dc98a6a9c004aaba2eb5a5ca866..dc52951dfe2c742cfd6986a93c79c8d327885538 100644 --- a/.vimrc +++ b/.vimrc @@ -950,9 +950,26 @@ nmap <silent> <leader>me <Plug>(coc-command)expandMacro nmap <silent> <leader>gh :CocCommand clangd.switchSourceHeader<CR> nmap <silent> <leader>gH :CocCommand clangd.switchSourceHeader vsplit<CR> nmap <silent> <leader>gsi :CocCommand clangd.SymbolInfo<CR> + +" From coc-completion-help 2022-08-01 +inoremap <expr> <cr> coc#pum#visible() ? coc#_select_confirm() : "\<CR>" + " Use K to show documentation in preview window nnoremap <silent> K :call <SID>show_documentation()<CR> + function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~ '\s' + endfunction + + " Insert <tab> when previous text is space, refresh completion if not. + inoremap <silent><expr> <TAB> + \ coc#pum#visible() ? coc#pum#next(1): + \ <SID>check_back_space() ? "\<Tab>" : + \ coc#refresh() + inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>" + + function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('<cword>')