-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
361 lines (290 loc) · 11.1 KB
/
init.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
let PYTHON2_HOST_VERSION = "2.7.15"
let PYTHON3_HOST_VERSION = "3.7.7"
" ============================================================================
" Vim-plug initialization
" Avoid modify this section, unless you are very sure of what you are doing
let vim_plug_just_installed = 0
let vim_plug_path = expand('~/.config/nvim/autoload/plug.vim')
if !filereadable(vim_plug_path)
echo "Installing Vim-plug..."
echo ""
silent !mkdir -p ~/.config/nvim/autoload
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
let vim_plug_just_installed = 1
endif
" manually load vim-plug the first time
if vim_plug_just_installed
:execute 'source '.fnameescape(vim_plug_path)
endif
" Obscure hacks done, you can now modify the rest of the .vimrc as you wish :)
" ============================================================================
call plug#begin('~/.config/nvim/plugged')
" Common
Plug 'terryma/vim-multiple-cursors'
Plug 'ctrlpvim/ctrlp.vim' " CtrlP is installed to support tag finding in vim-go
Plug 'w0rp/ale'
Plug 'tpope/vim-surround'
Plug 'junegunn/vim-easy-align'
Plug 'scrooloose/nerdtree'
Plug 'scrooloose/nerdcommenter'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'bling/vim-airline'
Plug 'jeffkreeftmeijer/vim-numbertoggle'
Plug 'sheerun/vim-polyglot'
Plug 'tpope/vim-fugitive'
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/neosnippet-snippets'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'vimwiki/vimwiki'
" Language support
Plug 'lifepillar/pgsql.vim' " PostgreSQL syntax highlighting
Plug 'sebdah/vim-delve' " Golang debugger
Plug 'davidhalter/jedi-vim', { 'for': 'python' } " Python goto etc
Plug 'tmhedberg/SimpylFold' " Python folding
Plug 'iamcco/markdown-preview.vim' " Markdown live preview in browser
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Colorschemes
Plug 'NLKNguyen/papercolor-theme'
call plug#end()
" Testing Configurations
let g:vimwiki_list = [{'path': '~/.config/nvim/wiki/', 'path_html': '~/.config/nvim/wikihtml/', 'ext': 'md'}]
"
" -------------------------------------------------------------------------
" ---- GENERAL
" -------------------------------------------------------------------------
set shell=/bin/bash
set encoding=UTF-8
let g:python3_host_prog = $HOME . '/.pyenv/versions/' . PYTHON3_HOST_VERSION . '/envs/neovim3/bin/python'
let g:python_host_prog = $HOME . '/.pyenv/versions/' . PYTHON2_HOST_VERSION . '/envs/neovim2/bin/python'
let mapleader = ','
set autoindent " take indent for new line from previous line
set autoread " reload file if the file changes on the disk
set autowrite " write when switching buffers
set autowriteall " write on :quit
set completeopt-=preview " remove the horrendous preview window
set cursorline " highlight the current line for the cursor
set noerrorbells " No bells!
set noswapfile " disable swapfile usage
set novisualbell " I said, no bells!
set smartindent " enable smart indentation
set number "Display line numbers
set ruler "Display cursor position
set ignorecase
" Colorscheme
set background=dark
colorscheme PaperColor
" Font settings
set guifont=Monaco:h13
" Autosave buffers before leaving them
autocmd BufLeave * silent! :wa
" Remove trailing white spaces on save
autocmd BufWritePre * :%s/\s\+$//e
set title
" Enable mouse if possible
if has('mouse')
set mouse=a
endif
" Allow vim to set a custom font or color for a word
syntax enable
" Common indentation settings
set noexpandtab
set shiftwidth=4
set tabstop=4
noremap <leader>t :NERDTreeToggle<CR>
" Javascript
autocmd FileType javascript set tabstop=2 shiftwidth=2 softtabstop=2 expandtab
" Golang
au FileType go set noexpandtab
au FileType go set shiftwidth=4
au FileType go set softtabstop=4
au FileType go set tabstop=4
au FileType go nmap <leader>gt :GoDeclsDir<cr>
au FileType go nmap <leader>gd <Plug>(go-def)
" Yaml
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=indent
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" Disable deoplete when in multi cursor mode
let g:deoplete#enable_at_startup = 1
function! Multiple_cursors_before()
let b:deoplete_disable_auto_complete = 1
endfunction
function! Multiple_cursors_after()
let b:deoplete_disable_auto_complete = 0
endfunction
let g:go_highlight_build_constraints = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_operators = 1
let g:go_highlight_structs = 1
let g:go_highlight_types = 1
let g:go_auto_sameids = 1
let g:go_auto_type_info = 1
let g:go_fmt_command = "goimports"
let g:go_addtags_transform = "snakecase"
" Jedi-vim ------------------------------
" Disable autocompletion (using deoplete instead)
let g:jedi#completions_enabled = 0
" All these mappings work only for python code:
" Go to definition
let g:jedi#goto_command = ',d'
" Find ocurrences
let g:jedi#usages_command = ',o'
" Find assignments
let g:jedi#goto_assignments_command = ',a'
" Go to definition in new tab
nmap ,D :tab split<CR>:call jedi#goto()<CR>
" Error and warning signs.
let g:ale_sign_error = '⤫'
let g:ale_sign_warning = '⚠'
" Enable integration with airline.
let g:airline#extensions#ale#enabled = 1
" Fix some common typos
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall
"----------------------------------------------
" Splits
"----------------------------------------------
" Create horizontal splits below the current window
set splitbelow
set splitright
" Creating splits
nnoremap <leader>v :vsplit<cr>
nnoremap <leader>h :split<cr>
" Closing splits
nnoremap <leader>q :close<cr>
"----------------------------------------------
" Plugin: 'ctrlpvim/ctrlp.vim'
"----------------------------------------------
" Note: We are not using CtrlP much in this configuration. But vim-go depend on
" it to run GoDecls(Dir).
" Disable the CtrlP mapping, since we want to use FZF instead for <c-p>.
let g:ctrlp_map = ''
"----------------------------------------------
" Plugin: 'scrooloose/nerdtree'
"----------------------------------------------
" Note: We are not using CtrlP much in this configuration. But vim-go depend on
" it to run GoDecls(Dir).
" Disable the CtrlP mapping, since we want to use FZF instead for <c-p>.
let g:NERDTreeShowHidden = 1
let g:NERDTreeIgnore = ['\.pyc$', '^__pycache__$', 'egg-info$']
"----------------------------------------------
" Plugin: 'junegunn/fzf.vim'
"----------------------------------------------
nnoremap <c-p> :FZF<cr>
"----------------------------------------------
" Plugin: 'w0rp/ale'
"----------------------------------------------
let g:ale_python_flake8_options = '--max-line-length=100'
let g:ale_python_pylint_options = '--max-line-length=100 --no-docstring-rgx=test'
let g:ale_linters = {
\ 'javascript': ['eslint'],
\ 'python': ['flake8']
\}
let g:ale_pattern_options = {'\.go$': {'ale_enabled': 0}}
"----------------------------------------------
" Plugin: 'sheerun/vim-polyglot'
"----------------------------------------------
let g:polyglot_disabled = ['md', 'markdown']
"----------------------------------------------
" Plugin: 'tmhedberg/SimpylFold'
"----------------------------------------------
let g:SimpylFold_docstring_preview = 0
let g:SimpylFold_fold_docstring = 1
let b:SimpylFold_fold_docstring = 1
let g:SimpylFold_fold_import = 0
let b:SimpylFold_fold_import = 0
"----------------------------------------------
" Plugin: 'Shougo/neosnippet'
"----------------------------------------------
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
"imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
" -------------------------------------------------------------------------------------------------
" coc.nvim default settings
" -------------------------------------------------------------------------------------------------
" if hidden is not set, TextEdit might fail.
set hidden
" Better display for messages
set cmdheight=2
" Smaller updatetime for CursorHold & CursorHoldI
set updatetime=300
" don't give |ins-completion-menu| messages.
set shortmess+=c
" always show signcolumns
set signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use `[c` and `]c` to navigate diagnostics
nmap <silent> [c <Plug>(coc-diagnostic-prev)
nmap <silent> ]c <Plug>(coc-diagnostic-next)
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use U to show documentation in preview window
nnoremap <silent> U :call <SID>show_documentation()<CR>
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Remap for format selected region
vmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
" Show all diagnostics
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions
nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
" Show commands
nnoremap <silent> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction('format')
autocmd BufWritePre *.go :call CocAction('runCommand', 'editor.action.organizeImport')
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
set nobackup
set nowritebackup