summaryrefslogtreecommitdiff
path: root/nvim
diff options
context:
space:
mode:
authorShubham Saini <pryr@pryr.xyz>2020-08-24 15:20:10 +0000
committerShubham Saini <pryr@pryr.xyz>2020-08-24 15:20:10 +0000
commit64f779a7f645dda8f5f6e0b807250abec9eaa768 (patch)
tree2038e95e79849694951ce17e6c0b37e968dbf674 /nvim
parent84f973c475822e1f8438d7c6ad42ae67674195b1 (diff)
deoplete to coc
Diffstat (limited to 'nvim')
-rw-r--r--nvim/.config/nvim/init.vim160
1 files changed, 142 insertions, 18 deletions
diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim
index 32bf76c..fc61186 100644
--- a/nvim/.config/nvim/init.vim
+++ b/nvim/.config/nvim/init.vim
@@ -1,8 +1,6 @@
1" vimplug 1" vimplug
2call plug#begin() 2call plug#begin()
3Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } 3Plug 'neoclide/coc.nvim', {'branch': 'release'}
4Plug 'Shougo/deoplete-clangx'
5Plug 'deoplete-plugins/deoplete-jedi'
6Plug 'Shougo/deol.nvim' 4Plug 'Shougo/deol.nvim'
7Plug 'ap/vim-css-color' 5Plug 'ap/vim-css-color'
8Plug 'tpope/vim-eunuch' 6Plug 'tpope/vim-eunuch'
@@ -38,22 +36,44 @@ colorscheme pencil
38"hi Normal ctermbg=16 guibg=#000000 36"hi Normal ctermbg=16 guibg=#000000
39"hi LineNr ctermbg=16 guibg=#000000 37"hi LineNr ctermbg=16 guibg=#000000
40 38
39let mapleader=" "
40
41" Alias write and quit to Q
42nnoremap <leader>q :wq<CR>
43nnoremap <leader>w :w<CR>
44
45" Save file as sudo when no sudo permissions
46cmap w!! w !sudo tee > /dev/null %
47
41" vim-bujo 48" vim-bujo
42nmap <C-N> <Plug>BujoAddnormal 49nmap <C-N> <Plug>BujoAddnormal
43imap <C-N> <Plug>BujoAddinsert 50imap <C-N> <Plug>BujoAddinsert
44nmap <C-P> <Plug>BujoChecknormal 51nmap <C-P> <Plug>BujoChecknormal
45imap <C-P> <Plug>BujoCheckinsert 52imap <C-P> <Plug>BujoCheckinsert
46 53
47" deoplete 54" nerdtree
48let g:deoplete#enable_at_startup = 1 55let g:NERDTreeWinPos = "right"
56map <C-i> :NERDTreeToggle<CR>
57autocmd StdinReadPre * let s:std_in=1
58autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
59autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
60
61" system clipboard
62set clipboard+=unnamedplus
63
64" Fix indenting visual block
65vmap < <gv
66vmap > >gv
49 67
50" git gutter settings 68" git gutter settings
51let g:gitgutter_override_sign_column_highlight = 0 69highlight GitGutterAdd guifg=#009900 ctermfg=Green
52let g:gitgutter_sign_added = '+' 70highlight GitGutterChange guifg=#bbbb00 ctermfg=Yellow
53let g:gitgutter_sign_modified = '±' 71highlight GitGutterDelete guifg=#ff2222 ctermfg=Red
54let g:gitgutter_sign_removed = '-' 72nmap ) <Plug>(GitGutterNextHunk)
55let g:gitgutter_sign_removed_first_line = '^' 73nmap ( <Plug>(GitGutterPrevHunk)
56let g:gitgutter_sign_modified_removed = '#' 74let g:gitgutter_enabled = 1
75let g:gitgutter_map_keys = 0
76let g:gitgutter_highlight_linenrs = 1
57 77
58" vim-markdown 78" vim-markdown
59let g:vim_markdown_no_default_key_mappings=1 79let g:vim_markdown_no_default_key_mappings=1
@@ -62,13 +82,6 @@ let g:vim_markdown_yaml_frontmatter=1
62let g:vim_markdown_folding_disabled=1 82let g:vim_markdown_folding_disabled=1
63let g:vim_markdown_conceal=0 83let g:vim_markdown_conceal=0
64 84
65" nerdtree
66let g:NERDTreeWinPos = "right"
67map <C-i> :NERDTreeToggle<CR>
68autocmd StdinReadPre * let s:std_in=1
69autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
70autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
71
72" insert centered 85" insert centered
73autocmd InsertEnter * norm zz 86autocmd InsertEnter * norm zz
74 87
@@ -129,3 +142,114 @@ set statusline+=%#PrimaryBlock#
129set statusline+=\ %Y\ 142set statusline+=\ %Y\
130set statusline+=%#SecondaryBlock# 143set statusline+=%#SecondaryBlock#
131set statusline+=\ %P\ 144set statusline+=\ %P\
145
146" ------COC SETTINGS------
147" prettier command for coc
148command! -nargs=0 Prettier :CocCommand prettier.formatFile
149let g:coc_global_extensions = [
150 \ 'coc-snippets',
151 \ 'coc-pairs',
152 \ 'coc-prettier',
153 \ 'coc-tsserver',
154 \ 'coc-html',
155 \ 'coc-css',
156 \ 'coc-json',
157 \ 'coc-clangd',
158 \ 'coc-python',
159 \ 'coc-vimtex'
160 \ ]
161
162" From Coc Readme
163set updatetime=300
164
165" Some servers have issues with backup files, see #649
166set nobackup
167set nowritebackup
168
169" don't give |ins-completion-menu| messages.
170set shortmess+=c
171
172" always show signcolumns
173set signcolumn=yes
174
175" Use tab for trigger completion with characters ahead and navigate.
176" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
177inoremap <silent><expr> <TAB>
178 \ pumvisible() ? "\<C-n>" :
179 \ <SID>check_back_space() ? "\<TAB>" :
180 \ coc#refresh()
181inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
182
183function! s:check_back_space() abort
184 let col = col('.') - 1
185 return !col || getline('.')[col - 1] =~# '\s'
186endfunction
187
188" Use <c-space> to trigger completion.
189inoremap <silent><expr> <c-space> coc#refresh()
190
191" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
192" Coc only does snippet and additional edit on confirm.
193inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
194" Or use `complete_info` if your vim support it, like:
195" inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
196
197" Use `[g` and `]g` to navigate diagnostics
198nmap <silent> [g <Plug>(coc-diagnostic-prev)
199nmap <silent> ]g <Plug>(coc-diagnostic-next)
200
201" Remap keys for gotos
202nmap <silent> gd <Plug>(coc-definition)
203nmap <silent> gy <Plug>(coc-type-definition)
204nmap <silent> gi <Plug>(coc-implementation)
205nmap <silent> gr <Plug>(coc-references)
206
207function! s:show_documentation()
208 if (index(['vim','help'], &filetype) >= 0)
209 execute 'h '.expand('<cword>')
210 else
211 call CocAction('doHover')
212 endif
213endfunction
214
215" Remap for rename current word
216nmap <rn> <Plug>(coc-rename)
217
218" Remap for format selected region
219xmap <leader>f <Plug>(coc-format-selected)
220nmap <leader>f <Plug>(coc-format-selected)
221
222augroup mygroup
223 autocmd!
224 " Setup formatexpr specified filetype(s).
225 autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
226 " Update signature help on jump placeholder
227 autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
228augroup end
229
230" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
231xmap <leader>a <Plug>(coc-codeaction-selected)
232nmap <leader>a <Plug>(coc-codeaction-selected)
233
234" Remap for do codeAction of current line
235nmap <leader>ac <Plug>(coc-codeaction)
236" Fix autofix problem of current line
237nmap <leader>qf <Plug>(coc-fix-current)
238
239" Create mappings for function text object, requires document symbols feature of languageserver.
240xmap if <Plug>(coc-funcobj-i)
241xmap af <Plug>(coc-funcobj-a)
242omap if <Plug>(coc-funcobj-i)
243omap af <Plug>(coc-funcobj-a)
244
245" Use `:Format` to format current buffer
246command! -nargs=0 Format :call CocAction('format')
247
248" Use `:Fold` to fold current buffer
249command! -nargs=? Fold :call CocAction('fold', <f-args>)
250
251" use `:OR` for organize import of current buffer
252command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
253
254" Add status line support, for integration with other plugin, checkout `:h coc-status`
255set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}