diff --git a/home/common/coc.vim b/home/common/coc.vim index 86cbe04..e9b6f30 100644 --- a/home/common/coc.vim +++ b/home/common/coc.vim @@ -1,3 +1,9 @@ +" 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 + " Use tab for trigger completion with characters ahead and navigate. " Use command ':verbose imap ' to make sure tab is not mapped by other plugin. inoremap @@ -11,11 +17,15 @@ let col = col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction +" Use to trigger completion. +inoremap coc#refresh() + " Use to confirm completion, `u` means break undo chain at current position. inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" -" Use to trigger completion. -inoremap coc#refresh() +" Use `[g` and `]g` to navigate diagnostics +nmap [g (coc-diagnostic-prev) +nmap ]g (coc-diagnostic-next) " Remap keys for gotos nmap gd (coc-definition) @@ -23,6 +33,17 @@ nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) +" Use K to show documentation in preview window +nnoremap K :call show_documentation() + +function! s:show_documentation() + if (index(['vim','help'], &filetype) >= 0) + execute 'h '.expand('') + else + call CocAction('doHover') + endif +endfunction + " Highlight symbol under cursor on CursorHold autocmd CursorHold * silent call CocActionAsync('highlight') @@ -33,6 +54,14 @@ nmap rn (coc-rename) xmap f (coc-format-selected) nmap f (coc-format-selected) +augroup mygroup + autocmd! + " Setup formatexpr specified filetype(s). + autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') + " Update signature help on jump placeholder + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') +augroup end + " Remap for do codeAction of selected region, ex: `aap` for current paragraph xmap a (coc-codeaction-selected) nmap a (coc-codeaction-selected) @@ -42,5 +71,39 @@ nmap ac (coc-codeaction) " Fix autofix problem of current line nmap qf (coc-fix-current) +" Create mappings for function text object, requires document symbols feature of languageserver. +xmap if (coc-funcobj-i) +xmap af (coc-funcobj-a) +omap if (coc-funcobj-i) +omap af (coc-funcobj-a) + +" Use for select selections ranges, needs server support, like: coc-tsserver, coc-python +nmap (coc-range-select) +xmap (coc-range-select) + " Use `:Format` to format current buffer command! -nargs=0 Format :call CocAction('format') + +" Use `:Fold` to fold current buffer +command! -nargs=? Fold :call CocAction('fold', ) + +" use `:OR` for organize import of current buffer +command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') + +" Using CocList +" Show all diagnostics +nnoremap a :CocList diagnostics +" Manage extensions +nnoremap e :CocList extensions +" Show commands +nnoremap c :CocList commands +" Find symbol of current document +nnoremap o :CocList outline +" Search workspace symbols +nnoremap s :CocList -I symbols +" Do default action for next item. +nnoremap j :CocNext +" Do default action for previous item. +nnoremap k :CocPrev +" Resume latest coc list +nnoremap p :CocListResume diff --git a/home/common/init.vim b/home/common/init.vim index 97ccd80..b573f11 100644 --- a/home/common/init.vim +++ b/home/common/init.vim @@ -8,11 +8,33 @@ let g:startify_bookmarks = [ \ '~/dev/fitnesspilot/microservices/coachtasks', \ '~/dev/fitnesspilot/microservices/notifications', \ '~/dev/fitnesspilot/microservices/googlefitimport', + \ '~/dev/fitnesspilot/microservices/devel', + \ '~/dev/fitnesspilot/common/APIModel', + \ '~/dev/fitnesspilot/common/CommonModel', + \ '~/dev/fitnesspilot/common/CommonDomain', + \ '~/dev/fitnesspilot/common/CosmosDBStore', + \ '~/dev/fitnesspilot/common/IntegrationTestBase', + \ '~/dev/fitnesspilot/common/MicroserviceUtils', + \ '~/dev/fitnesspilot/common/Utils', + \ '~/dev/fitnesspilot/common/FitnesspilotMathCore', + \ '/etc/nixos', \ ] let mapleader=" " let g:camelcasemotion_key = '' +let g:lightline = { + \ 'colorscheme': 'powerline', + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'cocstatus', 'currentfunction', 'readonly', 'filename', 'modified' ] ] + \ }, + \ 'component_function': { + \ 'cocstatus': 'coc#status', + \ 'currentfunction': 'CocCurrentFunction' + \ }, + \ } + " omnisharp-vim config: let g:OmniSharp_start_without_solution = 1 let g:OmniSharp_server_stdio = 1