|
|
|
|
" if hidden is not set, TextEdit might fail.
|
|
|
|
|
set hidden
|
|
|
|
|
|
|
|
|
|
" Some servers have issues with backup files, see #649
|
|
|
|
|
set nobackup
|
|
|
|
|
set nowritebackup
|
|
|
|
|
|
|
|
|
|
" Better display for messages
|
|
|
|
|
set cmdheight=2
|
|
|
|
|
|
|
|
|
|
" You will have bad experience for diagnostic messages when it's default 4000.
|
|
|
|
|
set updatetime=300
|
|
|
|
|
|
|
|
|
|
" don't give |ins-completion-menu| messages.
|
|
|
|
|
set shortmess+=c
|
|
|
|
|
|
|
|
|
|
" always show signcolumns
|
|
|
|
|
set signcolumn=yes
|
|
|
|
|
|
|
|
|
|
" python .env-contains-pythonpath support
|
|
|
|
|
autocmd FileType python let b:coc_root_patterns = ['.cocroot', '.git', '.env']
|
|
|
|
|
|
|
|
|
|
" useful key shortcuts
|
|
|
|
|
nmap <silent> rn <Plug>(coc-rename)
|
|
|
|
|
nmap <silent> td <Plug>(coc-definition)
|
|
|
|
|
nmap <silent> ty <Plug>(coc-type-definition)
|
|
|
|
|
nmap <silent> ti <Plug>(coc-implementation)
|
|
|
|
|
nmap <silent> tr <Plug>(coc-references)
|
|
|
|
|
nmap <silent> te <Plug>(coc-diagnostic-next-error)
|
|
|
|
|
nmap <silent> tn <Plug>(coc-diagnostic-next)
|
|
|
|
|
xmap ,r <Plug>(coc-format)
|
|
|
|
|
nmap ,r <Plug>(coc-format)
|
|
|
|
|
|
|
|
|
|
" Add `:Format` command to format current buffer.
|
|
|
|
|
command! -nargs=0 Format :call CocAction('format')
|
|
|
|
|
|
|
|
|
|
nmap f <Plug>(coc-smartf-forward)
|
|
|
|
|
nmap F <Plug>(coc-smartf-backward)
|
|
|
|
|
nmap ; <Plug>(coc-smartf-repeat)
|
|
|
|
|
nmap , <Plug>(coc-smartf-repeat-opposite)
|
|
|
|
|
|
|
|
|
|
augroup Smartf
|
|
|
|
|
autocmd User SmartfEnter :hi Conceal ctermfg=220 guifg=#6638F0
|
|
|
|
|
autocmd User SmartfLeave :hi Conceal ctermfg=239 guifg=#504945
|
|
|
|
|
augroup end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
" Use tab for trigger completion with characters ahead and navigate.
|
|
|
|
|
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
|
|
|
|
|
inoremap <silent><expr> <TAB>
|
|
|
|
|
\ pumvisible() ? "\<C-n>" :
|
|
|
|
|
\ <SID>check_back_space() ? "\<TAB>" :
|
|
|
|
|
\ coc#refresh()
|
|
|
|
|
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
|
|
|
|
|
|
|
|
|
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
|
|
|
|
|
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
|
|
|
|
|
function! s:check_back_space() abort
|
|
|
|
|
let col = col('.') - 1
|
|
|
|
|
return !col || getline('.')[col - 1] =~# '\s'
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" Use <c-space> to trigger completion.
|
|
|
|
|
inoremap <silent><expr> <c-space> coc#refresh()
|
|
|
|
|
|
|
|
|
|
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
|
|
|
|
|
" Coc only does snippet and additional edit on confirm.
|
|
|
|
|
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
|
|
|
|
|
" Or use `complete_info` if your vim support it, like:
|
|
|
|
|
" inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
|
|
|
|
|
|
|
|
|
|
" Use K to show documentation in preview window
|
|
|
|
|
nnoremap <silent> K :call <SID>show_documentation()<CR>
|
|
|
|
|
|
|
|
|
|
function! s:show_documentation()
|
|
|
|
|
if (index(['vim','help'], &filetype) >= 0)
|
|
|
|
|
execute 'h '.expand('<cword>')
|
|
|
|
|
else
|
|
|
|
|
call CocAction('doHover')
|
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" Highlight symbol under cursor on CursorHold
|
|
|
|
|
autocmd CursorHold * silent call CocActionAsync('highlight')
|