diff options
author | Shubham Saini <pryr@pryr.xyz> | 2020-08-24 15:20:10 +0000 |
---|---|---|
committer | Shubham Saini <pryr@pryr.xyz> | 2020-08-24 15:20:10 +0000 |
commit | 64f779a7f645dda8f5f6e0b807250abec9eaa768 (patch) | |
tree | 2038e95e79849694951ce17e6c0b37e968dbf674 /nvim | |
parent | 84f973c475822e1f8438d7c6ad42ae67674195b1 (diff) |
deoplete to coc
Diffstat (limited to 'nvim')
-rw-r--r-- | nvim/.config/nvim/init.vim | 160 |
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 |
2 | call plug#begin() | 2 | call plug#begin() |
3 | Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } | 3 | Plug 'neoclide/coc.nvim', {'branch': 'release'} |
4 | Plug 'Shougo/deoplete-clangx' | ||
5 | Plug 'deoplete-plugins/deoplete-jedi' | ||
6 | Plug 'Shougo/deol.nvim' | 4 | Plug 'Shougo/deol.nvim' |
7 | Plug 'ap/vim-css-color' | 5 | Plug 'ap/vim-css-color' |
8 | Plug 'tpope/vim-eunuch' | 6 | Plug '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 | ||
39 | let mapleader=" " | ||
40 | |||
41 | " Alias write and quit to Q | ||
42 | nnoremap <leader>q :wq<CR> | ||
43 | nnoremap <leader>w :w<CR> | ||
44 | |||
45 | " Save file as sudo when no sudo permissions | ||
46 | cmap w!! w !sudo tee > /dev/null % | ||
47 | |||
41 | " vim-bujo | 48 | " vim-bujo |
42 | nmap <C-N> <Plug>BujoAddnormal | 49 | nmap <C-N> <Plug>BujoAddnormal |
43 | imap <C-N> <Plug>BujoAddinsert | 50 | imap <C-N> <Plug>BujoAddinsert |
44 | nmap <C-P> <Plug>BujoChecknormal | 51 | nmap <C-P> <Plug>BujoChecknormal |
45 | imap <C-P> <Plug>BujoCheckinsert | 52 | imap <C-P> <Plug>BujoCheckinsert |
46 | 53 | ||
47 | " deoplete | 54 | " nerdtree |
48 | let g:deoplete#enable_at_startup = 1 | 55 | let g:NERDTreeWinPos = "right" |
56 | map <C-i> :NERDTreeToggle<CR> | ||
57 | autocmd StdinReadPre * let s:std_in=1 | ||
58 | autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif | ||
59 | autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | ||
60 | |||
61 | " system clipboard | ||
62 | set clipboard+=unnamedplus | ||
63 | |||
64 | " Fix indenting visual block | ||
65 | vmap < <gv | ||
66 | vmap > >gv | ||
49 | 67 | ||
50 | " git gutter settings | 68 | " git gutter settings |
51 | let g:gitgutter_override_sign_column_highlight = 0 | 69 | highlight GitGutterAdd guifg=#009900 ctermfg=Green |
52 | let g:gitgutter_sign_added = '+' | 70 | highlight GitGutterChange guifg=#bbbb00 ctermfg=Yellow |
53 | let g:gitgutter_sign_modified = '±' | 71 | highlight GitGutterDelete guifg=#ff2222 ctermfg=Red |
54 | let g:gitgutter_sign_removed = '-' | 72 | nmap ) <Plug>(GitGutterNextHunk) |
55 | let g:gitgutter_sign_removed_first_line = '^' | 73 | nmap ( <Plug>(GitGutterPrevHunk) |
56 | let g:gitgutter_sign_modified_removed = '#' | 74 | let g:gitgutter_enabled = 1 |
75 | let g:gitgutter_map_keys = 0 | ||
76 | let g:gitgutter_highlight_linenrs = 1 | ||
57 | 77 | ||
58 | " vim-markdown | 78 | " vim-markdown |
59 | let g:vim_markdown_no_default_key_mappings=1 | 79 | let g:vim_markdown_no_default_key_mappings=1 |
@@ -62,13 +82,6 @@ let g:vim_markdown_yaml_frontmatter=1 | |||
62 | let g:vim_markdown_folding_disabled=1 | 82 | let g:vim_markdown_folding_disabled=1 |
63 | let g:vim_markdown_conceal=0 | 83 | let g:vim_markdown_conceal=0 |
64 | 84 | ||
65 | " nerdtree | ||
66 | let g:NERDTreeWinPos = "right" | ||
67 | map <C-i> :NERDTreeToggle<CR> | ||
68 | autocmd StdinReadPre * let s:std_in=1 | ||
69 | autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif | ||
70 | autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | ||
71 | |||
72 | " insert centered | 85 | " insert centered |
73 | autocmd InsertEnter * norm zz | 86 | autocmd InsertEnter * norm zz |
74 | 87 | ||
@@ -129,3 +142,114 @@ set statusline+=%#PrimaryBlock# | |||
129 | set statusline+=\ %Y\ | 142 | set statusline+=\ %Y\ |
130 | set statusline+=%#SecondaryBlock# | 143 | set statusline+=%#SecondaryBlock# |
131 | set statusline+=\ %P\ | 144 | set statusline+=\ %P\ |
145 | |||
146 | " ------COC SETTINGS------ | ||
147 | " prettier command for coc | ||
148 | command! -nargs=0 Prettier :CocCommand prettier.formatFile | ||
149 | let 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 | ||
163 | set updatetime=300 | ||
164 | |||
165 | " Some servers have issues with backup files, see #649 | ||
166 | set nobackup | ||
167 | set nowritebackup | ||
168 | |||
169 | " don't give |ins-completion-menu| messages. | ||
170 | set shortmess+=c | ||
171 | |||
172 | " always show signcolumns | ||
173 | set 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. | ||
177 | inoremap <silent><expr> <TAB> | ||
178 | \ pumvisible() ? "\<C-n>" : | ||
179 | \ <SID>check_back_space() ? "\<TAB>" : | ||
180 | \ coc#refresh() | ||
181 | inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | ||
182 | |||
183 | function! s:check_back_space() abort | ||
184 | let col = col('.') - 1 | ||
185 | return !col || getline('.')[col - 1] =~# '\s' | ||
186 | endfunction | ||
187 | |||
188 | " Use <c-space> to trigger completion. | ||
189 | inoremap <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. | ||
193 | inoremap <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 | ||
198 | nmap <silent> [g <Plug>(coc-diagnostic-prev) | ||
199 | nmap <silent> ]g <Plug>(coc-diagnostic-next) | ||
200 | |||
201 | " Remap keys for gotos | ||
202 | nmap <silent> gd <Plug>(coc-definition) | ||
203 | nmap <silent> gy <Plug>(coc-type-definition) | ||
204 | nmap <silent> gi <Plug>(coc-implementation) | ||
205 | nmap <silent> gr <Plug>(coc-references) | ||
206 | |||
207 | function! s:show_documentation() | ||
208 | if (index(['vim','help'], &filetype) >= 0) | ||
209 | execute 'h '.expand('<cword>') | ||
210 | else | ||
211 | call CocAction('doHover') | ||
212 | endif | ||
213 | endfunction | ||
214 | |||
215 | " Remap for rename current word | ||
216 | nmap <rn> <Plug>(coc-rename) | ||
217 | |||
218 | " Remap for format selected region | ||
219 | xmap <leader>f <Plug>(coc-format-selected) | ||
220 | nmap <leader>f <Plug>(coc-format-selected) | ||
221 | |||
222 | augroup 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') | ||
228 | augroup end | ||
229 | |||
230 | " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph | ||
231 | xmap <leader>a <Plug>(coc-codeaction-selected) | ||
232 | nmap <leader>a <Plug>(coc-codeaction-selected) | ||
233 | |||
234 | " Remap for do codeAction of current line | ||
235 | nmap <leader>ac <Plug>(coc-codeaction) | ||
236 | " Fix autofix problem of current line | ||
237 | nmap <leader>qf <Plug>(coc-fix-current) | ||
238 | |||
239 | " Create mappings for function text object, requires document symbols feature of languageserver. | ||
240 | xmap if <Plug>(coc-funcobj-i) | ||
241 | xmap af <Plug>(coc-funcobj-a) | ||
242 | omap if <Plug>(coc-funcobj-i) | ||
243 | omap af <Plug>(coc-funcobj-a) | ||
244 | |||
245 | " Use `:Format` to format current buffer | ||
246 | command! -nargs=0 Format :call CocAction('format') | ||
247 | |||
248 | " Use `:Fold` to fold current buffer | ||
249 | command! -nargs=? Fold :call CocAction('fold', <f-args>) | ||
250 | |||
251 | " use `:OR` for organize import of current buffer | ||
252 | command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') | ||
253 | |||
254 | " Add status line support, for integration with other plugin, checkout `:h coc-status` | ||
255 | set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} | ||