/
.vimrc
254 lines (183 loc) · 5.92 KB
/
.vimrc
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
" ####################### BEGIN PLUGIN MANAGEMENT
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
" auto close parenthesis, brackets, quotes, etc...
Plug 'jiangmiao/auto-pairs'
" show indentation in editor
Plug 'yggdroot/indentline'
" tree viewer
Plug 'scrooloose/nerdtree'
" nerdtree addon for git
Plug 'Xuyuanp/nerdtree-git-plugin'
" show changed lines in a file on a git repository
Plug 'airblade/vim-gitgutter'
" git integration
Plug 'tpope/vim-fugitive'
" git conflict solver
Plug 'christoomey/vim-conflicted'
" file finder (requires fzf installed)
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
" status line
Plug 'itchyny/lightline.vim'
" multiple cursor
Plug 'terryma/vim-multiple-cursors'
" surrounding
Plug 'tpope/vim-surround'
" tmux navigation plugin
Plug 'christoomey/vim-tmux-navigator'
" polyglot
Plug 'sheerun/vim-polyglot'
" markdown
Plug 'tpope/vim-markdown'
" autocomplete
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" debugger
Plug 'vim-vdebug/vdebug'
" project-specific vimrc files
Plug 'embear/vim-localvimrc'
" syntax checker
Plug 'maralla/validator.vim'
" http client
Plug 'aquach/vim-http-client'
call plug#end()
" ####################### END PLUGIN MANAGEMENT
" ####################### BEGIN PROPERTIES
let default_indentation=2 " spaces
" ####################### END PROPERTIES
" ####################### USER FUNCTIONS
" set indentation configs
function! SetIndentation(spaces)
execute "set tabstop=".a:spaces
execute "set softtabstop=".a:spaces
execute "set shiftwidth=".a:spaces
execute "set expandtab"
endfunction
" ####################### END USER FUNCTIONS
" ####################### BEGIN EDITOR SETTINGS
" setting up default encoding
:set encoding=utf-8
" setting up line numbers
:set nu
" setting up indentation
if has("autocmd")
filetype plugin indent on
endif
" set tab settings to 4 spaces
call SetIndentation(default_indentation)
" setting up default split to right and bottom
set splitbelow
set splitright
" uncomment this line in order to make the backspace key to work as usual
" set backspace=indent,eol,start
" setting up vim to autoreload files when changed
set autoread
" polyglot compat
set nocompatible
" ####################### END EDITOR SETTINGS
" ####################### BEGIN KEYMAP SETTINGS
" ; => Open the file search using fzf
map ; :Files<CR>
" setup the leader key
:let mapleader = ","
" close current window/tab
:nnoremap <leader>q :close<CR>
:nnoremap <leader>Q :q!<CR>
" save current file
:nnoremap <leader>s :w<CR>
" reload current file
:nnoremap <leader>r :e<CR>
" tab mapping
:nnoremap <leader>t :tabnew<CR>
:nnoremap <leader>m :tabprevious<CR>
:nnoremap <leader>. :tabnext<CR>
:nnoremap <leader>1 :tabn 1<CR>
:nnoremap <leader>2 :tabn 2<CR>
:nnoremap <leader>3 :tabn 3<CR>
:nnoremap <leader>4 :tabn 4<CR>
:nnoremap <leader>5 :tabn 5<CR>
:nnoremap <leader>T :tabedit %<CR>
" ####################### END KEYMAP SETTINGS
" ####################### BEGIN CUSTOM COMMANDS
" :Em => Enable mouse scroll navigation
:command Em set mouse=a
" :Dm => Disable mouse scroll navigation
:command Dm set mouse=
" :Rs => reload vim configuration
:command Rs so $MYVIMRC
" :WipeReg => clear vim registers
:command! WipeReg for i in range(34,122) | silent! call setreg(nr2char(i), []) | endfor
" :I2 => Set indentation to 2 spaces
:command I2 call SetIndentation(2)
" :I4 => Set indentation to 4 spaces
:command I4 call SetIndentation(4)
" ####################### END CUSTOM COMMANDS
" ####################### BEGIN PLUGINS SETTINGS
" scrooloose/nerdtree
let NERDTreeMapOpenInTab='\r'
let NERDTreeShowHidden=1
let g:NERDTreeDirArrows=0
let g:NERDTreeWinPos = "right"
" Ctrl + o => Open NERDtree viewer as a sidebar
map <C-o> :NERDTreeToggle<CR>
" tpop/vim-fugitive
:nnoremap <leader>gd :Gdiffsplit<CR>
:nnoremap <leader>gb :Gblame<CR>
" nathanaelkane/vim-indent-guides
colorscheme default
let g:indent_guides_auto_colors = 0
let g:indent_guides_guide_size = 1
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=darkgrey ctermbg=252
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=darkgrey ctermbg=251
" itchyny/lightline
set laststatus=2
let g:lightline = {
\ 'colorscheme': 'darcula',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ]]
\ },
\ 'component_function': {
\ 'gitbranch': 'fugitive#head'
\ }
\ }
" yggdroot/indentLine
let g:indentLine_setConceal = 0
" christoomey/vim-conflicted
let g:diffget_local_map = 'gl'
let g:diffget_upstream_map = 'gu'
:nnoremap <leader>nc :GitNextConflict<CR>
" embear/vim-localvimrc
let g:localvimrc_sandbox = 0
let g:localvimrc_persistent = 2
" neoclide/coc.nvim
set nobackup
set nowritebackup
set cmdheight=2
set updatetime=300
set shortmess+=c
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
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)
" ####################### END PLUGINS SETTINGS