-
Notifications
You must be signed in to change notification settings - Fork 2
/
vimrc.after
1204 lines (919 loc) · 27.5 KB
/
vimrc.after
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
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General stuff "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""
" Theme and colors "
""""""""""""""""""""""
color railscasts
" Completion menu
hi Pmenu ctermfg=253 ctermbg=NONE
hi PmenuSel ctermfg=180 ctermbg=0
hi PmenuSbar ctermbg=242
set pumheight=20
filetype plugin on
hi SignColumn ctermbg=233
hi Vertsplit ctermfg=238
" Not too important as we use vim-airline
hi TabLineFill ctermfg=233
hi TabLine ctermbg=233
hi TabLineSel ctermbg=239
hi Visual ctermbg=236
" Fold colors
hi Folded ctermfg=180 ctermbg=none
hi FoldColumn ctermfg=180 ctermbg=233
"""""""""""""""""
" set options "
"""""""""""""""""
set noshowmode " Mode is sufficiently shown by airline
set history=400
set ttimeoutlen=50 " Fast exit from insert mode
set scrolloff=3 " Always show some context
set sidescrolloff=5
set splitright " Open to the right and below
set splitbelow " even when using CtrlP splitters
set autoread " Reread files when changed from the outside
set gdefault " E.g. substitutions are multiple per line per default
set wildmenu " get a little help. not properly colorized yet
set wildmode=longest:full,full
set wildignore+=*/doc/*,*.aux,*.dvi,*.out,*.toc,*.pdf,*.log " latex stuff
set hidden " Keep file in buffer after quit, remembers undo etc.
set nofoldenable " Never fold
set completeopt=menuone " don't open the preview scratch buffer
" Whitespace handling
set nowrap " don't wrap lines
set tabstop=2 " a tab is two spaces
set shiftwidth=2 " an autoindent (with <<) is two spaces
set expandtab " use spaces, not tabs
set list " Show invisible characters
set backspace=indent,eol,start " backspace through everything in insert mode
""""""""""""""""""""""""""""""""""""""
" Use cursors for something useful "
""""""""""""""""""""""""""""""""""""""
" not needed anymore, I am converted
map <Up> :lprev<cr>
map <Down> :lnext<cr>
map <Left> :bprev<cr>
map <Right> :bnext<cr>
imap <Up> <NOP>
imap <Down> <NOP>
imap <Left> <NOP>
imap <Right> <NOP>
""""""""""""""""""""""""""""""""""
" Key Remappings - Insert mode "
""""""""""""""""""""""""""""""""""
" This is potentially dangerous but saves quite a few keystrokes for
" keys that are used heavily in programming.
" ; is :
" : is ;
" / is _
" \ is /
" _ is \
" No shifting needed for _ : /
" \ is never used and moved away
"
" Toggle with the command ToggleCustomizedKeymap
"\ ';' : ':',
"\ ':' : ';',
let g:lfdm_custom_keymap = {
\ '/' : '_',
\ '_' : '\',
\ '\' : '/',
\}
function! s:UseCustomKeymap()
for [lhs, rhs] in items(g:lfdm_custom_keymap)
exe 'inoremap '.lhs.' '.rhs
endfor
let g:lfdm_custom_keymap_in_use = 1
echo "Using custom keymap"
endfunction
function! s:UseNormalKeymap()
for lhs in keys(g:lfdm_custom_keymap)
exe 'iunmap '.lhs
endfor
let g:lfdm_custom_keymap_in_use = 0
echo "Using normal keymap"
endfunction
function! s:ToggleCustomizedKeymap()
if g:lfdm_custom_keymap_in_use
call s:UseNormalKeymap()
else
call s:UseCustomKeymap()
endif
endfunction
command! ToggleCustomizedKeymap call s:ToggleCustomizedKeymap()
function! ToggleCustomizedKeymapFromInsertMode()
let g:lfdm_custom_keymap_toggled = 1
ToggleCustomizedKeymap
endfunction
function! s:RestoreKeymapToggling()
if g:lfdm_custom_keymap_toggled
ToggleCustomizedKeymap
let g:lfdm_custom_keymap_toggled = 0
endif
endfunction
let g:lfdm_custom_keymap_toggled = 0
au InsertLeave * call s:RestoreKeymapToggling()
silent call s:UseCustomKeymap()
map ,ck :ToggleCustomizedKeymap<cr>
inoremap ,ck <c-o>:call ToggleCustomizedKeymapFromInsertMode()<cr>
""""""""""""""""""""""""
" Insert mode helper "
""""""""""""""""""""""""
" upcase the word just written - useful for constants
" we don't use <C-c> to exit insert mode anyway
inoremap <C-c> <esc>viwUea
"""""""""""""""""""""""""""""""""""
" Key Remappings - Normal mode "
"""""""""""""""""""""""""""""""""""
" jumping in f command or similar
" obsolete - we jump with easymotion
noremap , ;
noremap \ ,
"""""""""""""""""""""
" Typo Prevention "
"""""""""""""""""""""
command! Q q
" don't want to lookup stuff by accident
map K <Nop>
"""""""""""""""""""
" Abbreviations "
"""""""""""""""""""
function! Abbrs()
ab c Caesar
ab bg Bellum Gallicum
ab cbg Caes. Gall.
ab tb Treebank
ab u und
ab a auch
ab f f"uer
endfunction
autocmd BufRead,BufNewFile ~/code/diploma_thesis/text/tex/*.tex call Abbrs()
""""""""""""""""""""""""""""
" Tabs, Buffers, Windows "
""""""""""""""""""""""""""""
" not really using tabs a lot anymore...
noremap <C-t> :tabnew<CR>
nnoremap ,l :tabnext<CR>
nnoremap ,h :tabprevious<CR>
nnoremap vv <c-w>v
nnoremap <leader>ss <c-w>s
" Switch windows faster
" Think about freeing up space againg. Hopper trigger maybe?
"nnoremap space> <c-w>w
" Regular window movement
" Destroys line bubbling, use unimpaired and hopper instead
nnoremap <c-h> <c-w>h
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-l> <c-w>l
" Break out window to tab
nnoremap <leader>wt <c-w>T
nnoremap <leader>bd :bd<cr>
""""""""""""""
" Sessions "
""""""""""""""
set ssop-=options " do not store global and local values in a session
set ssop-=folds " do not store folds
map <leader>ms :mksession! ~/session.vim
map <leader>lS :so ~/session.vim
"""""""""""""""""""""""""
" Saving and quitting "
"""""""""""""""""""""""""
map <leader>w :w<cr>
map <leader>wa :wa<cr>
map <leader>x :x<cr>
map <leader>qq :q<cr>
""""""""""""""
" Movement "
""""""""""""""
" H and L for start and end of line
noremap H ^
noremap L $
" Move over graphical lines, i.e. when they are wrapped
noremap j gj
noremap k gk
" Visual shifting - vmode is not exited
vnoremap < <gv
vnoremap > >gv
" go to last edit
nnoremap ,. '.
""""""""""""""""""""""""""""
" Centering search jumps "
""""""""""""""""""""""""""""
nnoremap <silent> n nzz
nnoremap <silent> N Nzz
nnoremap <silent> * *zz
nnoremap <silent> # #zz
nnoremap <silent> g* g*zz
nnoremap <silent> g# g#zz
""""""""""""""""""""
" Copy and Paste "
""""""""""""""""""""
" uses paste mode when pasting from the clipboard in insert mode
" and leaves it immeadiately after
inoremap <C-v> <esc>:set paste<cr>a<C-r>+<esc>:set nopaste<cr>a
inoremap <C-b> <esc>:set paste<cr>a<C-r>*<esc>:set nopaste<cr>a
" copy current paste buffer to clipboard buffer
" remember that a visual selection is automatically in @*
noremap <C-c> :let @+=@"<cr> :echo 'Copied default paste buffer to clipboard.'<cr>
" Y like D, C...
map Y y$
"""""""""""
" Marks "
"""""""""""
" swaps for easier mark navigation
" ` jumps directly to the mark
nnoremap ' `
nnoremap ` '
""""""""""""""""""
" Highlighting "
""""""""""""""""""
" Overlong lines. Don't do it in the quickfix windows.
" Hacky, but vimscript is driving one mad sometimes...
au BufRead * highlight OverLength ctermbg=238
au BufRead * match OverLength /\%80v.\+/
au BufReadPost quickfix exec ':call clearmatches()'
" Disables highlighting
map <esc><esc> :nohl<cr>
"""""""""""""""""""""""""
" Whitespace deletion "
"""""""""""""""""""""""""
" should be enabled for others too
au BufWritePre *.rb :%s/\s\+$//e
au BufWritePre *.js :%s/\s\+$//e
au BufWritePre *.py :%s/\s\+$//e
au BufWritePre *.jsx :%s/\s\+$//e
au BufWritePre *.coffee :%s/\s\+$//e
au BufWritePre *.less :%s/\s\+$//e
au BufWritePre *.scss :%s/\s\+$//e
au BufWritePre *.java :%s/\s\+$//e
""""""""""""""""""""""
" Filetype setting "
""""""""""""""""""""""
au BufRead,BufNewFile *.hamlc set ft=haml
au BufRead,BufNewFile *pryrc set ft=ruby
au BufRead,BufNewFile *.zsh-theme set ft=zsh
"""""""""""""""""""
" Spellchecking "
"""""""""""""""""""
au Filetype gitcommit setlocal spell spelllang=en
au Filetype markdown setlocal spell spelllang=en
""""""""""""""
" Wrapping "
""""""""""""""
command! -nargs=* HardWrap set wrap linebreak nolist textwidth=72
command! -nargs=* Wrap set wrap linebreak nolist textwidth=0 wrapmargin=0
""""""""""""
" Macros "
""""""""""""
" Fast replay of standard q macro
noremap Q @q
"""""""""""""""""""
" File renaming "
"""""""""""""""""""
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
map <leader>` :call RenameFile()<cr>
""""""""""""""""""""""""""""""""""""""""""
" running tests through rake and grunt "
""""""""""""""""""""""""""""""""""""""""""
" Usually set to rspec, but we run rake or grunt instead and try to send it off to the
" test-runner window in tmux
" Also saves the buffer before invoking rake-or-grunt
function! TestThroughTmux()
" making sure that we are in the correct directory before invoking rake
exec 'w'
let session = system('tmux display-message -p "#S"')
let session = substitute(session, '\n$', '', '')
exec 'silent ! tmux send-keys -t '.session.':test-runner C-u "cd ' . expand('%:p:h') . ' && rake-or-grunt" C-m'
exec 'redraw!'
endfunction
map <leader>r :call TestThroughTmux()<cr>
" Opens a split window with the corresponding spec file of what you're currently working on
function! OpenSpec()
let curr_file = expand('%')
if &ft == 'ruby'
let spec_file = substitute(expand('%'), ".rb$", "_spec.rb", "")
elseif &ft == 'javascript'
let spec_file = substitute(expand('%'), ".js$", "_spec.js", "")
let spec_file = substitute(spec_file, "^app\/js\/" , "", "")
endif
exec ":vs"
exec ":wincmd l"
exec ":e spec/" . spec_file
endfunction
map <leader>k :call OpenSpec()<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Language specific stuff "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""
" Ruby "
"""""""""
" Focus the RSpec do block you're currently hovering and saves the file
function! RSpecFocus()
if getline(".") =~ ', :focus'
exec ":silent! s/, :focus//g"
else
exec ":silent! s/ do/, :focus do"
endif
exec ":w"
endfunction
" Change Ruby 1.8 style hashes to new syntax - asks for confirmation
" Not terribly well done for now
function! MorphHash()
exec ":'<,'>:s/:\([^ ]*\)\(\s*\)=>/\1:/gc"
endfunction
function! RubySettings()
" Insert pry statement
" Mind that ; is remapped - we have to shield it with paste mode
map <leader>p :set paste<cr>orequire 'pry'; binding.pry<esc>:set nopaste<cr>
map <leader>P :set paste<cr>Orequire 'pry'; binding.pry<esc>:set nopaste<cr>
map <leader>j :call RSpecFocus()<Cr>
endfunction
autocmd FileType ruby call RubySettings()
"""""""""""""""
" LLT stuff "
"""""""""""""""
" Change current directory to the llt path of the current file
function! SetLLTPath()
exec ':lcd ' . matchlist(expand("%:p"), '\v.*llt-.{-}/')[0]
endfunction
map <leader>lt :call SetLLTPath()<Cr>
""""""""""""
" Python "
""""""""""""
""""""""""""""""
" javascript "
""""""""""""""""
" wrap a line in a console log
function! WrapInConsoleLog()
s/\(\s*\)\(.\{-}\);\?$/\1console.log(\2);
endfunction
noremap <leader>ll :call WrapInConsoleLog()<cr>
noremap <leader>dd odebugger;<esc>:w<cr>
function! WithoutPrefix(text)
return substitute(a:text, '\(\s*\) \* \(.*\)', '\1\2', '')
endfunction
function! WithoutAll(text)
return substitute(a:text, '\s*\* \(.*\)', '\1', '')
endfunction
function! MultiLineCommentFold()
let text = WithoutPrefix(getline(v:foldstart + 1))
" Adds the description of an ngdoc string if possible
"if text =~ 'ngdoc'
"let i = 2
"let no_description = 1
"while i < 7 && no_description
"let line = getline(v:foldstart + i)
"echom line
"if line =~ '^\s*\* @description'
"let no_description = 0
"endif
"let i += 1
"endwhile
"if !no_description
"echom text
"let text = text . ': ' . WithoutAll(getline(v:foldstart + i))
"endif
"endif
let line_count = v:foldend-v:foldstart + 1
let line_text = '('. line_count .' lines) '
let offset = strlen(line_text) + 4
return text . repeat(' ', winwidth(0) - strlen(text) - offset) . line_text
endfunction
function! JsSettings()
" folding of ngdoc comment strings
let filename = expand('%:t')
if filename =~ '^\([Gg]runt\|[Gg]ulp\)'
set nofoldenable
else
set fmr=/**,*/ fdm=marker fdc=1
set foldenable
let &foldtext = "MultiLineCommentFold()"
map zx :set foldenable!<cr>
map gh :call lookup#goToFunc()<cr>
map gH :call lookup#goToFile()<cr>
nmap gd :TernDef<cr>
nmap gD :TernDoc<cr>
nmap gr :TernRefs<cr>
endif
endfunction
autocmd FileType javascript call JsSettings()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Coffeescript "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! FocusOutmostDescribe()
exec FocusDescribe('c', 'file', 1)
endfunction
function! FocusInnerDescribe()
exec FocusDescribe('bc', 'inner describe', 0)
endfunction
function! FocusDescribe(flags, name, move_to_start)
let pos = getpos('.')
if a:move_to_start == 1
normal! gg
endif
call search('^\s*f\?describe', a:flags)
let line = getline('.')
if line =~ '^\s*f'
normal! "_x
echo "Unfocus " . a:name
else
normal! ^if
echo "Focus ". a:name
endif
call setpos('.', pos)
endfunction
function! CoffeeSettings()
map <leader>j :call FocusOutmostDescribe()<cr>
map <leader>J :call FocusInnerDescribe()<cr>
endfunction
autocmd FileType coffee call CoffeeSettings()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugin customization "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""
" Syntastic "
"""""""""""""""
" Quickly jump through the list
noremap <c-:> :lnext<cr>
noremap <c-'> :lprev<cr>
" Disables buggy checks for bats files
let g:syntastic_ignore_files = ['\.bats$']
" Automatically show error list
let g:syntastic_auto_loc_list=1
" Make the list a little shorter
let g:syntastic_loc_list_height=5
" Make tidy play nice with angular
let g:syntastic_html_tidy_ignore_errors=[
\ " proprietary attribute ",
\ "trimming empty <",
\ "unescaped &" ,
\ "lacks \"action",
\ "is not recognized!",
\ "discarding unexpected"
\]
"let g:syntastic_javascript_checkers = ['jsxhint']
let g:syntastic_typescript_checkers = ['tslint']
"""""""""""""""""""
" YouCompleteMe "
"""""""""""""""""""
" see also vimrc.before
let g:ycm_complete_in_comments = 1
let g:ycm_complete_in_strings = 1
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_use_bundler = 1
let g:rubycomplete_rails = 1
" Eclim - used by YouCompleteMe
" Currently unused, not really working and an expensive dependency
" let g:EclimCompletionMethod = 'omnifunc'
"""""""""""""""
" UltiSnips "
"""""""""""""""
" see also vimrc.before
let g:UltiSnipsEditSplit = 'vertical'
let g:UltiSnipsSnippetsDir = '~/dotfiles/snippets/ultisnips'
map <leader>ue :UltiSnipsEdit<cr>
" expand the snippet in current selection
smap <C-l> <esc>a<c-j>
imap <C-b> <c-j><esc>"_dd}
""""""""""""""""
" vim-hopper "
""""""""""""""""
" see vimrc.before
""""""""""""""""
" vim-lookup "
""""""""""""""""
let angular_pattern = '\v(index.js|style.less|spec.coffee|template.html)$'
let g:lookup_go_to_mappings = {
\'javascript': {
\ 'main_file': { 'dir': 'app/**', 'suffix': '.js' },
\ 'spec_file': { 'dir': 'app/**', 'suffix': '.spec.coffee' },
\},
\'coffee': {
\ 'main_file': { 'dir': 'app/**', 'suffix': '.js' },
\ 'spec_file': { 'dir': 'app/**', 'suffix': '.spec.coffee' },
\},
\'html' : {
\ 'substitute': [
\ ['\v(.*)', 'components/\1/index.js', '']
\ ],
\ 'main_file': { 'dir': 'app/**', 'suffix': '.js' },
\ 'spec_file': { 'dir': 'app/**', 'suffix': '.spec.coffee' },
\},
\'ruby' : {
\ 'main_file': { 'dir': 'lib/**', 'suffix': '.rb' },
\ 'spec_file': { 'dir': 'spec/**', 'suffix': '.rb' },
\}
\}
let g:lookup_file_mappings = {
\'js': [
\ {
\ 'pattern': angular_pattern,
\ 'substitute': [angular_pattern, 'index.js', '']
\ }
\],
\'spec': [
\ {
\ 'pattern': angular_pattern,
\ 'substitute': [angular_pattern, 'spec.coffee', '']
\ }
\],
\'tpl': [
\ {
\ 'pattern': angular_pattern,
\ 'substitute': [angular_pattern, 'template.html', '']
\ }
\],
\'less': [
\ {
\ 'pattern': angular_pattern,
\ 'substitute': [angular_pattern, 'style.less', '']
\ }
\]
\}
let g:lookup_layouts = {
\'angular' : [
\{
\'pattern' : 'directive' . angular_pattern,
\'windows' : [
\ [
\ { 'substitute': [angular_pattern, '.js'] },
\ { 'substitute': [angular_pattern, '-tpl.html'] }
\ ],
\ [
\ { 'substitute': [angular_pattern, '.spec.coffee'], 'rows': 18 },
\ { 'substitute': [angular_pattern, '.less'], 'rows': 18 }
\ ]
\]
\},
\{
\'pattern' : '\v(service|factory|controller)' . angular_pattern,
\'windows' : [
\ [
\ { 'substitute': [angular_pattern, '.js'] },
\ { 'substitute': [angular_pattern, '.spec.coffee'] }
\ ]
\]
\}
\]
\}
let lookup_mappings = {
\'ft': 'OpenFile tpl',
\'fs': 'OpenFile spec',
\'fj': 'OpenFile js',
\'fl': 'OpenFile less',
\'Ft': 'OpenFile tpl',
\'Fs': 'OpenFile spec',
\'Fj': 'OpenFile js',
\'Fl': 'OpenFile less',
\'oa': 'OpenLayout angular',
\'a': 'OpenLayout angular',
\}
for mapping in items(lookup_mappings)
exec "noremap " . g:lookup_leader . mapping[0] . ' :Lookup' . mapping[1] . '<cr>'
endfor
let g:lookup_glob_command = 'ag %s --files-with-matches -g "" --ignore "\.git$\|\.hg$\|\.svn$"'
"""""""""""""""""""
" NerdCommenter "
"""""""""""""""""""
" comment a whole paragraph
map <leader>cp vip<leader>c<space>
""""""""""""""
" NerdTree "
""""""""""""""
let NERDTreeMinimalUI = 1
let NERDTreeWinSize = 30
let NERDTreeShowHidden = 1
""""""""""""""
" Surround "
""""""""""""""
let g:surround_35 = "#{\r}" " ruby interpolation triggered by #
" Quickly surround the inner word by triggering
" , and the surrounder.
" When triggered from normal mode, jump to the later surrounder
map ,# ysiw#2w
vmap ,# c#{<C-R>"}<ESC>
map ," ysiw"2w
vmap ," c"<C-R>""<ESC>
map ,' ysiw'2w
vmap ,' c'<C-R>"'<ESC>
map ,( ysiw(2w
map ,) ysiw)2w
vmap ,( c( <C-R>" )<ESC>
vmap ,) c(<C-R>")<ESC>
map ,] ysiw]2w
map ,[ ysiw[2w
vmap ,[ c[ <C-R>" ]<ESC>
vmap ,] c[<C-R>"]<ESC>
map ,} ysiw}2w
map ,{ ysiw{2w
vmap ,} c{ <C-R>" }<ESC>
vmap ,{ c{<C-R>"}<ESC>
map ,` ysiw`2w
vmap ,` c`<C-R>"`<ESC>
""""""""""""
" switch "
""""""""""""
" switch_custom_def_helper
let scdh =
\{
\ 'class_module': ['class', 'module'],
\ 'any_empty': ['any', 'empty'],
\ 'if_unless': ['if', 'unless'],
\ 'ternary_args': {
\ '\v^(.*) \? (.*) : (.*)': '\1 ? \3 : \2'
\ },
\ 'should': {
\ '\v^(.*)should ': '\1should_not ',
\ '\v^(.*)should_not ': '\1should ',
\ },
\ 'jasmine-bools': ['toBeTruthy', 'toBeFalsy'],
\ 'jasmine-defined': ['toBeDefined', 'toBeUndefined'],
\ 'jasmine-not': ['.to', '.not.to'],
\ 'jasmine-describe-focus': {
\ 'describe': 'fdescribe',
\ 'fdescribe': 'describe',
\ },
\ 'jasmine-it-focus': {
\ 'it': 'fit',
\ 'fit': 'it',
\ },
\ 'ng-scope': ['scope', '$scope'],
\ 'ng-emit-broadcast': ['$emit', '$broadcast'],
\ 'this-self': ['this', 'self'],
\ 'fn-declarations': {
\ '\v^(.*)this\.(.{-}) \= function\s?\((.{-})\) (.*)' : '\1function \2(\3) \4',
\ '\v^(.*)function (.{-})\((.*)\) (.*)' : '\1var \2 = function(\3) \4',
\ '\v^(.*)var (.{-}) \= function\((.*)\) (.*)' : '\1this.\2 = function(\3) \4'
\ }
\}
au Filetype ruby let b:switch_custom_definitions =
\[
\ scdh['class_module'],
\ scdh['any_empty'],
\ scdh['if_unless'],
\ scdh['ternary_args'],
\ scdh['should'],
\]
au Filetype javascript let b:switch_custom_definitions =
\[
\ scdh['jasmine-bools'],
\ scdh['jasmine-defined'],
\ scdh['jasmine-not'],
\ scdh['ng-scope'],
\ scdh['ng-emit-broadcast'],
\ scdh['fn-declarations'],
\ scdh['this-self'],
\]
au Filetype coffee let b:switch_custom_definitions =
\[
\ scdh['jasmine-bools'],
\ scdh['jasmine-defined'],
\ scdh['jasmine-describe-focus'],
\ scdh['jasmine-it-focus'],
\ scdh['jasmine-not'],
\ scdh['ng-scope'],
\]
let g:switch_custom_definitions =
\ [
\ ['+', '-'],
\ ['>', '<']
\ ]
nnoremap - :Switch<cr>
"""""""""""""""
" splitjoin "
"""""""""""""""
nnoremap ,j :SplitjoinJoin<cr>
nnoremap ,s :SplitjoinSplit<cr>
""""""""""""""
" sideways "
""""""""""""""
SubmodeDefine sideways
Submode n <enter> <leader>sf <nop>
Submode n h :SidewaysJumpLeft<cr>
Submode n k :SidewaysJumpLeft<cr>
Submode n j :SidewaysJumpRight<cr>
Submode n l :SidewaysJumpRight<cr>
Submode n H :SidewaysLeft<cr>
Submode n K :SidewaysLeft<cr>
Submode n L :SidewaysRight<cr>
Submode n J :SidewaysRight<cr>
SubmodeDefineEnd
call submode#map('sideways', 'n', 'rs', 'd', 'd<Plug>SidewaysArgumentTextobjA')
call submode#map('sideways', 'n', 'rs', 'x', 'd<Plug>SidewaysArgumentTextobjI')
"""""""""""""
" submode "
"""""""""""""
" predefined by vim-hopper
"""""""""""""""""
" delimitMate "
"""""""""""""""""
" jumping over the auto-inserted closer
imap <C-a> <esc>wa
""""""""""""
" Tagbar "
""""""""""""
" shows a tags definition, a is for args, don't want this on <space>
let g:tagbar_map_showproto = 'a'
let g:tagbar_type_markdown = {
\ 'ctagstype' : 'markdown',
\ 'kinds' : [
\ 'h:Heading_L1',
\ 'i:Heading_L2',
\ 'k:Heading_L3',
\ 'r:Heading_L4'
\ ]
\ }
let g:tagbar_type_snippets = {
\ 'ctagstype' : 'snippets',
\ 'kinds' : [
\ 's:snippets',
\ 'g:globals',
\ ]
\ }
let g:tagbar_width = 60
"""""""""""""""
" IndentLine "
"""""""""""""""
" see also vimrc.before
let g:indentLine_color_term = 235
let g:indentLine_char = '|'
map <leader>ig :IndentLinesToggle<cr>
"""""""""""""""""""
" number_toggle "
"""""""""""""""""""
" see also vimrc.before
" Enables the only recently supported hybrid mode for line numbers.
" Overrides the built in function
function! EnableRelativeNumbers()
set number
set relativenumber
endfunction
"""""""""""
" Gundo "
"""""""""""
let g:gundo_right = 1
""""""""""""""
" Fugitive "
""""""""""""""
" stages file in current buffer
map <leader>ga :Gwrite<cr>
" removes a file from the git tree
map <leader>gr :Gremove<cr>
"""""""""""""""
" extradite "
"""""""""""""""
let g:extradite_width = 90
let g:extradite_showhash = 1
map <leader>ge :Extradite!<cr>
map <leader>gE :Extradite<cr>