-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
583 lines (456 loc) · 15.1 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
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
""" Minimal vim config if I need it instead of neovim
set nocompatible " be iMproved
filetype off " required!
"""""""""" undotree and persistent undo
set undofile
silent !mkdir -p ~/.vim/undodir
set undodir=~/.vim/undodir
nnoremap <F4> :UndotreeToggle<CR>
let neobundleReadme=expand('~/.vim/bundle/neobundle.vim/README.md')
if !filereadable(neobundleReadme)
echo "Installing NeoBundle..."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim
" echo "Done, restart vim"
" exit 1;
endif
set runtimepath+=~/.vim/bundle/neobundle.vim/
" if has('vim_starting')
" if &compatible
" set nocompatible " Be iMproved
" endif
"
" " Required:
" set runtimepath+=~/.vim/bundle/neobundle.vim/
" endif
" Required:
call neobundle#begin(expand('~/.vim/bundle/'))
" Let NeoBundle manage NeoBundle
" Required:
NeoBundleFetch 'Shougo/neobundle.vim'
" My Bundles here:
" Refer to |:NeoBundle-examples|.
" Note: You don't set neobundle setting in .gvimrc!
NeoBundle "Shougo/vimproc.vim", {
\ "build" : {
\ "windows" : "tools\\update-dll-mingw",
\ "cygwin" : "make -f make_cygwin.mak",
\ "mac" : "make -f make_mac.mak",
\ "linux" : "make",
\ "unix" : "gmake",
\ },
\ }
" Code editting goodness
NeoBundle "tomtom/tcomment_vim"
NeoBundle "mbbill/undotree"
NeoBundle "scrooloose/syntastic"
NeoBundle "tpope/vim-fugitive"
NeoBundle "airblade/vim-gitgutter"
NeoBundle "tpope/vim-surround"
NeoBundle "tpope/vim-repeat"
NeoBundle "gregsexton/gitv"
NeoBundle "godlygeek/tabular"
NeoBundle "ctrlpvim/ctrlp.vim"
NeoBundle "Shougo/neocomplete.vim"
" NeoBundle "ervandew/supertab"
NeoBundle "majutsushi/tagbar"
" hack to get 'correct' colors on vim terminal
NeoBundle 'vim-scripts/CSApprox'
NeoBundle 'flazz/vim-colorschemes'
" Show visual marker for indentation
NeoBundle 'Yggdroot/indentLine'
" Highlight trailing whitespaces
NeoBundle 'bronson/vim-trailing-whitespace'
" This requires ag to be installed
" https://github.com/rking/ag.vim
NeoBundle 'rking/ag.vim'
NeoBundle 'vim-airline/vim-airline'
NeoBundle 'vim-airline/vim-airline-themes'
NeoBundle 'danro/rename.vim'
" Language specific plugins
"""""""" Web (html/js/css and co) """"""""
NeoBundle 'vim-scripts/UltiSnips'
NeoBundle 'honza/vim-snippets'
" NeoBundle 'tpope/vim-jdaddy' " json
NeoBundle 'ap/vim-css-color'
NeoBundle "pangloss/vim-javascript"
NeoBundle "mxw/vim-jsx"
NeoBundle 'digitaltoad/vim-jade'
"github flavored markdown
NeoBundle 'tpope/vim-markdown'
"""""""" Python """"""""
NeoBundle 'klen/python-mode'
NeoBundle 'https://github.com/vim-scripts/django.vim'
" NeoBundle 'davidhalter/jedi-vim'
"""""""" Haskell """"""""
" stack install hdevtools hlint
" hdevtools requires `ghc` and `ghc-pkg` binaries on the path
" `stack path` will show where they are, just need to symlink them
NeoBundle "eagletmt/neco-ghc"
NeoBundle "bitc/vim-hdevtools"
"""""""" Misc """""""""
NeoBundle 'vim-scripts/loremipsum'
call neobundle#end()
" Required:
filetype plugin indent on
" If there are uninstalled bundles found on startup,
" this will conveniently prompt you to install them.
NeoBundleCheck
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" personal vimrc config
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set encoding=utf-8
au BufNewFile,BufRead *.json setlocal conceallevel=0
" per project .vimrc
set exrc
"remap the leaderkey to ,
:let mapleader = ","
" w is far far away on a bépo layout
noremap è w
noremap È W
noremap <c-è> <c-w>
noremap <c-È> <c-W>
"""""""" CSApprox plugin
" IMPORTANT: Uncomment one of the following lines to force
" using 256 colors (or 88 colors) if your terminal supports it,
" but does not automatically use 256 colors by default.
set t_Co=256
"set t_Co=88
let g:CSApprox_attr_map = { 'bold' : 'bold', 'italic' : '', 'sp' : '' }
" colorscheme darkocean
" colorscheme corporation
" colorscheme railscasts
" colorscheme inkpot
silent! colorscheme luna
" monokai, tomorrow night, tomorrow night bright
" Avoid the escape key
:imap jj <Esc>
:imap qq <Esc>
" let be serious !
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
imap <up> <nop>
imap <down> <nop>
imap <left> <nop>
imap <right> <nop>
map <C-up> <nop>
map <C-down> <nop>
map <C-left> <nop>
map <C-right> <nop>
imap <C-up> <nop>
imap <C-down> <nop>
imap <C-left> <nop>
imap <C-right> <nop>
" j and k as line wise movement
nnoremap <silent> j gj
nnoremap <silent> k gk
nnoremap gD <C-]>
"copy from system clipboard with p
"yank and allow to paste from system clipboard in other application
let os=substitute(system('uname'), '\n', '', '')
if os == 'Darwin'
set clipboard=unnamed
elseif os == 'Linux'
set clipboard=unnamedplus
endif
"disable creation of .swp files
set noswapfile
"set the terminal title
set title
"Display line number on the left
set number
"in an xterm, allow the use of the mouse
set mouse=a
"showmatch: Show the matching bracket for the last ')'?
set showmatch
" treat numerals as decimal instead of octals (practical vim tip11)
set nrformats=
"causes left and right arrow to change line when reaching the end/beginning
"< and > for normal mode, [ and ] for insert mode
set whichwrap+=<,>,[,]
" Tell vim to remember certain things when we exit
" '10 : marks will be remembered for up to 10 previously edited files
" "100 : will save up to 100 lines for each register
" :20 : up to 20 lines of command-line history will be remembered
" % : saved restores the buffer list
" n... : where to save the viminfo files
set viminfo='10,\"100,:20,n~/.viminfo
" Get back to last position.
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
"remember modified buffer when opening a new one with unsaved modif in the current buffer
set hidden
"set indentation to 2 spaces
set shiftwidth=2
set smartindent
" autocmd BufReadPost *.py setlocal shiftwidth=4
"replace <tab> by spaces
set expandtab
set tabstop=2
" A better backspace
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
"always paste with respect to indentation
nnoremap p ]p
"highlight search results
set hlsearch
"and start searching while typing
set incsearch
"to clear highlight search
nnoremap <F5> :let @/ = ""<CR>
"clear higlight search when opening a file
"the last search is remembered in viminfo
"and I didn't find a way to disable that
autocmd BufNewFile,BufReadPost * let @/ = ""
"quick save shortcut with <leader>s
"If the current buffer has never been saved, it will have no name,
"call the file browser to save it, otherwise just save it.
noremap <leader>s :update<cr>
inoremap <leader>s <esc>:update<cr>
nnoremap <leader>q :q<cr>
"indent folding with manual folds
" augroup vimrc
" au BufReadPre * setlocal foldmethod=indent
" au BufWinEnter * if &fdm == 'indent' | setlocal foldmethod=manual | endif
" augroup END
set foldmethod=indent
" open all folds when opening a file
set foldlevelstart=20
"search is case insensitive. If the search pattern contains
"upper case letter, then it's case sensitive
set ignorecase
set smartcase
" no more W is not a command !
nnoremap :W :w
nnoremap :Q :q
nnoremap gD <C-]>
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
" different color for the 90th column
if exists("&colorcolumn")
highlight ColorColumn ctermbg=grey guibg=orange
call matchadd('ColorColumn', '\%81v', 100)
" let &colorcolumn=join(range(90, 90),",")
" highlight ColorColumn ctermbg=235 guibg=#2c2d27
endif
" page up and down more accessible
noremap <BS> <C-B>
noremap <Space> <C-F>
" noremap <enter> zz
" more natural splits
set splitbelow
set splitright
" move between splits
map <C-h> <c-w>h
map <C-j> <c-w>j
map <C-k> <c-w>k
map <C-l> <c-w>l
" usefull stuff found here: http://vimbits.com/bits
" Make Y behave like other capitals
map Y y$
" automatically reload vimrc when it's saved
" au BufWritePost .vimrc so ~/.vimrc
"""""""" the following is inspired by Derek Wyatt vimrc
" https://github.com/derekwyatt/vim-config/blob/master/vimrc
" set the search scan to wrap lines
set wrapscan
" Edit the vimrc file
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>ov :so $MYVIMRC<CR>
" Don't update the display while executing macros
set lazyredraw
" Show the current mode
set showmode
" These commands open folds
set foldopen=block,insert,jump,mark,percent,quickfix,search,tag,undo
" When the page starts to scroll, keep the cursor 2 lines from the top and 2
" lines from the bottom
set scrolloff=2
" Allow the cursor to go in to "invalid" places
" set virtualedit=all
" Make the command-line completion better
set wildmenu
" Wipe out all buffers
nmap <silent> ,wa :1,9000bwipeout<cr>
" Read gzip files without unzipping
" http://vimdoc.sourceforge.net/htmldoc/autocmd.html#gzip-example
augroup gzip
autocmd!
autocmd BufReadPre,FileReadPre *.gz set bin
autocmd BufReadPost,FileReadPost *.gz '[,']!gunzip
autocmd BufReadPost,FileReadPost *.gz set nobin
autocmd BufReadPost,FileReadPost *.gz execute ":doautocmd BufReadPost " . expand("%:r")
autocmd BufWritePost,FileWritePost *.gz !mv <afile> <afile>:r
autocmd BufWritePost,FileWritePost *.gz !gzip <afile>:r
autocmd FileAppendPre *.gz !gunzip <afile>
autocmd FileAppendPre *.gz !mv <afile>:r <afile>
autocmd FileAppendPost *.gz !mv <afile> <afile>:r
autocmd FileAppendPost *.gz !gzip <afile>:r
augroup END
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" plugins configurations
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""" Markdown
" augroup markdown
" au!
" au BufNewFile,BufRead *.md,*.markdown setlocal filetype=ghmarkdown
" augroup END
au BufNewFile,BufRead *.md,*.markdown setlocal filetype=markdown
"""""""""" Tagbar
nnoremap <F8> :TagbarToggle<CR>
"""""""" Airline
let g:airline_theme='dark'
let g:airline_left_sep=''
let g:airline_right_sep=''
syntax on
set laststatus=2 " Always show the statusline
set encoding=utf-8 " Required to show Unicode glyphs
"""""""" Fugitive
" Delete hidden buffer opened by fugitive
autocmd BufReadPost fugitive://* set bufhidden=delete
"""""""" gitgutter
let g:updatetime = 250
"""""""" CtrlP
" ignore files that git ignores
" from https://github.com/kien/ctrlp.vim/issues/273
" let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_custom_ignore = '.git\|node_modules\|git\|venv\|.pyc\|dist/'
" let g:ctrlp_map = '<leader>p'
nnoremap <leader>p :CtrlP .<cr>
nnoremap <c-p> :CtrlP .<cr>
nnoremap <leader>b :CtrlPBuffer <cr>
" :h ctrlp-options
let g:ctrlp_root_markers = ['.git, .svn']
let g:ctrlp_match_window = 0
let g:ctrl_switch_buffer = 0
"""""""""" UltiSnips
"let g:UltiSnipsExpandTrigger="<tab>"
"let g:UltiSnipsJumpForwardTrigger="<tab>"
"let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" let g:UltiSnipsSnippetDirectories=["UltiSnips", "vim-snippets/UltiSnips"]
"let g:UltiSnipsSnippetDirectories=["bundle/vim-snippets/UltiSnips", "bundle/configFiles/frogSnippets"]
"""""""""" vim-javascript
let g:javascript_ignore_javaScriptdoc=1
let g:javascript_enable_domhtmlcss=1
" let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets'
"
" " SuperTab like snippets behavior.
" imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)"
" \: pumvisible() ? "\<C-n>" : "\<TAB>"
" smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)"
" \: "\<TAB>"
" Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
" let g:syntastic_always_populate_loc_list = 1
" let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" let g:syntastic_python_pyflakes_exe = 'python3 ~/.local/bin/pyflakes'
let g:syntastic_python_python_exec = '/usr/local/bin/python3'
" let g:syntastic_python_checkers = ['flake8']
let g:syntastic_python_checkers = ['pylint']
let g:syntastic_python_flake8_exe = 'python3 -m flake8'
let g:syntastic_python_pylint_post_args = '--msg-template="{path}:{line}:{column}:{C}: [{symbol} {msg_id}] {msg}"'
let g:syntastic_aggregate_errors = 1
let g:syntastic_javascript_checkers = ['eslint']
" let g:syntastic_php_checkers = []
" let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [], 'passive_filetype': []}
nnoremap <C-w>E :SyntasticCheck<CR> :SyntasticToggleMode<CR>
" Python
" autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4
" autocmd Filetype python setlocal foldmethod=indent
let g:jedi#completions_command = "<C-N>"
let g:jedi#popup_on_dot = 0
"""""""""" Python-mode
let g:pymode_rope = 0
let g:pymode_lint = 0 " done with syntastic
" let g:pymode_rope_complete_on_dot = 0
" let g:pymode_rope_autoimport = 0
" This requires vim with python3 support
let g:pymode_python = 'python3'
let g:pymode_options_max_line_length = 100
let g:pymode_doc = 1
let g:pymode_doc_bind = 'K'
"""""""""" undotree and persistent undo
set undofile
silent !mkdir -p ~/.vim/undodir
set undodir=~/.vim/undodir
nnoremap <F4> :UndotreeToggle<CR>
"""""""""" indentLine
" indentLine plugin prevent override of conceallevel setting. The following
" line will fix that
" See https://github.com/elzr/vim-json/issues/23#issuecomment-40293049
let g:indentLine_noConcealCursor=""
"""""""""" NeoComplete
let g:neocomplete#enable_at_startup=1
" Shell like behavior(not recommended).
" set completeopt+=longest
" let g:neocomplete#enable_auto_select = 1
" inoremap <expr><TAB> pumvisible() ? "\<Down>" :
" \ neocomplete#start_manual_complete()
inoremap <expr><C-n> pumvisible() ? "\<C-n>" : neocomplete#start_manual_complete()
let g:neocomplete#disable_auto_complete = 1
"""""""""" Haskell
nnoremap <F1> :HdevtoolsType<CR>
nnoremap <F2> :HdevtoolsClear<CR>
nnoremap <F3> :HdevtoolsInfo<CR>
" https://github.com/majutsushi/tagbar/wiki#haskell
let g:tagbar_type_haskell = {
\ 'ctagsbin' : 'hasktags',
\ 'ctagsargs' : '-x -c -o-',
\ 'kinds' : [
\ 'm:modules:0:1',
\ 'd:data: 0:1',
\ 'd_gadt: data gadt:0:1',
\ 't:type names:0:1',
\ 'nt:new types:0:1',
\ 'c:classes:0:1',
\ 'cons:constructors:1:1',
\ 'c_gadt:constructor gadt:1:1',
\ 'c_a:constructor accessors:1:1',
\ 'ft:function types:1:1',
\ 'fi:function implementations:0:1',
\ 'o:others:0:1'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 'm' : 'module',
\ 'c' : 'class',
\ 'd' : 'data',
\ 't' : 'type'
\ },
\ 'scope2kind' : {
\ 'module' : 'm',
\ 'class' : 'c',
\ 'data' : 'd',
\ 'type' : 't'
\ }
\ }
" hindent setup from:
" https://github.com/chrisdone/hindent/blob/master/vim/hindent.vim
if exists("g:loaded_hindent") || !executable("hindent")
finish
endif
let g:loaded_hindent = 1
if !exists("g:hindent_style")
let g:hindent_style = "fundamental"
endif
function! FormatHaskell()
if !empty(v:char)
return 1
else
let l:filter = "hindent --style " . g:hindent_style
let l:command = v:lnum.','.(v:lnum+v:count-1).'!'.l:filter
execute l:command
endif
endfunction
if has("autocmd")
autocmd FileType haskell setlocal formatexpr=FormatHaskell()
endif