diff options
-rwxr-xr-x | nvim/.config/nvim/init.vim | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim index 486385d..8978c2d 100755 --- a/nvim/.config/nvim/init.vim +++ b/nvim/.config/nvim/init.vim | |||
@@ -1,5 +1,6 @@ | |||
1 | " vimplug | 1 | " vimplug |
2 | call plug#begin() | 2 | call plug#begin() |
3 | Plug 'neoclide/coc.nvim', {'branch': 'release'} | ||
3 | Plug 'Shougo/deol.nvim' | 4 | Plug 'Shougo/deol.nvim' |
4 | Plug 'ap/vim-css-color' | 5 | Plug 'ap/vim-css-color' |
5 | Plug 'tpope/vim-eunuch' | 6 | Plug 'tpope/vim-eunuch' |
@@ -148,3 +149,115 @@ set statusline+=%#PrimaryBlock# | |||
148 | set statusline+=\ %Y\ | 149 | set statusline+=\ %Y\ |
149 | set statusline+=%#SecondaryBlock# | 150 | set statusline+=%#SecondaryBlock# |
150 | set statusline+=\ %P\ | 151 | set statusline+=\ %P\ |
152 | |||
153 | " ------COC SETTINGS------ | ||
154 | " prettier command for coc | ||
155 | command! -nargs=0 Prettier :CocCommand prettier.formatFile | ||
156 | let g:coc_global_extensions = [ | ||
157 | \ 'coc-snippets', | ||
158 | \ 'coc-pairs', | ||
159 | \ 'coc-prettier', | ||
160 | \ 'coc-tsserver', | ||
161 | \ 'coc-html', | ||
162 | \ 'coc-css', | ||
163 | \ 'coc-json', | ||
164 | \ 'coc-clangd', | ||
165 | \ 'coc-python', | ||
166 | \ 'coc-sh', | ||
167 | \ 'coc-vimtex' | ||
168 | \ ] | ||
169 | |||
170 | " From Coc Readme | ||
171 | set updatetime=300 | ||
172 | |||
173 | " Some servers have issues with backup files, see #649 | ||
174 | set nobackup | ||
175 | set nowritebackup | ||
176 | |||
177 | " don't give |ins-completion-menu| messages. | ||
178 | set shortmess+=c | ||
179 | |||
180 | " always show signcolumns | ||
181 | set signcolumn=yes | ||
182 | |||
183 | " Use tab for trigger completion with characters ahead and navigate. | ||
184 | " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin. | ||
185 | inoremap <silent><expr> <TAB> | ||
186 | \ pumvisible() ? "\<C-n>" : | ||
187 | \ <SID>check_back_space() ? "\<TAB>" : | ||
188 | \ coc#refresh() | ||
189 | inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | ||
190 | |||
191 | function! s:check_back_space() abort | ||
192 | let col = col('.') - 1 | ||
193 | return !col || getline('.')[col - 1] =~# '\s' | ||
194 | endfunction | ||
195 | |||
196 | " Use <c-space> to trigger completion. | ||
197 | inoremap <silent><expr> <c-space> coc#refresh() | ||
198 | |||
199 | " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position. | ||
200 | " Coc only does snippet and additional edit on confirm. | ||
201 | inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | ||
202 | " Or use `complete_info` if your vim support it, like: | ||
203 | " inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>" | ||
204 | |||
205 | " Use `[g` and `]g` to navigate diagnostics | ||
206 | nmap <silent> [g <Plug>(coc-diagnostic-prev) | ||
207 | nmap <silent> ]g <Plug>(coc-diagnostic-next) | ||
208 | |||
209 | " Remap keys for gotos | ||
210 | nmap <silent> gd <Plug>(coc-definition) | ||
211 | nmap <silent> gy <Plug>(coc-type-definition) | ||
212 | nmap <silent> gi <Plug>(coc-implementation) | ||
213 | nmap <silent> gr <Plug>(coc-references) | ||
214 | |||
215 | function! s:show_documentation() | ||
216 | if (index(['vim','help'], &filetype) >= 0) | ||
217 | execute 'h '.expand('<cword>') | ||
218 | else | ||
219 | call CocAction('doHover') | ||
220 | endif | ||
221 | endfunction | ||
222 | |||
223 | " Remap for rename current word | ||
224 | nmap <rn> <Plug>(coc-rename) | ||
225 | |||
226 | " Remap for format selected region | ||
227 | xmap <leader>f <Plug>(coc-format-selected) | ||
228 | nmap <leader>f <Plug>(coc-format-selected) | ||
229 | |||
230 | augroup mygroup | ||
231 | autocmd! | ||
232 | " Setup formatexpr specified filetype(s). | ||
233 | autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') | ||
234 | " Update signature help on jump placeholder | ||
235 | autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') | ||
236 | augroup end | ||
237 | |||
238 | " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph | ||
239 | xmap <leader>a <Plug>(coc-codeaction-selected) | ||
240 | nmap <leader>a <Plug>(coc-codeaction-selected) | ||
241 | |||
242 | " Remap for do codeAction of current line | ||
243 | nmap <leader>ac <Plug>(coc-codeaction) | ||
244 | " Fix autofix problem of current line | ||
245 | nmap <leader>qf <Plug>(coc-fix-current) | ||
246 | |||
247 | " Create mappings for function text object, requires document symbols feature of languageserver. | ||
248 | xmap if <Plug>(coc-funcobj-i) | ||
249 | xmap af <Plug>(coc-funcobj-a) | ||
250 | omap if <Plug>(coc-funcobj-i) | ||
251 | omap af <Plug>(coc-funcobj-a) | ||
252 | |||
253 | " Use `:Format` to format current buffer | ||
254 | command! -nargs=0 Format :call CocAction('format') | ||
255 | |||
256 | " Use `:Fold` to fold current buffer | ||
257 | command! -nargs=? Fold :call CocAction('fold', <f-args>) | ||
258 | |||
259 | " use `:OR` for organize import of current buffer | ||
260 | command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') | ||
261 | |||
262 | " Add status line support, for integration with other plugin, checkout `:h coc-status` | ||
263 | set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} | ||