Select _and_ trigger completion with <tab>

main
mandlm 2020-11-21 10:46:35 +01:00
parent e34a27110e
commit 437e2fedf9
Signed by: mandlm
GPG Key ID: 4AA25D647AA54CC7
1 changed files with 17 additions and 3 deletions

View File

@ -125,9 +125,6 @@ augroup close_preview
autocmd InsertLeave * silent! pclose!
augroup end
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" autoread/checktime timer {{{
set autoread
function! CheckTime(timer)
@ -174,3 +171,20 @@ nnoremap <silent> K :call CocAction('doHover')<CR>
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gr <Plug>(coc-references)
" use <tab> for trigger completion and navigate to the next complete item
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
inoremap <silent><expr> <Tab>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<Tab>" :
\ coc#refresh()
inoremap <silent><expr> <S-Tab>
\ pumvisible() ? "\<C-p>" :
\ <SID>check_back_space() ? "\<S-Tab>" :
\ coc#refresh()