summaryrefslogtreecommitdiff
path: root/nvim
diff options
context:
space:
mode:
Diffstat (limited to 'nvim')
-rwxr-xr-xnvim/.config/nvim/init.vim113
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
2call plug#begin() 2call plug#begin()
3Plug 'neoclide/coc.nvim', {'branch': 'release'}
3Plug 'Shougo/deol.nvim' 4Plug 'Shougo/deol.nvim'
4Plug 'ap/vim-css-color' 5Plug 'ap/vim-css-color'
5Plug 'tpope/vim-eunuch' 6Plug 'tpope/vim-eunuch'
@@ -148,3 +149,115 @@ set statusline+=%#PrimaryBlock#
148set statusline+=\ %Y\ 149set statusline+=\ %Y\
149set statusline+=%#SecondaryBlock# 150set statusline+=%#SecondaryBlock#
150set statusline+=\ %P\ 151set statusline+=\ %P\
152
153" ------COC SETTINGS------
154" prettier command for coc
155command! -nargs=0 Prettier :CocCommand prettier.formatFile
156let 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
171set updatetime=300
172
173" Some servers have issues with backup files, see #649
174set nobackup
175set nowritebackup
176
177" don't give |ins-completion-menu| messages.
178set shortmess+=c
179
180" always show signcolumns
181set 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.
185inoremap <silent><expr> <TAB>
186 \ pumvisible() ? "\<C-n>" :
187 \ <SID>check_back_space() ? "\<TAB>" :
188 \ coc#refresh()
189inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
190
191function! s:check_back_space() abort
192 let col = col('.') - 1
193 return !col || getline('.')[col - 1] =~# '\s'
194endfunction
195
196" Use <c-space> to trigger completion.
197inoremap <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.
201inoremap <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
206nmap <silent> [g <Plug>(coc-diagnostic-prev)
207nmap <silent> ]g <Plug>(coc-diagnostic-next)
208
209" Remap keys for gotos
210nmap <silent> gd <Plug>(coc-definition)
211nmap <silent> gy <Plug>(coc-type-definition)
212nmap <silent> gi <Plug>(coc-implementation)
213nmap <silent> gr <Plug>(coc-references)
214
215function! s:show_documentation()
216 if (index(['vim','help'], &filetype) >= 0)
217 execute 'h '.expand('<cword>')
218 else
219 call CocAction('doHover')
220 endif
221endfunction
222
223" Remap for rename current word
224nmap <rn> <Plug>(coc-rename)
225
226" Remap for format selected region
227xmap <leader>f <Plug>(coc-format-selected)
228nmap <leader>f <Plug>(coc-format-selected)
229
230augroup 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')
236augroup end
237
238" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
239xmap <leader>a <Plug>(coc-codeaction-selected)
240nmap <leader>a <Plug>(coc-codeaction-selected)
241
242" Remap for do codeAction of current line
243nmap <leader>ac <Plug>(coc-codeaction)
244" Fix autofix problem of current line
245nmap <leader>qf <Plug>(coc-fix-current)
246
247" Create mappings for function text object, requires document symbols feature of languageserver.
248xmap if <Plug>(coc-funcobj-i)
249xmap af <Plug>(coc-funcobj-a)
250omap if <Plug>(coc-funcobj-i)
251omap af <Plug>(coc-funcobj-a)
252
253" Use `:Format` to format current buffer
254command! -nargs=0 Format :call CocAction('format')
255
256" Use `:Fold` to fold current buffer
257command! -nargs=? Fold :call CocAction('fold', <f-args>)
258
259" use `:OR` for organize import of current buffer
260command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
261
262" Add status line support, for integration with other plugin, checkout `:h coc-status`
263set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}