-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
651 lines (556 loc) · 16.9 KB
/
.vimrc
File metadata and controls
651 lines (556 loc) · 16.9 KB
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
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
" Tabs
set tabstop=2
set shiftwidth=2
set expandtab
set nocompatible " be iMproved
filetype off " required!
let mapleader = ","
set clipboard=unnamed
" Global variables {{{
let s:isWindows = has('win32') || has('win64')
"}}}
" Commands timeout {{{
" Mapping commands delay
set timeoutlen=1000
" Make Escape faster or any key code
set ttimeoutlen=0
"}}}
" Basic configuration {{{
set encoding=utf-8
if has("gui_macvim") || has("unix")
set list "required by listchars
set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:❮
set showbreak=↪
elseif has("gui_win32")
set list "required by listchars
set listchars=tab:▸\ ,eol:¬,extends:╞,precedes:╡
set showbreak=→
endif
set visualbell
set splitbelow
set splitright
set title
" Enable mouse
set mouse=a
" Do not show the text edited in vim when it is closed
au VimLeave * :!clear
" }}}
" Trailing whitespace {{{
" Only shown when not in insert mode so I don't go insane.
augroup trailing
au!
if has("gui_macvim")
au InsertEnter * :set listchars-=trail:⌴
au InsertLeave * :set listchars+=trail:⌴
elseif has("gui_win32")
au InsertEnter * :set listchars-=trail:□
au InsertLeave * :set listchars+=trail:□
endif
augroup END
" Clean trailing whitespace
nnoremap <leader>tt mz:%s/\s\+$//<cr>:let @/=''<cr>`z
" }}}
" Saving and Auto saving {{{
" augroup autosave
" au!
" au InsertLeave * :update
" augroup END
" Save shortcut
nnoremap s :w<cr>
" nnoremap :w<cr> :call input("NOPE!")<cr>
" Save when losing focus
" au FocusLost * :silent! wall
" }}}
"
" Backups {{{
set backup " enable backups
set noswapfile " it's 2013, Vim.
set undodir=~/.vim/tmp/undo// " undo files
set backupdir=~/.vim/tmp/backup// " backups
set directory=~/.vim/tmp/swap// " swap files
" Make those folders automatically if they don't already exist.
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), "p")
endif
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), "p")
endif
" }}}
" Custom mappings {{{
" faster way to change to normal mode
inoremap jk <ESC>
" Kill the buffer
nnoremap K :q<cr>
nnoremap <leader>p "+p
" Heresy
inoremap <c-a> <esc>I
inoremap <c-e> <esc>A
cnoremap <c-a> <home>
cnoremap <c-e> <end>
" Close all the buffers except this one
nnoremap <leader>o :only<cr>
" Set F12 for setting paste and nopaste
set pastetoggle=<F12>
nnoremap <F5> :e!<cr>
" }}}
" CommandT config {{{
" Use root directory the pwd of vim
" It does not search for git or mercurial in the parent dirs
let g:CommandTTraverseSCM = 'pwd'
" }}}
" Netrw management {{{
" Open vertical explorer
nnoremap <leader>xv :Vexplore!<cr>
"Open horizontal explorer
nnoremap <leader>xs :Sex<cr>
" Open explorer in current buffer
nnoremap <leader>xx :Ex<cr>
" }}}
" Fugitive mappings {{{
nnoremap <leader>gs :Gstatus<cr>
nnoremap <leader>gb :Gblame<cr>
nnoremap <leader>gr :Gread<cr>
nnoremap <leader>gw :Gwrite<cr>
nnoremap <leader>gl :Glog<cr>
nnoremap <leader>gp :Gpush<cr>
nnoremap <leader>ge :Gedit<cr>
" }}}
" Directional Keys {{{
" It's 2015.
noremap j gj
noremap k gk
noremap gj j
noremap gk k
"}}}
" Jumping {{{
" Keep jumps in the middle of the window
nnoremap g; g;zz
nnoremap g, g,zz
nnoremap <c-o> <c-o>zz
nnoremap <c-6> <c-6>zz
" }}}
" Font {{{
if has("gui_macvim")
set guifont=Monaco:h12
elseif has("gui_win32")
set guifont=Consolas:h11:cANSI
endif
"}}}
" Configure Search and matches {{{
set hlsearch
set incsearch
set smartcase "Match uppercase when they are written in search
set ignorecase "Ignore case when searching
" Keep search matches in the middle of the window
nnoremap n nzzzv
nnoremap N Nzzzv
"}}}
" Change the cursor in insert mode"
" first, enable status line always (shows filename in status)
" Not necessary with tmux
" set laststatus=2
" now set it up to change the status line based on mode
if version >= 700
au InsertEnter * hi StatusLine term=reverse ctermbg=5 gui=undercurl
" guisp=Magenta
au InsertLeave * hi StatusLine term=reverse ctermfg=0 ctermbg=2
"" gui=bold,reverse
endif
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle
" required!
Plugin 'VundleVim/Vundle.vim'
" Color scheme
Plugin 'ovu/badwolf'
" My Bundles here:
Plugin 'jelera/vim-javascript-syntax'
Plugin 'nathanaelkane/vim-indent-guides'
Plugin 'scrooloose/syntastic'
Plugin 'gorodinskiy/vim-coloresque'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'jiangmiao/auto-pairs'
Plugin 'mattn/emmet-vim'
Plugin 'ctrlpvim/ctrlp.vim'
" Plugin 'Valloric/YouCompleteMe'
" Required for go
Plugin 'fatih/vim-go'
Plugin 'SirVer/ultisnips'
" Snipmate and its dependencies
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'garbas/vim-snipmate'
" For Raml files
Plugin 'IN3D/vim-raml'
" Json files
Plugin 'elzr/vim-json'
Plugin 'tpope/vim-jdaddy'
Plugin 'kopischke/vim-fetch'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-unimpaired'
Plugin 'tpope/vim-repeat'
" Better copy paste for vim
Plugin 'svermeulen/vim-easyclip'
" Needed for Omnisharp
" Plugin 'tpope/vim-dispatch'
Plugin 'szw/vim-maximizer'
Plugin 'easymotion/vim-easymotion'
Plugin 'dag/vim-fish'
Plugin 'pearofducks/ansible-vim'
" Scala
Plugin 'derekwyatt/vim-scala'
" Haskell
Plugin 'eagletmt/ghcmod-vim'
Plugin 'bitc/vim-hdevtools'
Plugin 'eagletmt/neco-ghc'
Plugin 'Shougo/neocomplete'
Plugin 'Shougo/vimproc.vim'
Plugin 'ovu/haskellmode-vim'
Plugin 'ekalinin/Dockerfile.vim'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'leafgarland/typescript-vim'
Plugin 'martinda/Jenkinsfile-vim-syntax'
call vundle#end()
filetype plugin indent on " required!
" Numbers
set number
" Colors
"set t_Co=256
syntax on
if has('gui_running')
set lines=999 columns=999
set background=dark
colorscheme badwolf
" Reload the colorscheme whenever we write the file.
augroup color_badwolf_dev
au!
au BufWritePost badwolf.vim color badwolf
augroup END
else
set t_Co=256
set background=dark
if !s:isWindows
colorscheme badwolf
else
colorscheme distinguished
endif
endif
" Buffers and windows
set splitright
" Source Vimrc after saving it"
if has("autocmd")
autocmd! bufwritepost .vimrc source $MYVIMRC
endif
" Pressing ,v opens vimrc in a new tab
nmap <leader>v :tabedit $MYVIMRC<CR>
" Edit files rapidly {{{
nmap <leader>ev :vsplit $MYVIMRC<CR>
nmap <leader>ep :vsplit ~/.profile<CR>
nmap <leader>et :vsplit ~/.tmux.conf<CR>
nmap <leader>em :vsplit ~/.muttrc<CR>
" }}}
" Pressing leader sv sources the vimrc
nnoremap <leader>sv :source $MYVIMRC<CR>
" Set status line
set statusline=[%02n]\ %f
" Set shortcuts for vimdiff
if &diff
map <leader>1 : diffget 1 <CR>
map <leader>2 : diffget 2 <CR>
map <leader>3 : diffget 3 <CR>
map <leader>4 : diffget 4 <CR>
endif
" Windows navigation {{{
map <C-h> <C-w>h
map <C-l> <C-w>l
map <C-j> <C-w>j
map <C-k> <C-w>k
" }}}
if has("gui_macvim") || has("gui_win32")
set cursorline
endif
" show cursorline
"augroup CursorLineOnlyInActiveWindow
" autocmd!
" autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline
" autocmd WinLeave * setlocal nocursorline
"augroup END
" Set cursorline color
"highlight CursorLine ctermfg=white ctermbg=23
" Allow backspace to delete existing text
set backspace=indent,eol,start
" Select the last text that was paste
nnoremap <expr> gp '`[' . strpart(getregtype(), 0, 1) . '`]'
" Hide the toolbar and menu when in UI
set guioptions-=m
set guioptions-=T
" Commandt configurations
" let g:CommandTHighlightColor = 'green'
" Commandt exclude directories
set wildignore +=bower_components
set wildignore +=node_modules
set wildignore +=dist
set wildignore +=testresults
" EasyGrep configuration
let g:EasyGrepFilesToExclude='bower_components,node_modules,.tmp,.git,*.swp,packages'
let g:EasyGrepCommand=1 "ack
let g:EasyGrepRecursive=1 "yes
let g:EasyGrepSearchCurrentBufferDir=1 "No
" Enable matchit: match the start and end of code blocks, e.g html elements
runtime macros/matchit.vim
" JSHINT configuration"
let $JS_CMD='node'
" JSCS {{{
" Use jshint and jscsrc
"autocmd FileType javascript let b:syntastic_checkers = findfile('.jscsrc', '.;') != '' ? ['jscs'] : ['jshint']
" autocmd FileType javascript let b:syntastic_checkers = findfile('.eslintrc', '.;') != '' ? ['eslint'] : ['standard']
" let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_javascript_checkers = ['jshint']
" Default recommendet settings for 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 = 1
" }}}
" Haskell Config {{{
" let g:syntastic_haskell_checkers = ['ghc-mod']
noremap T :HdevtoolsType <cr>
au FileType haskell nnoremap <buffer> <F1> :GhcModType<CR>
au FileType haskell nnoremap <buffer> <silent> <F2> :GhcModTypeClear<CR>
au FileType haskell nnoremap <buffer> <silent> ti :GhcModInfo!<CR>
au FileType haskell nnoremap <buffer> <silent> ts :GhcModSplitFunCase!<CR>
au FileType haskell nnoremap <buffer> <silent> tc :GhcModSigCodegen!<CR>
au FileType haskell nnoremap <buffer> <silent> te :GhcModTypeInsert!<CR>
au FileType haskell nnoremap <buffer> <silent> tf :GhcModInfoPreview!<CR>
" Configure YouCompleteMe with neco
let g:ycm_semantic_triggers = {'haskell' : ['.']}
" Avoid error of module not found with hdevtools
function! FindCabalSandboxRoot()
return finddir('.cabal-sandbox', './;')
endfunction
function! FindCabalSandboxRootPackageConf()
return glob(FindCabalSandboxRoot().'/*-packages.conf.d')
endfunction
" let g:syntastic_haskell_hdevtools_args = '-g-ilib -g-isrc -g-i. -g-idist/build/autogen -g-Wall -g-package-conf='.FindCabalSandboxRootPackageConf()
" let g:hdevtools_options = '-g-ilib -g-isrc -g-i. -g-idist/build/autogen -g-Wall -g-package-conf='.FindCabalSandboxRootPackageConf()
" Config for haskell mode
let g:haddock_browser="open"
let g:haddock_browser_url="http://localhost:8000/"
let g:haddock_browser_callformat = "%s %s"
" let g:haddock_browser="/Applications/Safari.app/Contents/MacOS/Safari"
let g:haddock_indexfiledir="/Users/omardiego/.vim/"
let g:haddock_docdir="/Users/omardiego/.stack/snapshots/x86_64-osx/lts-7.17/8.0.1/"
" }}}
" Haskell files {{{
augroup ft_haskell
au!
" Haskell completion with neco
let g:haskellmode_completion_ghc = 0
au FileType haskell setlocal omnifunc=necoghc#omnifunc
augroup END
" }}}
" Vim {{{
augroup ft_vim
au!
au FileType vim setlocal foldmethod=marker
au FileType help setlocal textwidth=78
au BufWinEnter *.txt if &ft == 'help' | wincmd L | endif
augroup END
" }}}
" Json {{{
augroup ft_json
au!
au FileType json setlocal foldmethod=syntax
au FileType help setlocal textwidth=78
" let g:vim_json_syntax_conceal = 0 " Disable conceal for the plugin vim json
augroup END
"}}}
" Javascript {{{
augroup ft_javascript
au!
" The color column should be in sync with jshint. Change this value when jshint default changes
au FileType javascript setlocal colorcolumn=120
augroup END
" }}}
"
" Custom Grep {{{
vnoremap <leader>g :<c-u>call GrepOperator(visualmode())<cr> \| :execute "normal! n" <cr>
function! GrepOperator(type)
if a:type ==# 'v'
normal! `<v`>y
elseif a:type ==# 'char'
normal! `[v`]y
else
return
endif
silent execute "Ggrep" . shellescape(@@) . " ."
copen
let @/ = escape(@@, '\\/.*$^~[]''')
"Redraw so it looks good after showing results
silent execute "redraw!"
endfunction
command! -nargs=1 Gg call s:GrepText(<f-args>) | execute "normal! /".<f-args>."\<cr>"
function! s:GrepText(text)
execute "Ggrep ".a:text
copen
endfunction
" }}}
"
" Fugitive configuration {{{
command! -nargs=0 Gs execute "Gstatus"
command! -nargs=0 Gb execute "Gblame"
command! -nargs=0 Gw execute "Gwrite"
command! -nargs=0 Gl execute "Glog"
command! -nargs=0 Gp execute "Gpush"
command! -nargs=0 Gc execute "Gcommit"
" }}}
"
" Control P configuration {{{
" Set custom file scanner: root, file listing
let g:ctrlp_user_command = ['.git','cd %s && git ls-files && git ls-files -o --exclude-standard']
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:25,results:25'
"}}}
"
" Syntax highlighting {{{
" Syntax highlighting javascript libraries
let g:used_javascript_libs = 'angularjs'
" }}}
" Improved unimpaired {{{
" Show matches in the middle of the window
nnoremap [q :cprevious<cr>zz
nnoremap ]q :cnext<cr>zz
" }}}
" Configure AutoPairs {{{
" Disable center line when cr is pressed
let g:AutoPairsCenterLine = 0
" }}}
" Emmet plugin configuration {{{
imap <Leader>e <C-Y>,
"
" }}}
" YouCompleteMe plugin configureation {{{
" Disable TAB for autocompletion because TAB is used by SnipMate
let g:ycm_key_list_select_completion = ['<Down>']
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_add_preview_to_completeopt = 0
" Disable the preview window when completing with ycm
set completeopt = "menu"
" " }}}"
" Go Vim plugin configuration {{{
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <leader>c <Plug>(go-coverage)
" Show documentation
au FileType go nmap <Leader>gd <Plug>(go-doc)
au FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
" Show type info
au FileType go nmap <Leader>gi <Plug>(go-info)
" Custom mappings
au FileType go nmap <leader>d <Plug>(go-describe)
au FileType go nmap <leader>i <Plug>(go-implements)
au FileType go nmap <leader>a <Plug>(go-callers)
" Configure syntastic plugin to avoid it builds everytime a file is saved
let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
" Required to get the type information
let g:go_auto_type_info = 1
" Linter configuration
let g:go_metalinter_autosave_enabled = ['vet', 'golint']
" Disable K to show dodoc. K is to kill buffer!
let g:go_doc_keywordprg_enabled = 0
" }}}
" Omnisharp configuraiton {{{
let g:syntastic_cs_checkers = ['issues', 'semantic']
" }}}
" Easy file navigation with gf when file extension is missing {{{
augroup suffixes
autocmd!
let associations = [
\["javascript", ".js,.javascript,.es,.esx,.json,.jsx"],
\["python", ".py,.pyw"]
\]
for ft in associations
execute "autocmd FileType " . ft[0] . " setlocal suffixesadd=" . ft[1]
endfor
augroup END
" }}}
" Easy Clip configuration {{{
" Do not use <C-P> and <C-p>
let g:EasyClipUsePasteToggleDefaults = 0
nmap ]p <plug>EasyClipSwapPasteForward
nmap [p <plug>EasyClipSwapPasteBackwards
" Show yanks to paste
nnoremap <leader>i :IPaste<cr>
" Persist yanks ans share between vim instances
let g:EasyClipShareYanks=1
"}}}
" Better Next textobject {{{
" Stolen from Steve Losh
" https://bitbucket.org/sjl/dotfiles/src/tip/vim/.vimrc
"
" Motion for "next/last object". For example, "din(" would go to the next "()"
" pair and delete its contents.
onoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr>
xnoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr>
onoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr>
xnoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr>
onoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr>
xnoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr>
onoremap il :<c-u>call <SID>NextTextObject('i', 'F')<cr>
xnoremap il :<c-u>call <SID>NextTextObject('i', 'F')<cr>
function! s:NextTextObject(motion, dir)
let c = nr2char(getchar())
if c ==# "b"
let c = "("
elseif c ==# "B"
let c = "{"
elseif c ==# "d"
let c = "["
endif
exe "normal! ".a:dir.c."v".a:motion.c
endfunction
" }}}
" NeoComplete {{{
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Define dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'haskell' : $HOME.'/.haskell_completions'
\}
" }}}
" Configure vim maximize {{{
nnoremap <silent><F3> :MaximizerToggle<CR>
vnoremap <silent><F3> :MaximizerToggle<CR>gv
inoremap <silent><F3> <C-o>:MaximizerToggle<CR>
" }}}
" Easy Motion Config {{{
map <Leader>l <Plug>(easymotion-lineforward)
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
map <Leader>h <Plug>(easymotion-linebackward)
" Two character search
nmap <Leader>s <Plug>(easymotion-s2)
nmap <Leader>t <Plug>(easymotion-t2)
" }}}
" Because of fish shell configure bash as vim shell {{{
set shell=/bin/bash
" }}}
" {{{ TMUX
" Show vim file name in tmux window
autocmd BufReadPost,FileReadPost,BufNewFile,BufEnter * call system("tmux rename-window " . expand("%:t"))
" When closing vim rename again the tmux window to fish
autocmd VimLeave * call system("tmux rename-window fish")
" }}}