-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvimrc
More file actions
1459 lines (1265 loc) · 49.6 KB
/
vimrc
File metadata and controls
1459 lines (1265 loc) · 49.6 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
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
" vim: set foldmarker={{{,}}} foldlevel=0 foldmethod=marker tabstop=4 shiftwidth=4:
" Environment {{{
set nocompatible " must be first line
set ttyfast " we have a fast tty
" }}}
" Plugins {{{
call plug#begin('~/.vim/plugged')
" General {{{
Plug 'itchyny/lightline.vim'
Plug 'unimpaired.vim'
Plug 'lastpos.vim'
"Plug 'sudo.vim' " eunuch has same functionality
"Plug 'vimshell-ssh'
" Plug 'ctrlpvim/ctrlp.vim' | Plug 'FelikZ/ctrlp-py-matcher'
" Plug 'EasyGrep'
"Plug 'hexman.vim'
"Plug 'taglist.vim'
Plug 'tpope/vim-repeat'
" Plug 'mileszs/ack.vim'
Plug 'Rykka/lastbuf.vim'
Plug 'bogado/file-line'
Plug 'arecarn/crunch' | Plug 'arecarn/selection.vim'
Plug 'gioele/vim-autoswap'
Plug 'VisIncr'
Plug 'majutsushi/tagbar'
" Plug 'EasyMotion'
Plug 'AndrewRadev/sideways.vim'
Plug 'AndrewRadev/switch.vim'
Plug 'tpope/vim-eunuch'
Plug 'aklt/vim-substitute'
"Plug 'myusuf3/numbers.vim'
Plug 'mbbill/undotree'
" Plug 'ledger/vim-ledger'
Plug 'vim-scripts/LanguageTool', { 'for': 'txt' }
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'plasticboy/vim-markdown'
Plug 'lervag/vimtex'
Plug 'neomake/neomake'
" Plug 'ctrlpvim/ctrlp.vim' | Plug 'FelikZ/ctrlp-py-matcher'
Plug 'Shougo/vimproc.vim', {'do' : 'make'}
Plug 'Shougo/unite.vim' | Plug 'Shougo/neomru.vim'
Plug 'Shougo/vimfiler.vim'
" }}}
" UI {{{
Plug 'altercation/vim-colors-solarized'
Plug 'bufkill.vim'
" Plug 'junegunn/limelight.vim', { 'for': ['txt', 'tex'] }
" }}}
" Programming {{{
Plug 'godlygeek/tabular', { 'on': 'Tabularize' }
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-dispatch'
" Plug 'skywind3000/asyncrun.vim'
Plug 'Keithbsmiley/investigate.vim'
Plug 'vim-json-bundle', { 'for': ['json','js'] }
Plug 'pangloss/vim-javascript', { 'for': 'js' }
Plug 'rhysd/vim-crystal', { 'for': 'crystal' }
" Snippets
Plug 'tomtom/tlib_vim'
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'sirver/UltiSnips' | Plug 'honza/vim-snippets'
" Ruby
Plug 'vim-ruby/vim-ruby'
Plug 'ecomba/vim-ruby-refactoring'
Plug 'splitjoin.vim'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-haml', { 'for': 'haml' }
Plug 'tpope/vim-rake'
Plug 'thoughtbot/vim-rspec'
Plug 'henrik/vim-ruby-runner'
" Plug 'cwood/vim-django'
" Elixir
Plug 'elixir-editors/vim-elixir'
" ES6
Plug 'isRuslan/vim-es6'
" }}}
" Textobjects {{{
Plug 'wellle/targets.vim'
" r
" Plug 'textobj-rubyblock' | Plug 'textobj-user'
" f
" i/I
" Plug 'textobj-indent'
" z
" Plug 'textobj-fold'
"}}}
call plug#end()
" }}}
" General {{{
" Set filetype stuff to on
filetype on
filetype plugin on
filetype indent on
set ffs=unix ",dos " sets line end to UNIX
set sh=zsh " Set shell
syntax on " Switch on syntax highlighting.
" Make the 'cw' and like commands put a $ at the end instead of just deleting
" the text and replacing it
set cpoptions+=c$
set history=1000 " Keep some stuff in the history
set mousehide " Hide the mouse pointer while typing
set autowrite " e.g. before :make
set noautochdir " auto change dir of file
set autoread
set vb " set visual bell -- i hate that damned beeping
" Allow the cursor to go in to "invalid" places
set virtualedit=all
" Disable encryption (:X)
" set key=
" set the forward slash to be the slash of note. No backslashes
set shellslash
" Numberformat to use, unsetting bascially only allows decimal
" octal and hex may make trouble if tried to increment/decrement
" certain numberformats
" (e.g. 007 will be incremented to 010, because vim thinks its octal)
set nrformats=
set hidden " allow buffer switching without saving
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" Add ignorance of whitespace to diff
"set diffopt+=iwhite
set diffopt+=vertical
" These things start comment lines
set comments=sl:/*,mb:\ *,ex:\ */,O://,b:#,:%,:XCOMM,n:>,fb:-
" Same as default except that I remove the 'u' option
set complete=.,w,b,t,i,kspell
set completeopt=menu,preview
" When completing by tag, show the whole tag, not just the function name
set showfulltag
" set clipboard=unnamed
set splitright
set splitbelow
" get rid of the silly characters in window separators
set fillchars=""
" Don't reset cursor to start of line when moving around.
set nostartofline
" Search {{{
set nohlsearch " Enable search highlighting
set incsearch " Incrementally match the search
set wrapscan " set the search scan to wrap lines
set ignorecase
if executable("rg")
set grepprg=rg\ -S
endif
" }}}
" Insert only one space when joining lines that contain sentence-terminating
" punctuation like `.`.
set nojoinspaces
" For regular expressions turn magic on
set magic
" encodings {{{
" set Unicode if possible
" First, check that the necessary capabilities are compiled-in
if has("multi_byte")
" (optional) remember the locale set by the OS
let g:locale_encoding = &encoding
" if already Unicode, no need to change it
" we assume that an encoding name is a Unicode one
" if its name starts with u or U
if &encoding !~? '^u'
" avoid clobbering the keyboard's charset
if &termencoding == ""
let &termencoding = &encoding
endif
" now we're ready to set UTF-8
set encoding=utf-8
endif
endif
" }}}
" Could use * rather than *.*, but I prefer to leave .files unsaved
" au BufWinLeave *.* silent! mkview "make vim save view (state) (folds, cursor, etc)
" au BufWinEnter *.* silent! loadview "make vim load view (state) (folds, cursor, etc)
" Backup {{{
" Save your backups to a less annoying place than the current directory.
" If you have .vim-backup in the current directory, it'll use that.
" Otherwise it saves it to ~/.vim/backup or . if all else fails.
if isdirectory($HOME . '/.vim/.tmp/backup') == 0
:silent !mkdir -p ~/.vim/.tmp/backup >/dev/null 2>&1
endif
set backupdir=~/.vim/.tmp/backup/
set backupdir+=~/.vim/backup/
set backupdir+=~/.vim/tmp/
set backupdir+=.
set backup
" Prevent backups from overwriting each other. The naming is weird,
" since I'm using the 'backupext' variable to append the path.
" So the file '/home/docwhat/.vimrc' becomes '.vimrc%home%docwhat~'
if has("autocmd")
autocmd BufWritePre * let &backupext = substitute(expand('%:p:h'), '/', '%', 'g') . '~'
endif
" }}}
" Swap {{{
" Save your swp files to a less annoying place than the current directory.
" If you have .vim-swap in the current directory, it'll use that.
" Otherwise it saves it to ~/.vim/swap, ~/tmp or .
if isdirectory($HOME . '/.vim/.tmp/swap') == 0
:silent !mkdir -p ~/.vim/.tmp/swap >/dev/null 2>&1
endif
set directory=./.vim-swap//
set directory+=~/.vim/.tmp/swap//
set directory+=~/.vim/swap//
set directory+=.
" }}}
" Session {{{
" viminfo stores the state of your previous editing session
set sessionoptions=blank,curdir,folds,help,tabpages,winpos
" +--Disable hlsearch while loading viminfo
" | +--Remember marks for last 500 files
" | | +--Remember up to 10000 lines in each register
" | | | +--Remember up to 1MB in each register
" | | | | +--Remember last 1000 search patterns
" | | | | | +---Remember last 1000 commands
" | | | | | |
" v v v v v v
" set viminfo=h,'500,<10000,s1000,/1000,:1000
" set viminfo+=n~/.vim/.tmp/viminfo
" }}}
" View {{{
set viewdir=~/.vim/.tmp/view
" }}}
" Undo {{{
if has('persistent_undo')
set undofile "so is persistent undo ...
set undolevels=1000 "maximum number of changes that can be undone
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
endif
if exists("+undofile")
" undofile - This allows you to use undos after exiting and restarting
" This, like swap and backups, uses .vim-undo first, then ~/.vim/undo
" :help undo-persistence
" This is only present in 7.3+
if isdirectory($HOME . '/.vim/.tmp/undo') == 0
:silent !mkdir -p ~/.vim/.tmp/undo > /dev/null 2>&1
endif
set undodir=./.vim-undo//
set undodir+=~/.vim/.tmp/undo//
set undodir+=~/.vim/undo//
set undofile
endif
" }}}
" }}}
" Vim UI {{{
set nu
set rnu
" set relativenumber
" solarized {{{
hi IndentGuidesOdd ctermbg=black
hi IndentGuidesEven ctermbg=darkgrey
"hi IndentGuidesOdd ctermbg=white
"hi IndentGuidesEven ctermbg=lightgrey
"color xoria256
set background=dark
" colorscheme railscasts
let g:solarized_termtrans=0
let g:solarized_termcolors=256
let g:solarized_contrast="high"
let g:solarized_visibility="normal"
let g:solarized_italic=1
let g:solarized_bold=1
let g:solarized_diffmode="high"
let g:solarized_hitrail=1
let g:solarized_underline=0
set t_Co=256
colorscheme solarized
" }}}
set showmode " Show the current mode
" set showbreak=↪
" highlight {{{
" highlight matching parens:
" Default for matchpairs: (:),[:],{{{:}}},<:>
set matchpairs+=<:>
set matchpairs+={:}
highlight MatchParen term=reverse ctermbg=7 guibg=cornsilk
hi MatchParen cterm=NONE ctermfg=black ctermbg=white
" I like it when the matching parens are automatically highlighted
let loaded_matchparen = 0
set matchtime=1
" Turn on: showmatching brackets in insert mode only!!
set noshowmatch
" }}}
" tell VIM to always put a status line in, even if there is only one window
set laststatus=2
set ch=2 " Make command line two lines high
set cursorline
set colorcolumn=80
set hidden " allow buffer switching without saving
set wildmenu " Make the command-line completion better
set wildmode=longest,list:longest " command <Tab> completion, list matches, then longest common part, then all.
set wildignore=*.o,*.obj,*~,*.swp
" Ignore case on insert completion
set infercase
set lazyredraw " Don't update the display while executing macros
set updatecount=10 "Save buffer every 10 chars typed
set winminheight=0 " windows can be 0 line high
" Syntax coloring lines that are too long just slows down the world
set synmaxcol=300
set list
set listchars=tab:▸\ ,trail:·,extends:#,nbsp:· ",eol:¬ " Highlight problematic whitespace: ﹁
set scrolloff=8 " minimum lines to keep above and below cursor
set scrolljump=5 " lines to scroll when cursor leaves screen
" Prevent Vim from clobbering the scrollback buffer. See
" http://www.shallowsky.com/linux/noaltscreen.html
set t_ti= t_te=
if has('cmdline_info')
"set ruler " show the ruler
"set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " a ruler on steroids
set showcmd " show partial commands in status line and
" selected characters/lines in visual mode
endif
" timeouts {{{
" This is the timeout used while waiting for user input on a multi-keyed macro
" or while just sitting and waiting for another key to be pressed measured
" in milliseconds.
"
" i.e. for the ",d" command, there is a "timeoutlen" wait period between the
" "," key and the "d" key. If the "d" key isn't pressed before the
" timeout expires, one of two things happens: The "," command is executed
" if there is one (which there isn't) or the command aborts.
"set timeoutlen=500
" Tweak timeouts, because the default is too conservative
" This setting is taken from :h 'ttimeoutlen'
"set timeout timeoutlen=500 ttimeoutlen=100
" Improve the speed for updating the status line when leaving insert mode.
set timeout
set ttimeoutlen=10
augroup FastEscape
autocmd!
set timeoutlen=400 ttimeoutlen=100
au InsertEnter * set timeoutlen=0
au InsertLeave * set timeoutlen=1000
au InsertLeave * set timeout timeoutlen=400 ttimeoutlen=100
augroup END
" }}}
" folding {{{
" These commands open folds
set foldmethod=syntax " folding by syntax
"set foldclose=all " if curser out of fold, then close
set foldcolumn=2 " set the column of the left side
"set nofoldenable " folding isn't enabled
"set foldmethod=marker " Fold on the marker
set nofoldenable " Turn folding off
set foldlevel=30 " Don't autofold anything (but I can still fold manually)
"set foldopen=block,insert,jump,mark,percent,quickfix,search,tag,undo,hor
set foldopen=block,jump,mark,percent,quickfix,search,tag,undo,hor
set foldtext=MyFoldLabel()
" }}}
" Don't show the intro message when starting vim.
set shortmess=atI
" }}}
" Formatting {{{
set textwidth=80 " Set the textwidth to be 80 chars (if 0: screen_width)
set wrapmargin=5
set formatoptions= " ta
set expandtab " Turn tabs into spaces
set shiftwidth=2 " use indents of 2 spaces
set tabstop=2
set softtabstop=2 " for backspace in insert-mod
set shiftround " When at 3 spaces and I hit >>, go to 4, not 5.
" Format text width the external programm "par" . Use "gq" for the external program; or use "gw" for internal program of vim
"set formatprg=par\ -re
set linebreak
set wrap " wrap long lines
set whichwrap=b,s,h,l,<,>,[,] " move freely between files
set autoindent " indent at the same level of the previous line
set copyindent
" Highlight VCS conflict markers
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
" }}}
" Key (re)Mappings {{{
let mapleader=","
" Use Caps-Lock as ESC key
exec "silent !xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'"
if filereadable(expand("~/.vim/mapping.vim"))
source ~/.vim/mapping.vim
endif
" }}}
" Plugins {{{
" Ctags {{{
set tags=./tags;/,~/.vimtags,./tags,tags
" }}}
" Fugitive {{{
fun! MyGstatus()
Gstatus | wincmd K | resize 15
endf
nnoremap <silent> <leader>gs :call MyGstatus()<CR>
nnoremap <silent> <leader>gd :Gdiff<CR>
fun! GdiffCached()
split | wincmd K | resize 15
Git! diff --cached
endf
command! GdiffCached call GdiffCached()
nnoremap <silent> <leader>gdc :call GdiffCached()<CR>
fun! Gadd()
silent !git add %
echo "Added to Git"
endf
command! Gadd call Gadd()
nnoremap <silent> <leader>ga :call Gadd()<CR>
nnoremap <silent> <leader>gi :Gcommit<CR>
nnoremap <leader>gC :update<cr>:Gcommit -am ""<left>
nnoremap <leader>gc :update<cr>:Gcommit -m ""<left>
nnoremap <silent> <leader>gb :Gblame<CR>
nnoremap <silent> <leader>gl :Glog<CR>
nnoremap <silent> <leader>gp :Git push<CR>:sleep 1<CR>
nnoremap <silent> <leader>gu :Git pull<CR>
"cmap Gbrowser Gbrowse | redraw!
"}}}
" TagBar {{{
nnoremap <silent> <leader>T :TagbarToggle<CR>
nnoremap <silent> <leader>tt :TagbarToggle<CR>
let g:tagbar_width = 30
let g:tagbar_sort = 0
let g:tagbar_compact = 1
"let g:tagbar_autoshowtag = 1
let g:tagbar_type_javascript = {}
"\ 'ctagstype' : 'javascript',
"\ 'ctagsbin' : '/usr/bin/jsctags'
"\ }
"}}}
" Substitute {{{
let g:substitute_PromptMap = "<leader>sw"
let g:substitute_NoPromptMap = "<leader>Sw"
"let g:substitute_GlobalMap = "<leader>sg"
"let g:substitute_SingleWordSize = 3
" }}}
" ATP {{{
"nmap :makelatex :MakeLatex
"nmap :viewoutput :ViewOutput
let g:atp_Python = "/usr/bin/python2"
let b:atp_Viewer = "evince"
" }}}
" Tabular {{{
"if exists(":Tabularize")
nmap <Leader>a= :Tabularize /=<CR>
vmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a: :Tabularize /:\zs<CR>
vmap <Leader>a: :Tabularize /:\zs<CR>
"endif
" }}}
" UndoTree {{{
nnoremap <silent> <Leader>u :UndotreeToggle<CR>
" If undotree is opened, it is likely one wants to interact with it.
let g:undotree_SetFocusWhenToggle=0
let g:undotree_DiffAutoOpen=0
let g:undotree_WindowLayout="4" " right
let g:undotree_SplitWidth=35
" }}}
" CtrlP {{{
"nnoremap <silent> <Leader>b :CtrlPBuffer<CR>
"nnoremap <silent> <Leader>m :CtrlPMRUFiles<CR>
"let g:ctrlp_map = '<leader>f'
"let g:ctrlp_show_hidden = 1 " show hidden files
"let g:ctrlp_max_height = 20 " height of file list
"let g:ctrlp_match_window_bottom = 0 " Show list on top
"let g:ctrlp_match_window_reversed = 0 " Go to bottom
"let g:ctrlp_match_func = { 'match': 'pymatcher#PyMatch' }
"let g:ctrlp_mruf_default_order = 1
"let g:ctrlp_by_filename = 0 " Search only by filename
"let g:ctrlp_max_files = 0 " unlimited files
"let g:ctrlp_max_depth = 20 " Max directory tree depth
"let g:ctrlp_switch_buffer = 0 " Allow opening multiple splits with same file via CtrlP
"let g:ctrlp_jump_to_buffer = 0
""for caching
"let g:ctrlp_use_caching = 0
"let g:ctrlp_clear_cache_on_exit = 0
"let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp'
"let g:ctrlp_lazy_update = 350 " Set delay to prevent extra search
"let g:ctrlp_custom_ignore = {
" \ 'dir': '\v[\/]\.(git|hg|svn|vendor)$',
" \ 'file': '\v\.(exe|so|dll)$',
" \ 'link': 'some_bad_symbolic_links',
" \ }
"let g:ctrlp_user_command = {
" \ 'fallback': 'ag %s -i --nocolor --nogroup --hidden
" \ --ignore out
" \ --ignore .git
" \ --ignore .svn
" \ --ignore .hg
" \ --ignore .DS_Store
" \ --ignore node_modules
" \ --ignore "**/*.pyc"
" \ --ignore .gitkeep
" \ -g ""'
" \ }
"" Don't let ctrlp change the working directory. Instead it now uses
"" the directory where vim was started. This fixes issues with some
"" projects that have nested git directories.
"let g:ctrlp_working_path_mode = 'r'
"let g:ctrlp_root_markers = ['README.md', 'README.txt']
" }}}
" Unite {{{
call unite#filters#matcher_default#use(['matcher_fuzzy'])
call unite#filters#sorter_default#use(['sorter_rank'])
" call unite#custom#profile('files', 'filters', ['sorter_rank'])
nnoremap <leader>a :<C-u>Unite grep -auto-preview -no-split -no-empty<CR>
nnoremap <leader>f :<C-u>Unite file_mru file/async file_rec/async -start-insert<CR>
nnoremap <leader>g :<C-u>Unite file_mru file/async file_rec/git -start-insert<CR>
nnoremap <leader>b :<C-u>Unite buffer -start-insert -no-split<CR>
nnoremap <leader>r :<C-u>UniteResume -start-insert -force-redraw<CR>
autocmd FileType unite nnoremap <silent> <buffer> <esc> :bd<CR>
let g:unite_redraw_hold_candidates = 50000
if executable('rg')
let g:unite_source_grep_command = 'rg'
let g:unite_source_grep_recursive_opt = ''
let g:unite_source_grep_default_opts = '-S --hidden --vimgrep --iglob .gitkeep --iglob *.orig'
elseif executable('ag')
let g:unite_source_grep_command = 'ag'
let g:unite_source_grep_default_opts = '--vimgrep'
let g:unite_source_grep_recursive_opt = ''
endif
" }}}
" VimFiler {{{
nnoremap <silent> <Leader>v :VimFilerExplorer<CR>
let g:vimfiler_safe_mode_by_default = 0
let g:vimfiler_as_default_explorer = 1
let g:vimfiler_tree_leaf_icon = ''
let g:vimfiler_tree_opened_icon = '▼'
let g:vimfiler_tree_closed_icon = '▻'
autocmd FileType vimfiler nmap <buffer> <C-l> :wincmd l<CR>
" }}}
" SnipMate {{{
" Shortcut for reloading snippets, useful when developing
au BufWritePost *.snippet call ReloadAllSnippets()
" }}}
" Unimpaired {{{
" Bubble single lines
" nmap <C-Up> [e
" nmap <C-Down> ]e
" Bubble multiple lines
" vmap <C-Up> [egv
" vmap <C-Down> ]egv
" Overwrite useless mapping for next/prev method
nmap [f [m
nmap 8f [m
nmap ]f ]m
nmap 9f ]m
" }}}
" Surround {{{
" via: http://whynotwiki.com/Vim
" via: https://github.com/skwp/dotfiles/blob/master/vim/plugin/settings/surround.vim
" Ruby
" Use v or # to get a variable interpolation (inside of a string)}
" ysiw# Wrap the token under the cursor in #{}
" v...s# Wrap the selection in #{}
au Filetype ruby let g:surround_113 = "#{\r}" " v
au Filetype ruby let g:surround_35 = "#{\r}" " #
" Select text in an ERb file with visual mode and then press s- or s=
" Or yss- to do entire line.
au Filetype erb let g:surround_45 = "<% \r %>" " -
au Filetype erb let g:surround_61 = "<%= \r %>" " =
" }}}
" SplitJoin {{{
nmap sj :SplitjoinSplit<cr>
nmap sk :SplitjoinJoin<cr>
" }}}
" LightLine {{{
let g:lightline = {
\ 'colorscheme': 'solarized',
\ 'mode_map': {
\ 'n': 'N ', 'i': 'I ', 'R': 'R ', 'v': 'V ',
\ 'V': 'VL', 'c': 'C ', "\<C-v>": 'VB', 's': 'S ',
\ 'S': 'SL', "\<C-s>": 'SB', 't': 'T ', '?': ' '
\ },
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'readonly' ], [ 'filename' ] ],
\ 'right': [ [ 'percent', 'lineinfo' ], [ 'fileencoding' ], [ 'sep', 'filetype' ] ]
\ },
\ 'tabline': {
\ 'left': [ [ 'tabs' ] ],
\ 'right': [ [ ] ]
\ },
\ 'component_function': {
\ 'sep': 'LightLineSeparator',
\ 'readonly': 'LightLineReadonly',
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename',
\ 'fileformat': 'LightLineFileformat',
\ 'filetype': 'LightLineFiletype',
\ 'fileencoding': 'LightLineFileencoding',
\ 'mode': 'LightLineMode',
\ },
\ 'separator': { 'left': "\u2b80", 'right': "\u2b82" },
\ 'subseparator': { 'left': "\u2b81", 'right': "\u2b83" }
\ }
function! LightLineSeparator()
return " "
endfunction
function! LightLineModified()
return &ft =~ 'help\|vimfiler\|gundo' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightLineReadonly()
return &ft !~? 'help\|vimfiler\|gundo' && &readonly ? '⭤' : ''
endfunction
function! LightLineFilename()
return (&ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ LightLinePath()) .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
endfunction
function! LightLinePath()
if '' != expand('%:p:.')
return winwidth(0) > 90 ? expand('%:p:.') : pathshorten(expand('%:p:.'))
else
return '[No Name]'
endif
endfunction
function! LightLineFugitive()
if &ft !~? 'vimfiler\|gundo' && exists("*fugitive#head")
let _ = fugitive#head()
return strlen(_) ? '⭠ '._ : ''
endif
return ''
endfunction
function! LightLineFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! LightLineFiletype()
return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : ''
endfunction
function! LightLineFileencoding()
return winwidth(0) > 70 ? (strlen(&fenc) ? &fenc : &enc) . '[' . &fileformat . ']' : ''
endfunction
function! LightLineMode()
return winwidth(0) > 60 ? lightline#mode() : ''
endfunction
" }}}
" Sideways {{{
nnoremap <leader>> :SidewaysRight<CR>
nnoremap <leader>< :SidewaysLeft<CR>
" }}}
" Switch {{{
nnoremap <silent> - :Switch<CR>
" }}}
" UltiSnips {{{
" Filename function, taken from snipMate.vim
let did_UltiSnips_snipmate_compatibility = 1
fun! Filename(...)
let filename = expand('%:t:r')
if filename == '' | return a:0 == 2 ? a:2 : '' | endif
return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g')
endf
" let g:UltiSnipsSnippetDirectories=["UltiSnips"]
let g:UltiSnips = {}
"let g:UltiSnips.always_use_first_snippet = 1
let g:UltiSnips.snipmate_ft_filter = {
\ 'default' : {'filetypes': ["FILETYPE", "_"] },
\ 'html' : {'filetypes': ["html", "javascript", "_"] },
\ 'javascript' : {'filetypes': ["javascript", "javascript.es6", "javascript-mocha"] },
\ 'cpp' : {'filetypes': [] },
\ }
let g:UltiSnips.UltiSnips_ft_filter = {
\ 'default' : {'filetypes': [] },
\ }
"" }}}
" Rooter {{{
let g:rooter_patterns = ['Gemfile', 'Rakefile', '.git/']
let g:rooter_use_lcd = 1
"autocmd BufEnter * :Rooter
" }}}
" Rails {{{
" autocmd User Rails cmap Rroutes edit config/routes.rb
autocmd User Rails silent! Lcd
autocmd User Rails command! Rstop call RailsServerStop()<CR>
nmap <f6> :Rrefresh<CR>
let g:rails_projections = {
\ "config/projections.json": {
\ "command": "projections"
\ },
\ "config/routes.rb": {
\ "command": "routes"
\ },
\ "config/locales/*.yml": {
\ "command": "locale"
\ },
\ "app/delayed_jobs/*_job.rb": {
\ "command": "job"
\ },
\ "app/forms/*_form.rb": {
\ "command": "form"
\ },
\ "app/serializers/*_serializer.rb": {
\ "command": "serializer"
\ },
\ "app/decorators/*_decorator.rb": {
\ "command": "decorator"
\ },
\ "db/seeds/*.rb": {
\ "command": "seeds"
\ },
\ "spec/features/*_spec.rb": {
\ "command": "feature",
\ "template": "require 'spec_helper'\n\nfeature '%h' do\n\nend",
\ }}
" }}}
" Ruby {{{
command! VA vsplit | A
let ruby_operators = 1
" }}}
" Dispatch {{{
" autocmd FileType ruby let b:dispatch = 'rspec %'
nnoremap <F9> :Dispatch<CR>
" }}}
" LastBuf {{{
" this option decides to reopen which level of hided buffer.
" :hid bufhidden (will always be reopened)
" :bun bufunload (will be reopened if level >= 1)
" :bd bufdelete (will be reopened if level >= 2)
" :bw bufwipeout (will never be reopened!CAUTION!!)
" default is 1 , means :bd and :bw not be reopened.
" if you want the same effect of 'nohidden'.
" set it to 0 and set 'nohidden'
let g:lastbuf_level=3
" }}}
" vim-rspec {{{
let g:rspec_command = "Dispatch rspec {spec}"
nnoremap <Leader>t :call RunCurrentSpecFile()<CR>
nnoremap <Leader>ts :call RunNearestSpec()<CR>
nnoremap <Leader>tl :call RunLastSpec()<CR>
" }}}
" Crunch {{{
map <silent> <plug>NoCrunchEvalLine <plug>CrunchEvalLine
command Calc Crunch
" }}}
" Investigate {{{
" unmap gK
nnoremap <silent> K :call investigate#Investigate()<CR>
" }}}
" Commentary {{{
autocmd FileType apache setlocal commentstring=#\ %s
autocmd FileType crontab setlocal commentstring=#\ %s
autocmd FileType gnuplot setlocal commentstring=#\ %s
autocmd FileType coffee setlocal commentstring=#\ %s
autocmd FileType nginx setlocal commentstring=#\ %s
autocmd FileType xdefaults setlocal commentstring=!\ %s
autocmd FileType conkyrc setlocal commentstring=--\ %s
" autocmd FileType php setlocal commentstring=//\ %s
" }}}
" VMath {{{
vmap <expr> ++ VMATH_YankAndAnalyse()
nmap ++ vip++
" }}}
" Schlepp {{{
vmap <unique> <up> <Plug>SchleppUp
vmap <unique> <down> <Plug>SchleppDown
vmap <unique> <left> <Plug>SchleppLeft
vmap <unique> <right> <Plug>SchleppRight
" }}}
" Languagetool {{{
let g:languagetool_lang='de'
let g:languagetool_jar='$HOME/sys/lib/LanguageTool-3.2/languagetool-commandline.jar'
" }}}
" Limelight {{{
let g:limelight_default_coefficient = 0.5
" }}}
" Ack/Ag {{{
let g:ackprg = 'ag --vimgrep --smart-case'
cnoreabbrev ag Ack
cnoreabbrev aG Ack
cnoreabbrev Ag Ack
cnoreabbrev AG Ack
" }}}
" }}}
" Functions {{{
" Foldtext {{{
function! MyFoldLabel() " {{{
let line = getline(v:foldstart)
let nucolwidth = &fdc + &number * &numberwidth
let windowwidth = winwidth(0) - nucolwidth - 3
let foldedlinecount = v:foldend - v:foldstart
" Remove foldmarkers
let opening_foldmarker = split(&foldmarker, ",")[0]
let line = substitute(line, opening_foldmarker, "", 'g')
" expand tabs into spaces
let onetab = strpart(' ', 0, &tabstop)
let line = substitute(line, '\t', onetab, 'g')
"let linestart = substitute(v:folddashes, ".", '»', 'g')
"let line = linestart . line
let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
return line . ' ' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
endfunction " }}}
" }}}
" Auto commands {{{
augroup Text "{{{
au!
au BufReadPre *.txt setl textwidth=72
au BufReadPre *.txt setl wrapmargin=5
au BufReadPre *.txt setl formatoptions=tl
augroup END
"}}}
augroup gitcommit "{{{
au!
au FileType gitcommit setl textwidth=72
au FileType gitcommit setl wrapmargin=5
au FileType gitcommit setl formatoptions=tl
augroup END
"}}}
augroup ruby "{{{
au!
au FileType ruby setl ts=2 sts=2 sw=2 expandtab
"}}}
augroup Python "{{{
au!
au FileType python setl ts=4 sts=4 sw=4 expandtab
"}}}
augroup Binary "{{{
au!
au BufReadPre *.bin let &bin=1
au BufReadPost *.bin if &bin | %!xxd
au BufReadPost *.bin set filetype=xxd | endif
au BufWritePre *.bin if &bin | %!xxd -r
au BufWritePre *.bin endif
au BufWritePost *.bin if &bin | %!xxd
au BufWritePost *.bin set nomod | endif
augroup END
"}}}
augroup Mail "{{{
au!
autocmd BufNewFile,BufRead *.mail set filetype=mail
autocmd BufNewFile,BufRead ~/.mutt/* set filetype=muttrc
autocmd BufNewFile,BufRead *msmtp* set filetype=msmtp
augroup END
"}}}
augroup Pass "{{{
au!
au BufNewFile,BufRead /dev/shm/pass.* setlocal noswapfile nobackup noundofile ft=yaml
augroup END
"}}}
augroup Coffee "{{{
au!
au BufNewFile,BufRead *.coffee setl filetype=coffee
au BufNewFile,BufRead *.coffee setl foldmethod=indent
au Filetype coffee setl foldmethod=indent nofoldenable
au Filetype coffee setl shiftwidth=2 expandtab
augroup END
"}}}
augroup Shebang "{{{
au!
au BufNewFile *.rb 0put =\"#!/usr/bin/env ruby\<nl># encoding: utf-8\<nl>\"|$
au BufNewFile *.sh 0put =\"#!/usr/bin/env bash\<nl>\"|$
au BufNewFile *.pl 0put =\"#!/usr/bin/env perl\<nl>\"|$
autocmd BufNewFile *.\(cc\|hh\) 0put =\"//\<nl>// \".expand(\"<afile>:t\").\" -- \<nl>//\<nl>\"|2|start!
augroup END
"}}}
augroup Executable "{{{
" automatically give executable permissions if file begins with #! and contains '/bin/' in the path
au!
au BufWritePost * call MakeExecutable()
augroup END
"}}}
" augroup MakeNonExistingDirectory "{{{
" automatically create missing directories
" au!
" au BufWritePre * call MakeNonExistingDir()
" augroup END
"}}}
augroup Latex "{{{
au!