-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
438 lines (338 loc) · 9.5 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
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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
""""""""""""""""""""""""""""""
" Base conf
""""""""""""""""""""""""""""""
scriptencoding UTF-8
" disable vim startup message
set shortmess=I " Read :help shortmess for everything else.
" enable theme
syntax enable
" show current line
set cursorline
" show current column
set cursorcolumn
" color for the current line
hi CursorLine guibg=#4d4d4d
" encoding
set encoding=UTF-8
set fileencodings=UTF-8
set fileencoding=UTF-8
" remove beep
set vb
" remove sound if error
set errorbells
set novisualbell
set t_vb=
" display line number
set number
" backspace
set backspace=indent,eol,start
" show existing tab with 2 spaces width
set softtabstop=2
set tabstop=2
" when indenting with '>', use 2 spaces width
set shiftwidth=2
" On pressing tab, insert 2 spaces
set expandtab
" enable mouse scroll
:set mouse=a
""""""""""""""""""""""""""""""
" enable backup
""""""""""""""""""""""""""""""
set backup
" backup folder: ~/.vim/backup
if filewritable(expand("$HOME/.vim/backup")) == 2
set backupdir=$HOME/.vim/backup
else
if has("unix") || has("win32unix")
call system("mkdir $HOME/.vim/backup -p")
set backupdir=$HOME/.vim/backup
endif
endif
" fix webpack watch
set backupcopy=yes
" set history
set history=100
" enable syntax
if has("syntax")
syntax on
endif
" listen to reload file
set autoread
" show status bar
set laststatus=2
" setup status line
" set statusline=%F%m\ %r\ Line:%l\/%L,%c\ %p%%
" set statusline=%<%f%=\ [%1*%M%*%n%R%H]\ %-19(%3l,%02c%03V%)%O'%02b'\ \ %{strftime('%H:%M')}
set statusline=%F%m\ %r\ Line:%l\/%L,%c\ %p%%%=\ \ %{strftime('%H:%M')}
" search case insensitive
set ignorecase
set infercase
" if end of file, don t go to begin of file
set hlsearch
" show cursor position
set ruler
" improve vim display
set ttyfast
"""""""""""""""""""""""""""""""
" Plugins
"""""""""""""""""""""""""""""""
call plug#begin('$HOME/.vim/plugged')
" for JS
Plug 'pangloss/vim-javascript'
Plug 'posva/vim-vue'
Plug 'flowtype/vim-flow', {
\ 'autoload': {
\ 'filetypes': 'javascript'
\ },
\ 'build': {
\ 'mac': 'npm install -g flow-bin',
\ 'unix': 'npm install -g flow-bin'
\ }}
" coding style
Plug 'editorconfig/editorconfig-vim'
" Ctrl + E: h, j, k, l rezie
Plug 'simeji/winresizer'
" auto close (x)html tags
Plug 'alvan/vim-closetag'
" Minimap like sublime text
Plug 'severin-lemaignan/vim-minimap'
" autocomplete
" Plug 'Valloric/YouCompleteMe'
" async tasks
Plug 'Shougo/vimproc.vim'
" show errors ale is async compare to syntastic
" Plug 'vim-syntastic/syntastic'
Plug 'w0rp/ale'
" show git diff
Plug 'airblade/vim-gitgutter'
" git
Plug 'tpope/vim-fugitive'
" multiple selection
Plug 'terryma/vim-multiple-cursors'
" TypeScript syntaz
Plug 'leafgarland/typescript-vim'
" Golang
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" rename variables
Plug 'ternjs/tern_for_vim'
" automatic closing of quotes, parenthesis, brackets
Plug 'jiangmiao/auto-pairs'
" search / open file
Plug 'ctrlpvim/ctrlp.vim'
" Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeToggle', 'NERDTreeFind'] } | Plug 'Xuyuanp/nerdtree-git-plugin' | Plug 'ryanoasis/vim-devicons'
Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeToggle', 'NERDTreeFind'] } | Plug 'Xuyuanp/nerdtree-git-plugin'
" browse tags (class / var ...)
Plug 'majutsushi/tagbar'
" add symbol after x characters
Plug 'Yggdroot/indentLine'
" marks
Plug 'jacquesbh/vim-showmarks'
" graphic undo
Plug 'sjl/gundo.vim'
" nice bottom bar with info
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Themes
Plug 'NLKNguyen/papercolor-theme'
Plug 'crusoexia/vim-monokai'
Plug 'morhetz/gruvbox'
Plug 'acarapetis/vim-colors-github'
call plug#end()
"""""""""""""""""""""""""""""""
" config plugin airline
"""""""""""""""""""""""""""""""
let g:airline_theme='papercolor'
let g:airline_solarized_bg='light'
let g:airline_powerline_fonts = 1
"""""""""""""""""""""""""""""""
" CtrlP auto cache clearing
"""""""""""""""""""""""""""""""
function! SetupCtrlP()
if exists("g:loaded_ctrlp") && g:loaded_ctrlp
augroup CtrlPExtension
autocmd!
autocmd FocusGained * CtrlPClearCache
autocmd BufWritePost * CtrlPClearCache
augroup END
endif
endfunction
if has("autocmd")
autocmd VimEnter * :call SetupCtrlP()
endif
"""""""""""""""""""""""""""""""
" NerdTree
"""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""
" Gundo
"""""""""""""""""""""""""""""""
if has('python3')
let g:gundo_prefer_python3 = 1
endif
"""""""""""""""""""""""""""""""
" Config close tag
"""""""""""""""""""""""""""""""
let g:closetag_filenames = '*.xhtml,*.html,*.vue,*.jsx'
let g:closetag_shortcut = '>'
"""""""""""""""""""""""""""""""
" config theme
"""""""""""""""""""""""""""""""
colorscheme PaperColor
" colorscheme monokai
" colorscheme gruvbox
" colorscheme github
" set bg=dark
set bg=light
"""""""""""""""""""""""""""""""
" config plugin indent
"""""""""""""""""""""""""""""""
let g:indentLine_char = '|'
let g:indentLine_leadingSpaceEnabled = 1
let g:indentLine_leadingSpaceChar = '·'
let g:indentLine_bufNameExclude = ['_.*', 'NERD_tree.*']
"""""""""""""""""""""""""""""""
" config editorconfig
"""""""""""""""""""""""""""""""
" let g:EditorConfig_exec_path = '/usr/bin/editorconfig'
"""""""""""""""""""""""""""""""
" config vim-javascript
"""""""""""""""""""""""""""""""
" let g:javascript_conceal_function = "ƒ"
" let g:javascript_conceal_arrow_function = "⇒"
" let g:javascript_plugin_flow = 1
" set conceallevel=1
"""""""""""""""""""""""""""""""
" config syntastic
"""""""""""""""""""""""""""""""
" eslint its parser and plugin dependencies must be installed locally in
" each project
" let g:syntastic_javascript_checkers=['eslint']
" let g:syntastic_javascript_eslint_generic = 1
" let g:syntastic_javascript_eslint_exec = '/bin/ls'
" let g:syntastic_javascript_eslint_exe='$(npm bin)/eslint'
" let g:syntastic_javascript_eslint_args='-f compact'
" exec manualy syntastic
" let g:syntastic_mode_map = { 'mode': 'passive' }
"""""""""""""""""""""""""""""""
" ale config
"""""""""""""""""""""""""""""""
let g:ale_sign_column_always = 1
let g:airline#extensions#ale#enabled = 1
let g:ale_sign_error = '✖'
let g:ale_sign_info = '⚠'
let g:ale_sign_warning = '⚠'
" enable ale for js
let g:ale_linters = {
\ 'javascript': ['eslint', 'flow'],
\}
" Enable completion where available.
let g:ale_completion_enabled = 1
"""""""""""""""""""""""""""""""
" config gitgutter
"""""""""""""""""""""""""""""""
let g:gitgutter_highlight_lines = 0
" reduce time from 4s to 2500ms to refresh gitgutter
" (should) let enough time to ale to show errors/warning, else gitgutter override signs
set updatetime=2500
"""""""""""""""""""""""""""""""
" config ctrl-p plugin: ignore files/folders
"""""""""""""""""""""""""""""""
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git\|coverage\|dist'
let g:ctrlp_working_path_mode = 0
"""""""""""""""""""""""""""""""
" config ctags
"""""""""""""""""""""""""""""""
let g:tagbar_type_typescript = {
\ 'ctagsbin' : 'tstags',
\ 'ctagsargs' : '-f-',
\ 'kinds': [
\ 'e:enums:0:1',
\ 'f:function:0:1',
\ 't:typealias:0:1',
\ 'M:Module:0:1',
\ 'I:import:0:1',
\ 'i:interface:0:1',
\ 'C:class:0:1',
\ 'm:method:0:1',
\ 'p:property:0:1',
\ 'v:variable:0:1',
\ 'c:const:0:1',
\ ],
\ 'sort' : 0
\ }
"""""""""""""""""""""""""""""""
" Tern
"""""""""""""""""""""""""""""""
let g:tern_map_keys=1
let g:tern_show_argument_hints='on_hold'
""""""""""""""""""""""""""""""
" Flow
""""""""""""""""""""""""""""""
filetype plugin on
set omnifunc=syntaxcomplete#Complete
" disable typecheking on `:w`
" by default use ale
let g:flow#enable = 0
"""""""""""""""""""""""""""""""
" shortcuts
"""""""""""""""""""""""""""""""
" tabs navigation
nnoremap <S-Tab> :tabprevious<CR>
nnoremap <Tab> :tabnext<CR>
" outindent in virtual mode
vnoremap < <gv
" indent in virtual mode
vnoremap > >gv
" alignment of file
:nnoremap <localleader>= <Esc>gg=G<C-o>
" NerdTree
map <silent> <C-o> :NERDTreeToggle<CR>
map <silent> <C-f> :NERDTreeFind<CR>
" tagbar
nmap <C-g> :TagbarToggle<CR>
" Gundo
map <silent> <C-h> :GundoToggle<CR>
" show buffer
:nnoremap <localleader>b :ls<CR>:buffer<Space>
" move line (normal/insert mode)
nnoremap <C-Down> :m-1<CR>
nnoremap <C-Up> :m-2<CR>
nnoremap <C-Down> :m+<CR>
inoremap <C-Up> <Esc>:m-2<CR>
inoremap <C-Down> <Esc>:m+<CR>
" move lines (visual mode)
vnoremap <C-Down> :m '>+1<CR>gv=gv
vnoremap <C-Up> :m '<-2<CR>gv=gv
" marks
:nnoremap <localleader>m :<CR>:DoShowMarks<CR>
:nnoremap <localleader>m! :<CR>:NoShowMarks<CR>
" delete marks
:delm! | delm A-Z0-9
"""""""""""""""""""""""""""""""
" sessions
"""""""""""""""""""""""""""""""
function! MakeSession()
exe "NERDTreeClose"
let b:sessiondir = '$HOME/.vim/sessions'
let b:filename = split(getcwd(), '/')
let b:filename = b:filename[-1] . '-' . b:filename[-2] . '-' .b:filename[-3]
let b:filename = b:sessiondir . '/' . b:filename . '.vim'
exe "mksession! " . b:filename
exe ":wqa"
endfunction
function! OpenSession()
let b:sessiondir = '$HOME/.vim/sessions'
let b:filename = split(getcwd(), '/')
let b:filename = b:filename[-1] . '-' . b:filename[-2] . '-' .b:filename[-3]
let b:filename = b:sessiondir . '/' . b:filename . '.vim'
exe "source " . b:filename
exe "NERDTreeFind"
endfunction
function! ListSessions()
exe "!ls -1 $HOME/.vim/sessions/ "
endfunction
:nnoremap <localleader>q :<CR>:execute MakeSession()<CR>
:nnoremap <localleader>o :<CR>:execute OpenSession()<CR>
" fix 'imp module is deprecated in favour of importlib'
if has('python3')
silent! python3 1
endif