2019-04-21 11:42:15 +00:00
|
|
|
" pop-up (completion) menu mappings {{{
|
2019-12-15 20:17:10 +00:00
|
|
|
imap <silent><expr> <CR> pumvisible() ? "\<C-y>" : "\<Plug>delimitMateCR"
|
|
|
|
imap <silent><expr> <Esc> pumvisible() ? "\<C-e>" : "\<Esc>"
|
|
|
|
imap <silent><expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
|
2019-04-21 11:42:15 +00:00
|
|
|
imap <silent><expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
|
|
|
|
" }}}
|
|
|
|
|
2019-06-20 23:27:47 +00:00
|
|
|
if !g:vim_ide
|
|
|
|
function IsCocEnabled()
|
|
|
|
return 0
|
|
|
|
endfunction
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
2019-04-21 11:42:15 +00:00
|
|
|
" coc.nvim {{{
|
|
|
|
" list of filetypes (that are added in language-specific scripts) for which
|
|
|
|
" coc mappings are enabled
|
|
|
|
let g:coc_filetypes = []
|
|
|
|
|
|
|
|
function IsCocEnabled()
|
|
|
|
return index(g:coc_filetypes, &filetype) >= 0
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
augroup vimrc-coc
|
|
|
|
autocmd!
|
|
|
|
autocmd FileType * if IsCocEnabled()
|
|
|
|
\|let &l:formatexpr = "CocAction('formatSelected')"
|
|
|
|
\|let &l:keywordprg = ":call CocAction('doHover')"
|
|
|
|
\|endif
|
|
|
|
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
|
|
|
|
augroup end
|
|
|
|
|
|
|
|
" mappings {{{
|
|
|
|
let g:coc_snippet_next = '<Tab>'
|
|
|
|
let g:coc_snippet_prev = '<S-Tab>'
|
|
|
|
|
|
|
|
inoremap <silent><expr> <C-Space> coc#refresh()
|
|
|
|
|
|
|
|
nmap <silent> [c <Plug>(coc-diagnostic-prev)
|
|
|
|
nmap <silent> ]c <Plug>(coc-diagnostic-next)
|
|
|
|
|
2019-04-22 20:16:43 +00:00
|
|
|
nmap <silent> <space>gd <Plug>(coc-definition)
|
|
|
|
nmap <silent> <space>gt <Plug>(coc-type-definition)
|
|
|
|
nmap <silent> <space>gi <Plug>(coc-implementation)
|
|
|
|
nmap <silent> <space>gr <Plug>(coc-references)
|
2019-04-21 11:42:15 +00:00
|
|
|
nmap <silent> <F2> <Plug>(coc-rename)
|
|
|
|
nmap <silent> <A-CR> <Plug>(coc-codeaction)
|
|
|
|
vmap <silent> <A-CR> <Plug>(coc-codeaction-selected)
|
|
|
|
" nmap <silent> <leader>qf <Plug>(coc-fix-current)
|
|
|
|
|
2019-05-01 14:40:25 +00:00
|
|
|
nnoremap <silent> <space>l <Cmd>CocList<CR>
|
|
|
|
nnoremap <silent> <space>d <Cmd>CocList --auto-preview diagnostics<CR>
|
|
|
|
nnoremap <silent> <space>c <Cmd>CocList commands<CR>
|
|
|
|
nnoremap <silent> <space>o <Cmd>CocList --auto-preview outline<CR>
|
|
|
|
nnoremap <silent> <space>s <Cmd>CocList --interactive symbols<CR>
|
|
|
|
nnoremap <silent> <space>h <Cmd>CocPrev<CR>
|
|
|
|
nnoremap <silent> <space>k <Cmd>CocPrev<CR>
|
|
|
|
nnoremap <silent> <space>l <Cmd>CocNext<CR>
|
|
|
|
nnoremap <silent> <space>j <Cmd>CocNext<CR>
|
|
|
|
nnoremap <silent> <space>p <Cmd>CocListResume<CR>
|
2019-04-21 11:42:15 +00:00
|
|
|
" }}}
|
|
|
|
|
|
|
|
" CocFormat {{{
|
|
|
|
function s:CocFormat(range, line1, line2) abort
|
|
|
|
if a:range == 0
|
|
|
|
call CocAction('format')
|
|
|
|
else
|
|
|
|
call cursor(a:line1, 1)
|
|
|
|
normal! V
|
|
|
|
call cursor(a:line2, 1)
|
|
|
|
call CocAction('formatSelected', 'V')
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
command! -nargs=0 -range -bar CocFormat call s:CocFormat(<range>, <line1>, <line2>)
|
|
|
|
" }}}
|
|
|
|
|
|
|
|
call coc#add_extension('coc-snippets')
|
2019-06-27 22:28:22 +00:00
|
|
|
call coc#config('diagnostic', {
|
|
|
|
\ 'virtualText': v:true,
|
|
|
|
\ 'enableMessage': 'jump',
|
|
|
|
\ 'errorSign': 'XX',
|
|
|
|
\ 'warningSign': '!!',
|
|
|
|
\ })
|
2019-12-15 20:17:10 +00:00
|
|
|
|
|
|
|
runtime! coc-languages/*.vim
|
|
|
|
|
2019-04-21 11:42:15 +00:00
|
|
|
" }}}
|