|
1 | 1 | " --------------- |
2 | | -" Airline |
| 2 | +" coc.nvim |
3 | 3 | " --------------- |
4 | | -let g:airline_powerline_fonts=1 |
| 4 | +let g:coc_global_extensions = [ |
| 5 | + \ 'coc-diagnostic', |
| 6 | + \ 'coc-marketplace', |
| 7 | + \ 'coc-pairs', |
| 8 | + \ 'coc-snippets', |
| 9 | + \ 'coc-vimlsp', |
| 10 | + \ ] |
| 11 | + |
| 12 | +" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable |
| 13 | +" delays and poor user experience. |
| 14 | +set updatetime=300 |
| 15 | + |
| 16 | +" Don't pass messages to |ins-completion-menu|. |
| 17 | +set shortmess+=c |
| 18 | + |
| 19 | +" Always show the signcolumn, otherwise it would shift the text each time |
| 20 | +" diagnostics appear/become resolved. |
| 21 | +set signcolumn=yes |
| 22 | + |
| 23 | +" Use tab for trigger completion with characters ahead and navigate. |
| 24 | +" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by |
| 25 | +" other plugin before putting this into your config. |
| 26 | +inoremap <silent><expr> <TAB> |
| 27 | + \ pumvisible() ? "\<C-n>" : |
| 28 | + \ <SID>check_back_space() ? "\<TAB>" : |
| 29 | + \ coc#refresh() |
| 30 | +inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" |
| 31 | +
|
| 32 | +function! s:check_back_space() abort |
| 33 | + let col = col('.') - 1 |
| 34 | + return !col || getline('.')[col - 1] =~# '\s' |
| 35 | +endfunction |
| 36 | + |
| 37 | +" Use <c-space> to trigger completion. |
| 38 | +inoremap <silent><expr> <c-space> coc#refresh() |
| 39 | +
|
| 40 | +" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current |
| 41 | +" position. Coc only does snippet and additional edit on confirm. |
| 42 | +if exists('*complete_info') |
| 43 | + inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>" |
| 44 | +else |
| 45 | + imap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" |
| 46 | +endif |
| 47 | + |
| 48 | +" Use `[g` and `]g` to navigate diagnostics |
| 49 | +nmap <silent> [g <Plug>(coc-diagnostic-prev) |
| 50 | +nmap <silent> ]g <Plug>(coc-diagnostic-next) |
| 51 | +nmap <silent> <leader><s-space> <Plug>(coc-diagnostic-prev) |
| 52 | +nmap <silent> <leader><space> <Plug>(coc-diagnostic-next) |
| 53 | +
|
| 54 | +" GoTo code navigation. |
| 55 | +nmap <silent> gd <Plug>(coc-definition) |
| 56 | +nmap <silent> gy <Plug>(coc-type-definition) |
| 57 | +nmap <silent> gi <Plug>(coc-implementation) |
| 58 | +nmap <silent> gr <Plug>(coc-references) |
| 59 | +
|
| 60 | +" Use K to show documentation in preview window. |
| 61 | +nnoremap <silent> K :call <SID>show_documentation()<CR> |
| 62 | +
|
| 63 | +function! s:show_documentation() |
| 64 | +if (index(['vim','help'], &filetype) >= 0) |
| 65 | + execute 'h '.expand('<cword>') |
| 66 | + else |
| 67 | + call CocAction('doHover') |
| 68 | + endif |
| 69 | +endfunction |
| 70 | + |
| 71 | +" Highlight the symbol and its references when holding the cursor. |
| 72 | +autocmd CursorHold * silent call CocActionAsync('highlight') |
| 73 | + |
| 74 | +" Symbol renaming. |
| 75 | +nmap <leader>rn <Plug>(coc-rename) |
| 76 | +
|
| 77 | +" Formatting selected code. |
| 78 | +xmap <leader>f <Plug>(coc-format-selected) |
| 79 | +" nmap <leader>f <Plug>(coc-format-selected) |
| 80 | + |
| 81 | +augroup mygroup |
| 82 | + autocmd! |
| 83 | + " Setup formatexpr specified filetype(s). |
| 84 | + autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') |
| 85 | + " Update signature help on jump placeholder. |
| 86 | + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') |
| 87 | +augroup end |
| 88 | + |
| 89 | +" Applying codeAction to the selected region. |
| 90 | +" Example: `<leader>aap` for current paragraph |
| 91 | +xmap <leader>a <Plug>(coc-codeaction-selected) |
| 92 | +nmap <leader>a <Plug>(coc-codeaction-selected) |
| 93 | +
|
| 94 | +" Remap keys for applying codeAction to the current line. |
| 95 | +nmap <leader>ac <Plug>(coc-codeaction) |
| 96 | +" Apply AutoFix to problem on the current line. |
| 97 | +nmap <leader>qf <Plug>(coc-fix-current) |
| 98 | +
|
| 99 | +" Introduce function text object |
| 100 | +" NOTE: Requires 'textDocument.documentSymbol' support from the language server. |
| 101 | +xmap if <Plug>(coc-funcobj-i) |
| 102 | +xmap af <Plug>(coc-funcobj-a) |
| 103 | +omap if <Plug>(coc-funcobj-i) |
| 104 | +omap af <Plug>(coc-funcobj-a) |
| 105 | +
|
| 106 | +" Use <TAB> for selections ranges. |
| 107 | +" NOTE: Requires 'textDocument/selectionRange' support from the language server. |
| 108 | +" coc-tsserver, coc-python are the examples of servers that support it. |
| 109 | +nmap <silent> <TAB> <Plug>(coc-range-select) |
| 110 | +xmap <silent> <TAB> <Plug>(coc-range-select) |
| 111 | +
|
| 112 | +" Add `:Format` command to format current buffer. |
| 113 | +command! -nargs=0 Format :call CocAction('format') |
| 114 | + |
| 115 | +" Add `:Fold` command to fold current buffer. |
| 116 | +command! -nargs=? Fold :call CocAction('fold', <f-args>) |
| 117 | + |
| 118 | +" Add `:OR` command for organize imports of the current buffer. |
| 119 | +command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') |
| 120 | + |
| 121 | +" Add (Neo)Vim's native statusline support. |
| 122 | +" NOTE: Please see `:h coc-status` for integrations with external plugins that |
| 123 | +" provide custom statusline: lightline.vim, vim-airline. |
| 124 | +set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} |
| 125 | + |
| 126 | +" Mappings using CoCList: |
| 127 | +" Show all diagnostics. |
| 128 | +nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr> |
| 129 | +" Manage extensions. |
| 130 | +nnoremap <silent> <space>e :<C-u>CocList extensions<cr> |
| 131 | +" Show commands. |
| 132 | +nnoremap <silent> <space>c :<C-u>CocList commands<cr> |
| 133 | +" Find symbol of current document. |
| 134 | +nnoremap <silent> <space>o :<C-u>CocList outline<cr> |
| 135 | +" Search workspace symbols. |
| 136 | +nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr> |
| 137 | +" Do default action for next item. |
| 138 | +nnoremap <silent> <space>j :<C-u>CocNext<CR> |
| 139 | +" Do default action for previous item. |
| 140 | +nnoremap <silent> <space>k :<C-u>CocPrev<CR> |
| 141 | +" Resume latest coc list. |
| 142 | +nnoremap <silent> <space>p :<C-u>CocListResume<CR> |
5 | 143 |
|
6 | 144 | " --------------- |
7 | | -" bclose |
| 145 | +" Airline |
8 | 146 | " --------------- |
9 | | -cmap bd Bclose |
| 147 | +let g:airline_powerline_fonts=1 |
10 | 148 |
|
11 | 149 | " --------------- |
12 | 150 | " CtrlP |
@@ -49,65 +187,6 @@ endif |
49 | 187 |
|
50 | 188 | nnoremap ,u :GundoToggle<CR> |
51 | 189 |
|
52 | | -" --------------- |
53 | | -" syntastic |
54 | | -" --------------- |
55 | | -let g:syntastic_javascript_checkers = ['jshint'] |
56 | | -let g:syntastic_enable_signs=1 |
57 | | -"let g:syntastic_quiet_messages = {'level': 'warnings'} |
58 | | -let g:syntastic_auto_loc_list=2 |
59 | | - |
60 | | -" --------------- |
61 | | -" neocomplcache |
62 | | -" --------------- |
63 | | -let g:neocomplcache_enable_at_startup = 1 |
64 | | -let g:neocomplcache_enable_camel_case_completion = 1 |
65 | | -let g:neocomplcache_enable_underbar_completion = 0 |
66 | | -let g:neocomplcache_enable_fuzzy_completion = 1 |
67 | | -let g:neocomplcache_enable_fuzzy_completion_start_length = 2 |
68 | | -let g:neocomplcache_enable_smart_case = 1 |
69 | | -let g:neocomplcache_force_overwrite_completefunc = 1 |
70 | | -let g:neocomplcache_max_list = 20 |
71 | | -"let g:neocomplcache_disable_auto_complete = 1 |
72 | | -let g:neocomplcache_min_syntax_length = 3 |
73 | | -let g:neocomplcache_auto_completion_start_length = 2 |
74 | | -let g:neocomplcache_manual_completion_start_length = 0 |
75 | | -let g:neocomplcache_enable_auto_delimiter = 1 |
76 | | - |
77 | | -" Define keyword. |
78 | | -if !exists('g:neocomplcache_keyword_patterns') |
79 | | - let g:neocomplcache_keyword_patterns = {} |
80 | | -endif |
81 | | -let g:neocomplcache_keyword_patterns['default'] = '\h\w*' |
82 | | - |
83 | | -"let g:neocomplcache_snippets_dir = $HOME . '/bundle/vim-snippets' |
84 | | - |
85 | | -" ruby omni completion fix |
86 | | -" http://osdir.com/ml/editors.vim.vim-ruby.devel/2007-02/msg00008.html |
87 | | -if has("ruby") |
88 | | - silent! ruby nil |
89 | | -endif |
90 | | -" Enable omni completion. |
91 | | -autocmd FileType css,less setlocal omnifunc=csscomplete#CompleteCSS |
92 | | -autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags |
93 | | -autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS |
94 | | -autocmd FileType python setlocal omnifunc=pythoncomplete#Complete |
95 | | -autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags |
96 | | -autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete |
97 | | -" Enable heavy omni completion. |
98 | | -if !exists('g:neocomplcache_omni_patterns') |
99 | | - let g:neocomplcache_omni_patterns = {} |
100 | | -endif |
101 | | -let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::' |
102 | | -let g:neocomplcache_omni_patterns.go = '\h\w*\%.' |
103 | | -let g:neocomplcache_omni_patterns.less = '^\s\+\w\+\|\w\+[):;]\?\s\+\w*\|[@!]' |
104 | | - |
105 | | -" neocomplcache activation |
106 | | -inoremap <expr> <c-space> pumvisible() ? "\<C-n>" : "\<C-x>\<C-u>" |
107 | | -inoremap <expr><c-CR> neocomplcache#smart_close_popup() . "\<CR>" |
108 | | -inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>" |
109 | | -inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>" |
110 | | -
|
111 | 190 | "--------------- |
112 | 191 | " Surround |
113 | 192 | "--------------- |
@@ -142,12 +221,6 @@ map <leader>{ ysiw{ |
142 | 221 | vmap <leader>} c{ <C-R>" }<ESC> |
143 | 222 | vmap <leader>{ c{<C-R>"}<ESC> |
144 | 223 |
|
145 | | - |
146 | | -"--------------- |
147 | | -" delimitMate |
148 | | -"--------------- |
149 | | -let delimitMate_expand_cr = 1 |
150 | | - |
151 | 224 | "--------------- |
152 | 225 | " ACK |
153 | 226 | "--------------- |
|
0 commit comments