-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
1696 lines (1364 loc) · 53 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
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
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"
" __ _(_)_ __ ___ _ __ ___
" \ \ / / | '_ ` _ \| '__/ __|
" \ V /| | | | | | | | | (__
" (_)_/ |_|_| |_| |_|_| \___|
"
" Author: joe di castro <[email protected]>
" Source: http://github.com/joedicastro/dotfiles/tree/master/vim
"
" This file is under a lot of stress, it changes frequently, so it's better if
" you watch the DVCS commits to stay in the loop.
" Setup language {{{ ==========================================================
" language en_US.UTF-8 " Solve some plugins incompatibilities
" }}}
" NEOBUNDLE {{{ ===============================================================
set nocompatible " No to the total compatibility with the ancient vi
" NeoBundle auto-installation and setup {{{
" Auto installing NeoBundle
let iCanHazNeoBundle=1
let neobundle_readme=expand($HOME.'/.vim/bundle/neobundle.vim/README.md')
if !filereadable(neobundle_readme)
echo "Installing NeoBundle.."
echo ""
silent !mkdir -p $HOME/.vim/bundle
silent !git clone https://github.com/Shougo/neobundle.vim $HOME/.vim/bundle/neobundle.vim
let iCanHazNeoBundle=0
endif
" Call NeoBundle
if has('vim_starting')
set rtp+=$HOME/.vim/bundle/neobundle.vim/
endif
call neobundle#rc(expand($HOME.'/.vim/bundle/'))
" is better if NeoBundle rules NeoBundle (needed!)
NeoBundle 'Shougo/neobundle.vim'
" }}}
" BUNDLES (plugins administrated by NeoBundle) {{{
" Shougo's way {{{
" Vimproc to asynchronously run commands (NeoBundle, Unite)
NeoBundle 'Shougo/vimproc', {
\ 'build' : {
\ 'windows' : 'make -f make_mingw32.mak',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'unix' : 'make -f make_unix.mak',
\ },
\ }
" Unite. The interface to rule almost everything
NeoBundle 'Shougo/unite.vim'
" Unite sources
NeoBundleLazy 'Shougo/unite-outline', {'autoload':{'unite_sources':'outline'}}
NeoBundleLazy 'tsukkee/unite-help', {'autoload':{'unite_sources':'help'}}
NeoBundleLazy 'ujihisa/unite-colorscheme', {'autoload':{'unite_sources':
\ 'colorscheme'}}
NeoBundleLazy 'ujihisa/unite-locate', {'autoload':{'unite_sources':'locate'}}
NeoBundleLazy 'thinca/vim-unite-history', { 'autoload' : { 'unite_sources' :
\ ['history/command', 'history/search']}}
NeoBundleLazy 'osyo-manga/unite-filetype', { 'autoload' : {'unite_sources' :
\ 'filetype', }}
NeoBundleLazy 'osyo-manga/unite-quickfix', {'autoload':{'unite_sources':
\ ['quickfix', 'location_list']}}
NeoBundleLazy 'osyo-manga/unite-fold', {'autoload':{'unite_sources':'fold'}}
NeoBundleLazy 'tacroe/unite-mark', {'autoload':{'unite_sources':'mark'}}
" File explorer (needed where ranger is not available)
NeoBundleLazy 'Shougo/vimfiler', {'autoload' : { 'commands' : ['VimFiler']}}
" Junk files
NeoBundleLazy 'Shougo/junkfile.vim', {'autoload':{'commands':'JunkfileOpen',
\ 'unite_sources':['junkfile','junkfile/new']}}
" }}}
" Colorschemes {{{
" Dark themes
" Improved terminal version of molokai, almost identical to the GUI one
NeoBundle 'joedicastro/vim-molokai256'
NeoBundle 'tomasr/molokai'
NeoBundleLazy 'sjl/badwolf', { 'autoload' :
\ { 'unite_sources' : 'colorscheme', }}
NeoBundleLazy 'nielsmadan/harlequin', { 'autoload' :
\ { 'unite_sources' : 'colorscheme', }}
" Light themes
NeoBundleLazy 'vim-scripts/summerfruit256.vim', { 'autoload' :
\ { 'unite_sources' : 'colorscheme', }}
NeoBundleLazy 'joedicastro/vim-github256', { 'autoload' :
\ { 'unite_sources' : 'colorscheme', }}
" Make terminal themes from GUI themes
NeoBundleLazy 'godlygeek/csapprox', { 'autoload' :
\ { 'commands' : ['CSApprox', 'CSApproxSnapshot']}}
" }}}
" DCVS {{{
"
" Admin Git
NeoBundle 'tpope/vim-fugitive'
" Show git repository changes in the current file
NeoBundle 'airblade/vim-gitgutter'
" Git viewer
NeoBundleLazy 'gregsexton/gitv', {'depends':['tpope/vim-fugitive'],
\ 'autoload':{'commands':'Gitv'}}
" Browse GitHub events in Vim
NeoBundle 'joedicastro/vim-github-dashboard'
" }}}
" Markdown {{{
" Markdown Syntax
NeoBundleLazy 'joedicastro/vim-markdown'
" Makes a Markdown Extra preview into the browser
NeoBundleLazy 'joedicastro/vim-markdown-extra-preview'
" }}}
" Linux tools {{{
" A diff tool for directories
NeoBundleLazy 'joedicastro/DirDiff.vim', { 'autoload': { 'commands' : 'DirDiff'}}
" Hexadecimal editor
NeoBundle 'Shougo/vinarise.vim'
" }}}
" Python {{{
" Autocompletion
NeoBundle 'Shougo/neocomplete.vim'
" A Python plugin
NeoBundleLazy 'klen/python-mode', {'autoload': {'filetypes': ['python']}}
" Admin virtualenvs
NeoBundle 'jmcantrell/vim-virtualenv'
" Show indent lines
NeoBundleLazy 'Yggdroot/indentLine', {'autoload': {'filetypes': ['python']}}
" Show reports from coverage.py
NeoBundleLazy 'alfredodeza/coveragepy.vim', {'autoload': {'filetypes': ['python']}}
" Sort imports
NeoBundle 'fisadev/vim-isort', {'autoload': {'filetypes': ['python']}}
" }}}
" Code Snippets {{{
" Powerful and advanced Snippets tool
NeoBundle 'SirVer/ultisnips'
" }}}
" Syntax {{{
NeoBundleLazy 'vim-scripts/JSON.vim', {'autoload': {'filetypes': ['json']}}
NeoBundleLazy 'vim-scripts/po.vim--gray', {'autoload': {'filetypes': ['po']}}
NeoBundleLazy 'joedicastro/vim-pentadactyl', {
\ 'autoload': {'filetypes': ['pentadactyl']}}
NeoBundle 'scrooloose/syntastic'
" }}}
" Open external links {{{
" Open a url into the browser or another files with an external app
NeoBundle 'vim-scripts/utl.vim'
" }}}
" Text edition {{{
" Autocompletion of (, [, {, ', ", ...
NeoBundle 'delimitMate.vim'
" Smart and fast date changer
NeoBundle 'tpope/vim-speeddating'
" to surround vim objects with a pair of identical chars
NeoBundle 'tpope/vim-surround'
" extend repetitions by the 'dot' key
NeoBundle 'tpope/vim-repeat'
" toggle comments
NeoBundle 'tpope/vim-commentary'
" smart digraphs insertion
NeoBundle 'Rykka/easydigraph.vim'
" browse the vim undo tree
NeoBundleLazy 'sjl/gundo.vim', { 'autoload' : {'commands': 'GundoToggle'}}
" to insert lorem ipsum blocks
NeoBundleLazy 'vim-scripts/loremipsum', { 'autoload' :
\ { 'commands' : 'Loremipsum'}}
" reveals all the character info, Unicode included
NeoBundle 'tpope/vim-characterize'
" transpose lines and text blocks
NeoBundleLazy 'salsifis/vim-transpose', { 'autoload' :
\ { 'commands' : 'Transpose'}}
" marks admin
NeoBundle 'kshenoy/vim-signature'
" text-objects
NeoBundle 'kana/vim-textobj-entire' " ae, ie
NeoBundle 'kana/vim-textobj-indent' " ai, ii, aI, iI
NeoBundle 'kana/vim-textobj-lastpat' " a/, i/, a?, i?
NeoBundle 'kana/vim-textobj-line' " al, il
NeoBundle 'kana/vim-textobj-underscore' " a_, i_
NeoBundle 'kana/vim-textobj-user'
" multiple cursors
NeoBundle 'terryma/vim-multiple-cursors'
" }}}
" HTML/CSS {{{
" A smart and powerful Color Management tool. Needs to be loaded to be able
" to use the mappings
NeoBundleLazy 'Rykka/colorv.vim', {'autoload' : {
\ 'commands' : [
\ 'ColorV', 'ColorVView', 'ColorVPreview',
\ 'ColorVPicker', 'ColorVEdit', 'ColorVEditAll',
\ 'ColorVInsert', 'ColorVList', 'ColorVName',
\ 'ColorVScheme', 'ColorVSchemeFav',
\ 'ColorVSchemeNew', 'ColorVTurn2'],
\ }}
NeoBundleLazy 'othree/html5.vim', {'autoload':
\ {'filetypes': ['html', 'xhttml', 'css']}}
NeoBundleLazy 'mattn/emmet-vim', {'autoload':
\ {'filetypes': ['html', 'xhttml', 'css', 'xml', 'xls', 'markdown']}}
NeoBundle 'kchmck/vim-coffee-script',{'autoload' : {
\ 'commands' : [
\ 'CoffeeCompile', 'CoffeeLint', 'CoffeeMake',
\ 'CoffeeRun', 'CoffeeWatch'],
\ 'filetypes' : ['coffee']
\ }}
" }}}
" GUI {{{
" A better looking status line
NeoBundle 'bling/vim-airline'
" Zooms a window
NeoBundleLazy 'vim-scripts/zoomwintab.vim', {'autoload' :
\{'commands' : 'ZoomWinTabToggle'}}
" easily window resizing
NeoBundle 'jimsei/winresizer'
" }}}
" Tmux {{{
" Easily interacts with Tmux from Vim
NeoBundle 'benmills/vimux'
" Tmux config file syntax
NeoBundleLazy 'vimez/vim-tmux', { 'autoload' : { 'filetypes' : 'conf'}}
" }}}
" API Web {{{
NeoBundle 'mattn/webapi-vim'
" }}}
" END BUNDLES }}}
" Auto install the plugins {{{
" First-time plugins installation
if iCanHazNeoBundle == 0
echo "Installing Bundles, please ignore key map error messages"
echo ""
:NeoBundleInstall
endif
" Check if all of the plugins are already installed, in other case ask if we
" want to install them (useful to add plugins in the .vimrc)
NeoBundleCheck
" }}}
filetype plugin indent on " Indent and plugins by filetype
" END NEOBUNDLE }}}
" VIM Setup {{{ ===============================================================
" <Leader> & <LocalLeader> mapping {{{
let mapleader=','
let maplocalleader= ' '
" }}}
" Basic options {{{
scriptencoding utf-8
set encoding=utf-8 " setup the encoding to UTF-8
set ls=2 " status line always visible
set go-=T " hide the toolbar
set go-=m " hide the menu
" The next two lines are quite tricky, but in Gvim, if you don't do this, if you
" only hide all the scrollbars, the vertical scrollbar is showed anyway
set go+=rRlLbh " show all the scrollbars
set go-=rRlLbh " hide all the scrollbars
set visualbell " turn on the visual bell
set cursorline " highlight the line under the cursor
set fillchars+=vert:│ " better looking for windows separator
set ttyfast " better screen redraw
set title " set the terminal title to the current file
set showcmd " shows partial commands
set hidden " hide the inactive buffers
set ruler " sets a permanent rule
set lazyredraw " only redraws if it is needed
set autoread " update a open file edited outside of Vim
set ttimeoutlen=0 " toggle between modes almost instantly
set backspace=indent,eol,start " defines the backspace key behavior
set virtualedit=all " to edit where there is no actual character
" }}}
" Searching {{{
set incsearch " incremental searching
set showmatch " show pairs match
set hlsearch " highlight search results
set smartcase " smart case ignore
set ignorecase " ignore case letters
" }}}
" History and permanent undo levels {{{
set history=1000
set undofile
set undoreload=1000
" }}}
" Make a dir if no exists {{{
function! MakeDirIfNoExists(path)
if !isdirectory(expand(a:path))
call mkdir(expand(a:path), "p")
endif
endfunction
" }}}
" Backups {{{
set backup
set noswapfile
set backupdir=$HOME/.vim/tmp/backup/
set undodir=$HOME/.vim/tmp/undo/
set directory=$HOME/.vim/tmp/swap/
set viminfo+=n$HOME/.vim/tmp/viminfo
" make this dirs if no exists previously
silent! call MakeDirIfNoExists(&undodir)
silent! call MakeDirIfNoExists(&backupdir)
silent! call MakeDirIfNoExists(&directory)
" }}}
" Wildmenu {{{
set wildmenu " Command line autocompletion
set wildmode=list:longest,full " Shows all the options
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.bak,*.?~,*.??~,*.???~,*.~ " Backup files
set wildignore+=*.luac " Lua byte code
set wildignore+=*.jar " java archives
set wildignore+=*.pyc " Python byte code
set wildignore+=*.stats " Pylint stats
" }}}
" Tabs, space and wrapping {{{
set expandtab " spaces instead of tabs
set tabstop=4 " a tab = four spaces
set shiftwidth=4 " number of spaces for auto-indent
set softtabstop=4 " a soft-tab of four spaces
set autoindent " set on the auto-indent
" set formatoptions=qrn1ct
set textwidth=80
set colorcolumn=81
function! ToggleWrap()
let s:nowrap_cc_bg = [22, '#005f00']
redir => s:curr_cc_hi
silent hi ColorColumn
redir END
let s:curr_cc_ctermbg = matchstr(s:curr_cc_hi, 'ctermbg=\zs.\{-}\s\ze\1')
let s:curr_cc_guibg = matchstr(s:curr_cc_hi, 'guibg=\zs.\{-}\_$\ze\1')
if s:curr_cc_ctermbg != s:nowrap_cc_bg[0]
let g:curr_cc_ctermbg = s:curr_cc_ctermbg
endif
if s:curr_cc_guibg != s:nowrap_cc_bg[1]
let g:curr_cc_guibg = s:curr_cc_guibg
endif
if &textwidth == 80
set textwidth=0
exec 'hi ColorColumn ctermbg='.s:nowrap_cc_bg[0].
\' guibg='.s:nowrap_cc_bg[1]
elseif &textwidth == 0
set textwidth=80
exec 'hi ColorColumn ctermbg='.g:curr_cc_ctermbg.
\' guibg='.g:curr_cc_guibg
endif
endfunction
nmap <silent><Leader>ew :call ToggleWrap()<CR>
" }}}
" Ok, a vim for men, get off the cursor keys {{{
"nnoremap <up> <nop>
"nnoremap <down> <nop>
"nnoremap <left> <nop>
"nnoremap <right> <nop>
"inoremap <up> <nop>
"inoremap <down> <nop>
"inoremap <left> <nop>
"inoremap <right> <nop>
" }}}
" Colorscheme {{{
syntax enable " enable the syntax highlight
set background=dark " set a dark background
set t_Co=256 " 256 colors for the terminal
if has('gui_running')
colorscheme molokai
else
colorscheme molokai256
endif
" }}}
" Font {{{
set guifont=Dejavu\ Sans\ Mono\ for\ Powerline\ 11
" }}}
" Resize the divisions if the Vim window size changes {{{
au VimResized * exe "normal! \<c-w>="
" }}}
" New windows {{{
nnoremap <Leader>v <C-w>v
nnoremap <Leader>h <C-w>s
" }}}
" Fast window moves {{{
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" }}}
" Fast window & buffer close and kill {{{
nnoremap <Leader>k <C-w>c
nnoremap <silent><Leader>K :bd<CR>
" }}}
" Toggle line numbers {{{
nnoremap <silent><Leader>l :call ToggleRelativeAbsoluteNumber()<CR>
function! ToggleRelativeAbsoluteNumber()
if !&number && !&relativenumber
set number
set norelativenumber
elseif &number && !&relativenumber
set nonumber
set relativenumber
elseif !&number && &relativenumber
set number
set relativenumber
elseif &number && &relativenumber
set nonumber
set norelativenumber
endif
endfunction
" }}}
" Show hidden chars {{{
nmap <Leader>eh :set list!<CR>
set listchars=tab:→\ ,eol:↵,trail:·,extends:↷,precedes:↶
" }}}
" Folding {{{
set foldmethod=marker
" Toggle folding
nnoremap \ za
vnoremap \ za
" }}}
" Cut/Paste {{{
" to/from the clipboard
map <Leader>y "*y
map <Leader>p "*p
" toggle paste mode
map <Leader>P :set invpaste<CR>
" }}}
" Autoload configuration when this file changes ($MYVIMRC) {{{
autocmd! BufWritePost vimrc source %
" }}}
" Spelling {{{
" turn on the spell checking and set the Spanish language
nmap <Leader>ss :setlocal spell spelllang=es<CR>
" turn on the spell checking and set the English language
nmap <Leader>se :setlocal spell spelllang=en<CR>
" turn off the spell checking
nmap <Leader>so :setlocal nospell <CR>
" jump to the next bad spell word
nmap <Leader>sn ]s
" suggest words
nmap <Leader>sp z=
" jump to the next bad spell word and suggests a correct one
nmap <Leader>sc ]sz=
" add word to the dictionary
nmap <Leader>sa zg
" }}}
" Save as root {{{
cmap w!! w !sudo tee % >/dev/null<CR>:e!<CR><CR>
" }}}
" Quick saving {{{
nmap <silent> <Leader>w :update<CR>
" }}}
" Delete trailing whitespaces {{{
nmap <silent><Leader>et :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
" }}}
" Use Ranger as a file explorer {{{
fun! RangerChooser()
exec "silent !ranger --choosefile=/tmp/chosenfile " . expand("%:p:h")
if filereadable('/tmp/chosenfile')
exec 'edit ' . system('cat /tmp/chosenfile')
call system('rm /tmp/chosenfile')
endif
redraw!
endfun
map <Leader>x :call RangerChooser()<CR>
" }}}
" Toggle the Quickfix window {{{
function! s:QuickfixToggle()
for i in range(1, winnr('$'))
let bnum = winbufnr(i)
if getbufvar(bnum, '&buftype') == 'quickfix'
cclose
lclose
return
endif
endfor
copen
endfunction
command! ToggleQuickfix call <SID>QuickfixToggle()
nnoremap <silent> <Leader>q :ToggleQuickfix<CR>
" }}}
" Text statistics {{{
" get the total of lines, words, chars and bytes (and for the current position)
map <Leader>es g<C-G>
" get the word frequency in the text
function! WordFrequency() range
let all = split(join(getline(a:firstline, a:lastline)), '\A\+')
let frequencies = {}
for word in all
let frequencies[word] = get(frequencies, word, 0) + 1
endfor
let lst = []
for [key,value] in items(frequencies)
call add(lst, value."\t".key."\n")
endfor
call sort(lst)
echo join(lst)
endfunction
command! -range=% WordFrequency <line1>,<line2>call WordFrequency()
map <Leader>ef :Unite output:WordFrequency<CR>
" }}}
" Count lines of code {{{
function! LinesOfCode()
echo system('cloc --quiet '.bufname("%"))
endfunction
"}}}
" Toggle the search results highlighting {{{
map <silent><Leader>eq :set invhlsearch<CR>
" }}}
" Quick exiting without save {{{
nnoremap <Leader>`` :qa!<CR>
" }}}
" Execution permissions by default to shebang (#!) files {{{
augroup shebang_chmod
autocmd!
autocmd BufNewFile * let b:brand_new_file = 1
autocmd BufWritePost * unlet! b:brand_new_file
autocmd BufWritePre *
\ if exists('b:brand_new_file') |
\ if getline(1) =~ '^#!' |
\ let b:chmod_post = '+x' |
\ endif |
\ endif
autocmd BufWritePost,FileWritePost *
\ if exists('b:chmod_post') && executable('chmod') |
\ silent! execute '!chmod '.b:chmod_post.' "<afile>"' |
\ unlet b:chmod_post |
\ endif
augroup END
" }}}
" Load matchit by default {{{
if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
runtime! macros/matchit.vim
endif
" }}}
" Make the Y behavior similar to D & C {{{
nnoremap Y y$
" }}}
" END VIM SETUP }}}
" PLUGINS Setup {{{ ===========================================================
" Airline {{{
set noshowmode
let g:airline_theme='powerlineish'
let g:airline_enable_branch=1
let g:airline_powerline_fonts=1
let g:airline_detect_whitespace = 1
let g:airline#extensions#hunks#non_zero_only = 1
" let g:airline#extensions#tabline#enabled = 2
" let g:airline#extensions#tabline#fnamemod = ':t'
" let g:airline#extensions#tabline#buffer_min_count = 1
" }}}
" CoffeeScript {{{
map <Leader>rw :CoffeeWatch vert<CR>
" }}}
" ColorV {{{
let g:colorv_cache_file=$HOME.'/.vim/tmp/vim_colorv_cache'
let g:colorv_cache_fav=$HOME.'/.vim/tmp/vim_colorv_cache_fav'
" }}}
" Commentary {{{ -------------------------------------------------------------
nmap <Leader>c <Plug>CommentaryLine
xmap <Leader>c <Plug>Commentary
augroup plugin_commentary
au!
au FileType python setlocal commentstring=#%s
au FileType htmldjango setlocal commentstring={#\ %s\ #}
au FileType puppet setlocal commentstring=#\ %s
augroup END
" }}}
" delimitmate {{{
let delimitMate_expand_space = 1
" }}}
" easydigraph {{{
let g:EasyDigraph_nmap = '<Leader>dd'
" }}}
" Fugitive {{{
nnoremap <Leader>gn :Unite output:echo\ system("git\ init")<CR>
nnoremap <Leader>gs :Gstatus<CR>
nnoremap <Leader>gw :Gwrite<CR>
nnoremap <Leader>go :Gread<CR>
nnoremap <Leader>gR :Gremove<CR>
nnoremap <Leader>gm :Gmove<Space>
nnoremap <Leader>gc :Gcommit<CR>
nnoremap <Leader>gd :Gdiff<CR>
nnoremap <Leader>gb :Gblame<CR>
nnoremap <Leader>gB :Gbrowse<CR>
nnoremap <Leader>gp :Git! push<CR>
nnoremap <Leader>gP :Git! pull<CR>
nnoremap <Leader>gi :Git!<Space>
nnoremap <Leader>ge :Gedit<CR>
nnoremap <Leader>gE :Gedit<Space>
nnoremap <Leader>gl :exe "silent Glog <Bar> Unite -no-quit
\ quickfix"<CR>:redraw!<CR>
nnoremap <Leader>gL :exe "silent Glog -- <Bar> Unite -no-quit
\ quickfix"<CR>:redraw!<CR>
nnoremap <Leader>gt :!tig<CR>:redraw!<CR>
nnoremap <Leader>gS :exe "silent !shipit"<CR>:redraw!<CR>
nnoremap <Leader>gg :exe 'silent Ggrep -i '.input("Pattern: ")<Bar>Unite
\ quickfix -no-quit<CR>
nnoremap <Leader>ggm :exe 'silent Glog --grep='.input("Pattern: ").' <Bar>
\Unite -no-quit quickfix'<CR>
nnoremap <Leader>ggt :exe 'silent Glog -S='.input("Pattern: ").' <Bar>
\Unite -no-quit quickfix'<CR>
nnoremap <Leader>ggc :silent! Ggrep -i<Space>
" for the diffmode
noremap <Leader>du :diffupdate<CR>
if !exists(":Gdiffoff")
command Gdiffoff diffoff | q | Gedit
endif
noremap <Leader>dq :Gdiffoff<CR>
" }}}
" Gitv {{{
nnoremap <silent> <leader>gv :Gitv --all<CR>
nnoremap <silent> <leader>gV :Gitv! --all<CR>
vnoremap <silent> <leader>gV :Gitv! --all<CR>
let g:Gitv_OpenHorizontal = 'auto'
let g:Gitv_WipeAllOnClose = 1
let g:Gitv_DoNotMapCtrlKey = 1
" let g:Gitv_WrapLines = 1
autocmd FileType git set nofoldenable
" }}}
" GitHub dashboard {{{
nnoremap <Leader>gD :exe 'GHD! '.input("Username: ")<CR>
nnoremap <Leader>gA :exe 'GHA! '.input("Username or repository: ")<CR>
function! GHDashboard (...)
if &filetype == 'github-dashboard'
" first variable is the statusline builder
let builder = a:1
call builder.add_section('airline_a', 'GitHub ')
call builder.add_section('airline_b',
\ ' %{get(split(get(split(github_dashboard#statusline(), " "),
\ 1, ""), ":"), 0, "")} ')
call builder.add_section('airline_c',
\ ' %{get(split(get(split(github_dashboard#statusline(), " "),
\ 2, ""), "]"), 0, "")} ')
" tell the core to use the contents of the builder
return 1
endif
endfunction
autocmd FileType github-dashboard call airline#add_statusline_func('GHDashboard')
" }}}
" Gundo {{{ ------------------------------------------------------------------
nnoremap <Leader>u :GundoToggle<CR>
let g:gundo_preview_bottom = 1
" }}}
" indentLine {{{
map <silent> <Leader>L :IndentLinesToggle<CR>
let g:indentLine_enabled = 0
let g:indentLine_char = '┊'
let g:indentLine_color_term = 239
" }}}
" Neocomplete {{{
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#enable_auto_select = 1
let g:neocomplete#enable_refresh_always = 1
let g:neocomplete#max_list = 30
let g:neocomplete#min_keyword_length = 1
let g:neocomplete#sources#syntax#min_keyword_length = 1
let g:neocomplete#data_directory = $HOME.'/.vim/tmp/neocomplete'
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
let g:neocomplete#sources#omni#input_patterns.python='\h\w*\|[^. \t]\.\w*'
" }}}
" Po.vim {{{ -----------------------------------------------------------------
let g:po_translator = "joe di castro <[email protected]>"
" }}}
" PythonMode {{{ -------------------------------------------------------------
nmap <silent><Leader>n :PymodeLint<CR>
let g:pymode_breakpoint_bind = '<Leader>B'
let g:pymode_lint = 1
let g:pymode_lint_on_write = 1
let g:pymode_lint_checkers = ['pep8', 'mccabe', 'pep257']
let g:pymode_lint_ignore = ''
let g:pymode_virtualenv = 0
let g:pymode_rope = 0
let g:pymode_rope_completion = 0
let g:pymode_rope_complete_on_dot = 1
" }}}
" Syntastic {{{
nmap <silent><Leader>N :SyntasticCheck<CR>:Errors<CR>
let g:syntastic_python_pylint_exe = "pylint2"
let g:syntastic_mode_map = { 'mode': 'active',
\ 'active_filetypes': [],
\ 'passive_filetypes': ['python'] }
let g:syntastic_error_symbol='✗'
let g:syntastic_warning_symbol='⚠'
let g:syntastic_style_error_symbol = '⚡'
let g:syntastic_style_warning_symbol = '⚡'
" }}}
" Unite {{{
" files
nnoremap <silent><Leader>o :Unite -silent -start-insert file<CR>
nnoremap <silent><Leader>O :Unite -silent -start-insert file_rec/async<CR>
nnoremap <silent><Leader>m :Unite -silent file_mru<CR>
" buffers
nnoremap <silent><Leader>b :Unite -silent buffer<CR>
" tabs
nnoremap <silent><Leader>B :Unite -silent tab<CR>
" buffer search
nnoremap <silent><Leader>f :Unite -silent -no-split -start-insert -auto-preview
\ line<CR>
nnoremap <silent>[menu]8 :UniteWithCursorWord -silent -no-split -auto-preview
\ line<CR>
" yankring
nnoremap <silent><Leader>i :Unite -silent history/yank<CR>
" grep
nnoremap <silent><Leader>a :Unite -silent -no-quit grep<CR>
" help
nnoremap <silent> g<C-h> :UniteWithCursorWord -silent help<CR>
" tasks
nnoremap <silent><Leader>; :Unite -silent -toggle
\ grep:%::FIXME\|TODO\|NOTE\|XXX\|COMBAK\|@todo<CR>
" outlines (also ctags)
nnoremap <silent><Leader>t :Unite -silent -vertical -winwidth=40
\ -direction=topleft -toggle outline<CR>
" junk files
nnoremap <silent><Leader>d :Unite -silent junkfile/new junkfile<CR>
" menus {{{
let g:unite_source_menu_menus = {}
" menu prefix key (for all Unite menus) {{{
nnoremap [menu] <Nop>
nmap <LocalLeader> [menu]
" }}}
" menus menu
nnoremap <silent>[menu]u :Unite -silent -winheight=20 menu<CR>
" files and dirs menu {{{
let g:unite_source_menu_menus.files = {
\ 'description' : ' files & dirs
\ ⌘ [space]o',
\}
let g:unite_source_menu_menus.files.command_candidates = [
\['▷ open file ⌘ ,o',
\'Unite -start-insert file'],
\['▷ open more recently used files ⌘ ,m',
\'Unite file_mru'],
\['▷ open file with recursive search ⌘ ,O',
\'Unite -start-insert file_rec/async'],
\['▷ edit new file',
\'Unite file/new'],
\['▷ search directory',
\'Unite directory'],
\['▷ search recently used directories',
\'Unite directory_mru'],
\['▷ search directory with recursive search',
\'Unite directory_rec/async'],
\['▷ make new directory',
\'Unite directory/new'],
\['▷ change working directory',
\'Unite -default-action=lcd directory'],
\['▷ know current working directory',
\'Unite output:pwd'],
\['▷ junk files ⌘ ,d',
\'Unite junkfile/new junkfile'],
\['▷ save as root ⌘ :w!!',
\'exe "write !sudo tee % >/dev/null"'],
\['▷ quick save ⌘ ,w',
\'normal ,w'],
\['▷ open ranger ⌘ ,x',
\'call RangerChooser()'],
\['▷ open vimfiler ⌘ ,X',
\'VimFiler'],
\]