/
vimrc.symlink
902 lines (710 loc) · 23.8 KB
/
vimrc.symlink
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
set nocompatible
filetype off
filetype plugin indent off
set runtimepath+=$GOBIN
set runtimepath+=~/.vim/bundle/dart-vim-plugin
" set the runtime path to include Vundle and initialize
call plug#begin()
" My bundles
Plug 'Shougo/vimproc.vim'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'ervandew/supertab'
Plug 'sjl/gundo.vim'
Plug 'reinh/vim-makegreen'
Plug 'scrooloose/nerdcommenter'
Plug 'scrooloose/syntastic'
Plug 'Townk/vim-autoclose'
Plug 'vim-scripts/Rainbow-Parenthesis'
Plug 'kien/ctrlp.vim'
Plug 'benmills/vimux'
Plug 'vim-scripts/ZoomWin'
Plug 'vim-scripts/Jinja'
Plug 'vim-scripts/TaskList.vim'
Plug 'rizzatti/funcoo.vim'
Plug 'rizzatti/dash.vim'
Plug 'ap/vim-buftabline'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'majutsushi/tagbar'
Plug 'vim-scripts/Align'
Plug 'godlygeek/tabular'
Plug 'michaeljsmith/vim-indent-object'
Plug 'christoomey/vim-tmux-navigator'
Plug 'mtth/scratch.vim'
" Nerdtree
Plug 'vim-scripts/The-NERD-tree'
" Markdown
Plug 'tpope/vim-markdown', { 'for': 'markdown' }
" Git
Plug 'tpope/vim-fugitive'
Plug 'vim-scripts/gitignore'
Plug 'gregsexton/gitv'
Plug 'airblade/vim-gitgutter'
Plug 'int3/vim-extradite'
" Language-spec
Plug 'klen/python-mode'
Plug 'vim-ruby/vim-ruby'
Plug 'pangloss/vim-javascript'
Plug 'elzr/vim-json'
Plug 'jelera/vim-javascript-syntax'
Plug 'robertkluin/vim-handy-highlights'
Plug 'mxw/vim-jsx'
Plug 'raichoo/purescript-vim'
Plug 'dart-lang/dart-vim-plugin'
Plug 'jimenezrick/vimerl'
"Clojure
Plug 'tpope/vim-classpath', { 'for': 'clojure' }
Plug 'vim-scripts/paredit.vim', { 'for': 'clojure' }
Plug 'guns/vim-clojure-static', { 'for': 'clojure' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
Plug 'tpope/vim-salve', { 'for': 'clojure' }
" Erlang
Plug 'vim-erlang/vim-erlang-compiler', { 'for': 'erlang' }
Plug 'vim-erlang/vim-erlang-omnicomplete', { 'for': 'erlang' }
Plug 'vim-erlang/vim-erlang-tags', { 'for': 'erlang' }
Plug 'vim-erlang/vim-rebar', { 'for': 'erlang' }
Plug 'vim-erlang/vim-dialyzer', { 'for': 'erlang' }
Plug 'jimenezrick/vimerl', { 'for': 'erlang' }
" Less
Plug 'groenewege/vim-less', { 'for': 'less' }
" Haskell
Plug 'neovimhaskell/haskell-vim', { 'for': ['haskell', 'cabal'] }
Plug 'enomsg/vim-haskellConcealPlus', { 'for': ['haskell', 'cabal'] }
Plug 'eagletmt/ghcmod-vim', { 'for': ['haskell', 'cabal'] }
Plug 'eagletmt/neco-ghc', { 'for': ['haskell', 'cabal'] }
Plug 'Twinside/vim-hoogle', { 'for': ['haskell', 'cabal'] }
Plug 'lukerandall/haskellmode-vim', { 'for': ['haskell', 'cabal'] }
"Plug 'lukerandall/haskellmode-vim'
"Plug 'dag/vim2hs'
" Rust
Plug 'wting/rust.vim', { 'for': 'rust' }
" Purescript
Plug 'raichoo/purescript-vim', { 'for': ['purescript', 'purs'] }
" Elm
"Plug 'lambdatoast/elm.vim', { 'for': ['elm'] }
Plug 'elmcast/elm-vim', { 'for': ['elm'] }
" GOLANG
"Plugin 'dgryski/vim-godef'
"set rtp+=/usr/local/go/misc/vim
"autocmd FileType go autocmd BufWritePre <buffer> Fmt
"nmap <F4> :TagbarToggle<CR>
"" Need to make sure bash_profile as GOROORT set to HOME/go
"" go get -v code.google.com/p/rog-go/exp/cmd/godef
"" go install -v code.google.com/p/rog-go/exp/cmd/godef
"let g:godef_split=0
"let g:godef_same_file_in_same_window=1
Plug 'fatih/vim-go', { 'for': 'go' }
Plug 'benmills/vimux-golang', { 'for': 'go' }
call plug#end()
filetype plugin indent on
" The basics
syntax on
set showcmd
set hidden
set cursorline
set ruler
set backspace=2
set number
set laststatus=2
set history=1000
set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:❮
set dictionary=/usr/share/dict/words
set mouse=a
set wildmode=longest:full
set wildmenu
" TABS, SPACING
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set autoindent
set textwidth=80
set colorcolumn=80
" backups
set backup
set noswapfile
set undolevels=999
set undofile
set undoreload=10000
set undodir=/var/tmp/vim/undo// " undo files
set backupdir=/var/tmp/vim/backup// " backups
set directory=/var/tmp/vim/swap// " swap files
set hlsearch
set nowrap
" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8
" Use Unix as the standard file type
set ffs=unix,dos,mac
" KEY REMAPPING
" leader
let mapleader = ","
let maplocalleader = "\\"
" Made D behave
nnoremap D d$
" It's 2011.
noremap j gj
noremap k gk
" Destroy infuriating keys
" Fuck you, help key.
noremap <F1> :set invfullscreen<CR>
inoremap <F1> <ESC>:set invfullscreen<CR>a
" Fuck you too, manual key.
nnoremap K <nop>
" Stop it, hash key.
inoremap # X<BS>#
" Less chording
map ; :
noremap ;; ;
" Faster Esc
inoremap jj <esc>
" toggle current column highlight shortcut
map <leader>c :set cursorcolumn!<cr>
" Gundo
nnoremap <leader>g :GundoToggle<CR>
" toggle between relative and absolute line numbers.
map <leader>l :exec "set " &nu ? "rnu": "nu"<cr>
" toggle paste mode.
map <leader>e :set paste!<CR>
" toggle spell mode.
map <leader>p :set spell!<cr>
" SEARCHING
" Keep search matches in the middle of the window and pulse the line when moving
" to them.
nnoremap / /\v
vnoremap / /\v
" Open file in same path wiht :e %%
cabbr <expr> %% expand('%:p:h')
" Search for selected word
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
" Moving around
" quick buffer list
:nnoremap <C-t> :buffers<CR>:buffer<Space>
" Buffer movement.
nnoremap <leader>j :bnext<CR>
nnoremap <leader>k :bprev<CR>
" Vim Expand Region
vmap v <Plug>(expand_region_expand)
vmap <C-v> <Plug>(expand_region_shrink)
" Show trailing whitespace
set list
" But only interesting whitespace
if &listchars ==# 'eol:$'
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
endif
if has("autocmd")
" Enable file type detection
filetype on
" Turn spellcheck on for gitcommit by default.
autocmd FileType gitcommit set spell
" mako syntax highlighting
autocmd BufRead *.mako set filetype=mako
" haskell
autocmd BufRead *.hs set filetype=haskell
" purescript
autocmd BufRead *.purs set filetype=purescript
" Docker
autocmd BufRead *.Dockerfile set filetype=sh
" make jinja, jst, and handlebars templates use html syntax highlighting
autocmd BufRead *.jinja,*.jst,*.handlebars,*.mustache set filetype=html
" Set html, coffee, and javascript indent depths to 2-space.
autocmd FileType coffee,html,javascript,mako.yaml setlocal shiftwidth=2 tabstop=2 softtabstop=2
" Flex syntax highlighting
autocmd BufRead *.as set filetype=actionscript
autocmd BufRead *.mxml set filetype=mxml
autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
" Customisations base on preference
autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType less setlocal ts=2 sts=2 sw=2 expandtab
" Flex syntax highlighting
autocmd BufRead *.as set filetype=actionscript
autocmd BufRead *.mxml set filetype=mxml
" Clojure
au BufNewFile,BufRead *.cljs set filetype=clojure
" Elm
au BufNewFile,BufRead *.elm set filetype=elm
autocmd FileType elm setlocal shiftwidth=4 tabstop=4 softtabstop=4
endif
" EDITING"
" **************************************************
"au BufWritePost *.go,*.c,*.cpp,*.h silent! !ctags -R &
autocmd BufNewFile,BufReadPost *.md set filetype=markdown
" auto complete
set omnifunc=syntaxcomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS noci
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags noci
autocmd FileType mustache set omnifunc=htmlcomplete#CompleteTags noci
autocmd FileType mako set omnifunc=htmlcomplete#CompleteTags noci
autocmd FileType jst set omnifunc=htmlcomplete#CompleteTags noci
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags noci
autocmd FileType c set omnifunc=ccomplete#Completej noci
set completeopt=menuone
" Substitute
nnoremap <leader>s :%s//<left>
" Sudo to write
cmap w!! w !sudo tee % >/dev/null
" FILE MANAGEMENT
" ***************************************************
" wild menu
set wildignore+=*.py[co] " Python byte code
" Resize splits when the window is resized
au VimResized * exe "normal! \<c-w>="
noremap <leader><space> :noh<cr>:call clearmatches()<cr>
" Make leader leader switch between last 2 buffers
nnoremap <leader><leader> <c-^>
" Easy buffer navigation
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
" Highlight VCS conflict markers
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
" COLOR SCHEME
syntax on
set background=dark
colorscheme mymolokai
set t_Co=256
hi Normal ctermbg=235
hi NonText ctermbg=235
"hi Statement ctermbg=235
hi Visual ctermbg=60
hi StatusLine ctermfg=246 ctermbg=234
hi StatusLineNC ctermfg=238 ctermbg=187
hi Todo ctermfg=30
hi Exception ctermfg=187 ctermbg=235
" highlight groups
hi CursorLine cterm=NONE ctermbg=236
hi CursorColumn cterm=NONE ctermbg=236
hi ColorColumn cterm=NONE ctermbg=232
" ABBREVATIONS AND SPELLING
abbr teh the
abbr nad and
abbr adn and
abbr becasue because
abbr becuase because
abbr taht that
abbr refactor reorganize
abbr prase parse
abbr sefl self
abbr pathc patch
abbr udpate update
" PLUGINS
" Align
" Stop Align plugin from forcing its mappings on us
let g:loaded_AlignMapsPlugin=1
" Align on equal signs
map <Leader>a= :Align =<CR>
" Align on commas
map <Leader>a, :Align ,<CR>
" Align on pipes
map <Leader>a<bar> :Align <bar><CR>
" Prompt for align character
map <leader>ap :Align
" Task list
map <leader>td <Plug>TaskList
" Haskell Interrogation {{{
set completeopt+=longest
" Use buffer words as default tab completion
let g:SuperTabDefaultCompletionType = '<c-x><c-p>'
" But provide (neco-ghc) omnicompletion
if has("gui_running")
imap <c-space> <c-r>=SuperTabAlternateCompletion("\<lt>c-x>\<lt>c-o>")<cr>
else " no gui
if has("unix")
inoremap <Nul> <c-r>=SuperTabAlternateCompletion("\<lt>c-x>\<lt>c-o>")<cr>
endif
endif
" Show types in completion suggestions
let g:necoghc_enable_detailed_browse = 1
" Resolve ghcmod base directory
au FileType haskell let g:ghcmod_use_basedir = getcwd()
" Type of expression under cursor
nmap <silent> <leader>ht :GhcModType<CR>
" Insert type of expression under cursor
nmap <silent> <leader>hT :GhcModTypeInsert<CR>
" GHC errors and warnings
nmap <silent> <leader>hc :SyntasticCheck hdevtools<CR>
" Haskell Lint
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['haskell'] }
nmap <silent> <leader>hl :SyntasticCheck hlint<CR>
" Options for Haskell Syntax Check
let g:syntastic_haskell_hdevtools_args = '-g-Wall'
" Hoogle the word under the cursor
nnoremap <silent> <leader>hh :Hoogle<CR>
" Hoogle and prompt for input
nnoremap <leader>hH :Hoogle
" Hoogle for detailed documentation (e.g. "Functor")
nnoremap <silent> <leader>hi :HoogleInfo<CR>
" Hoogle for detailed documentation and prompt for input
nnoremap <leader>hI :HoogleInfo
" Hoogle, close the Hoogle window
nnoremap <silent> <leader>hz :HoogleClose<CR>
" }}}
" Tags {{{
set tags=tags;/,codex.tags;/
let g:tagbar_type_haskell = {
\ 'ctagsbin' : 'hasktags',
\ 'ctagsargs' : '-x -c -o-',
\ 'kinds' : [
\ 'm:modules:0:1',
\ 'd:data: 0:1',
\ 'd_gadt: data gadt:0:1',
\ 't:type names:0:1',
\ 'nt:new types:0:1',
\ 'c:classes:0:1',
\ 'cons:constructors:1:1',
\ 'c_gadt:constructor gadt:1:1',
\ 'c_a:constructor accessors:1:1',
\ 'ft:function types:1:1',
\ 'fi:function implementations:0:1',
\ 'o:others:0:1'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 'm' : 'module',
\ 'c' : 'class',
\ 'd' : 'data',
\ 't' : 'type'
\ },
\ 'scope2kind' : {
\ 'module' : 'm',
\ 'class' : 'c',
\ 'data' : 'd',
\ 'type' : 't'
\ }
\ }
" Generate haskell tags with codex and hscope
map <leader>tg :!codex update --force<CR>:call system("git-hscope -X TemplateHaskell")<CR><CR>:call LoadHscope()<CR>
map <leader>tt :TagbarToggle<CR>
set csprg=hscope
set csto=1 " search codex tags first
set cst
set csverb
nnoremap <silent> <C-\> :cs find c <C-R>=expand("<cword>")<CR><CR>
" Automatically make cscope connections
function! LoadHscope()
let db = findfile("hscope.out", ".;")
if (!empty(db))
let path = strpart(db, 0, match(db, "/hscope.out$"))
set nocscopeverbose " suppress 'duplicate connection' error
exe "cs add " . db . " " . path
set cscopeverbose
endif
endfunction
au BufEnter /*.hs call LoadHscope()
" }}}
" Control P
" *****************************************************************************
" *****************************************************************************
"let g:ctrlp_cmd = 'CtrlPMixed' " search anything (in files, buffers and MRU files at the same time.)
let g:ctrlp_working_path_mode = 'r' " search for nearest ancestor like .git, .hg, and the directory of the current file
let g:ctrlp_match_window_bottom = 0 " show the match window at the top of the screen
"let g:ctrlp_by_filename = 1
let g:ctrlp_max_height = 10 " maxiumum height of match window
"let g:ctrlp_switch_buffer = 'et' " jump to a file if it's open already
let g:ctrlp_use_caching = 1 " enable caching
let g:ctrlp_clear_cache_on_exit=1 " speed up by not removing clearing cache evertime
let g:ctrlp_mruf_max = 250 " number of recently opened files
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn|build)$',
\ 'file': '\v\.(exe|so|dll)$',
\ 'link': 'SOME_BAD_SYMBOLIC_LINKS',
\ }
" TODO: add javascript and some other languages who doesn't have ctags support
" coffee: https://gist.github.com/michaelglass/5210282
" go: http://stackoverflow.com/a/8236826/462233
" objc: http://www.gregsexton.org/2011/04/objective-c-exuberant-ctags-regex/
" rust: https://github.com/mozilla/rust/blob/master/src/etc/ctags.rust
let g:ctrlp_buftag_types = {
\ 'go' : '--language-force=go --golang-types=ftv',
\ 'coffee' : '--language-force=coffee --coffee-types=cmfvf',
\ 'markdown' : '--language-force=markdown --markdown-types=hik',
\ 'objc' : '--language-force=objc --objc-types=mpci',
\ 'rc' : '--language-force=rust --rust-types=fTm'
\ }
" *****************************************************************************
" *****************************************************************************
" Fugitive
set statusline= " clear the statusline for when vimrc is reloaded
set statusline+=%-3.3n\ " buffer number
" set statusline+=%{fugitive#statusline()}\ " Git branch
set statusline+=%{exists('g:loaded_fugitive')?fugitive#statusline():''}
set statusline+=%f\ " file name
set statusline+=%h%m%r%w " flags
set statusline+=[%{strlen(&ft)?&ft:'none'}, " filetype
set statusline+=%{strlen(&fenc)?&fenc:&enc}, " encoding
set statusline+=%{&fileformat}] " file format
set statusline+=%= " right align
set statusline+=%{synIDattr(synID(line('.'),col('.'),1),'name')}\ " highlight
set statusline+=%b,0x%-8B\ " current char
set statusline+=%-14.(%l,%c%V%)\ %<%P " offset
" NERD Tree
map <leader>n :NERDTreeToggle<CR> :NERDTreeMirror<CR>
"inoremap <F2> <esc>:NERDTreeToggle<cr>
au Filetype nerdtree setlocal nolist
let NERDTreeHighlightCursorline=1
let NERDTreeIgnore=['.vim$', '.*\.pyc$']
"let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
let NERDTreeWinSize = 30
" Searching
let g:gitgreprg="grep\\ -n\\ -R\\ --exclude='*.{xml}'"
let g:gitgrepprg="grep\\ -n\\ -R\\ --include='*.py'"
let g:gitgrepprgclass="grep\\ -n\\ -R\\ --include='*.py'\\ class\\"
let g:gitgrepprgfunction="grep\\ -n\\ -R\\ --include='*.py\\ def\\'"
function! GitGrep(args)
redraw
echo "Searching..."
let grepprg_bak=&grepprg
exec "set grepprg=" . g:gitgreprg
execute "silent! grep " . a:args . " *"
let &grepprg=grepprg_bak
botright copen
redraw!
endfunction
command! -nargs=* -complete=file G call GitGrep(<q-args>)
function! GitGrepClass(args)
redraw
echo "Searching..."
let grepprg_bak=&grepprg
exec "set grepprg=" . g:gitgrepprgclass
execute "silent! grep " . a:args . " *"
let &grepprg=grepprg_bak
botright copen
redraw!
endfunction
command! -nargs=* -complete=file Gc call GitGrepClass(<q-args>)
function! GitGrepFunction(args)
redraw
echo "Searching..."
let grepprg_bak=&grepprg
exec "set grepprg=" . g:gitgrepprgfunction
execute "silent! grep " . a:args . " *"
let &grepprg=grepprg_bak
botright copen
redraw!
endfunction
command! -nargs=* -complete=file Gf call GitGrepFunction(<q-args>)
function! GitGrepWord()
normal! "zyiw
call GitGrep(getreg('z'))
endfunction
nmap <leader>gw :call GitGrepWord()<CR>"
" Selecta
" Run a given vim command on the results of fuzzy selecting from a given shell
" command. See usage below.
function! SelectaCommand(choice_command, selecta_args, vim_command)
try
let selection = system(a:choice_command . " | selecta " . a:selecta_args)
catch /Vim:Interrupt/
" Swallow the ^C so that the redraw below happens; otherwise there will be
" leftovers from selecta on the screen
redraw!
return
endtry
redraw!
exec a:vim_command . " " . selection
endfunction
" Find all files in all non-dot directories starting in the working directory.
" Fuzzy select one of those. Open the selected file with :e.
nnoremap <leader>f :call SelectaCommand("find * -type f", "", ":e")<cr>
" LANGUAGE STUFF
augroup ft_markdown
au!
set wrap
set linebreak
set nolist " list disables linebreak
set textwidth=0
set wrapmargin=0
augroup END
augroup ft_elm
au!
nnoremap <leader>el :ElmEvalLine<CR>
vnoremap <leader>es :<C-u>ElmEvalSelection<CR>
nnoremap <leader>em :ElmMakeCurrentFile<CR>
let g:elm_format_autosave = 1
augroup END
augroup ft_haskell
au!
autocmd FileType haskell map <silent> <leader><cr> :noh<cr>:GhcModTypeClear<cr>:SyntasticReset<cr>
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
let g:haddock_browser = "open"
au Bufenter *.hs compiler ghc
" 1 tab == 2 spaces
set shiftwidth=2
set tabstop=2
" Pretty unicode haskell symbols
let g:haskell_conceal_wide = 1
let g:haskell_conceal_enumerations = 1
let hscoptions="𝐒𝐓𝐄𝐌xRtB𝔻w"
set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines
augroup END
augroup ft_javascript
au!
let g:syntastic_javascript_checkers = ['jsxhint']
augroup END
augroup ft_python
au!
au FileType python setlocal omnifunc=pythoncomplete#Complete
" Flake 8
let g:syntastic_python_checkers=['flake8']
let g:syntastic_python_flake8_args='--ignore=W391'
au FileType python nnoremap <leader>s :SyntasticCheck<CR>
au FileType python nnoremap zj :lnext<CR>zz
au FileType python nnoremap zk :lprev<CR>zz
" Python
" Rope
let g:pymode_folding=0
let g:pymode_lint_ignore = "W391"
let g:pymode_lint = 0
let g:pymode_lint_cwindow = 0
let g:pymode_run = 0
"let g:pymode_rope_guess_project = 0
" Pyflakes
let g:pyflakes_use_quickfix = 1
" Full python syntax highlighting
let python_highlight_all=1
" Makegreen
au FileType python map <localleader>t :call MakeGreen()<cr>
au FileType python let g:makegreen_stay_on_file=1
"autocmd BufNewFile,BufRead *.py compiler nose
" For now set all tests to nose. But we'll probably want something better long
" term. Like using a make file...
au FileType python autocmd BufNewFile,BufRead *.* compiler nose
augroup END
augroup ft_go
au!
map <localleader>t :wa<CR> :GolangTestCurrentPackage<CR>
map <localleader>tf :wa<CR> :GolangTestFocused<CR>
" Import package under cursor.
au FileType go nmap <Leader>i <Plug>(go-import)
" Open Godoc for word.
"au FileType go nmap <Leader>d <Plug>(go-doc)
au FileType go nmap <C-c>d <Plug>(go-doc)
" Run go <command>
au FileType go nmap <localleader>r <Plug>(go-run)
au FileType go nmap <localleader>b <Plug>(go-build)
"au FileType go nmap <localleader>t <Plug>(go-test)
" Goto declaration for word under cursor.
"au FileType go nmap gd <Plug>(go-def)
au FileType go nmap <C-c>g <Plug>(go-def)
" Open declaration for word under curos in split, vertical, tab
au FileType go nmap <C-c>gs <Plug>(go-def-split)
au FileType go nmap <C-c>gv <Plug>(go-def-vertical)
au FileType go nmap <C-c>gt <Plug>(go-def-tab)
let g:go_fmt_command = "goimports"
augroup END
function! ZoomMode()
if exists("t:zoom_mode_enabled")
" If zoom mode is on, make windows a size usable for coding as we jump
" between them.
set winwidth=90
" We have to have a winheight bigger than we want to set winminheight.
" But if we set winheight to be huge before winminheight, the
" winminheight set will fail.
set winheight=15
set winminheight=15
set winheight=999
" Mark ZoomMode as off.
unlet t:zoom_mode_enabled
echo " zoom"
else
" If zoom mode is not on, set resize limits much lower.
set winwidth=20
set winheight=15
set winminheight=1
set winheight=1
" Mark that ZoomMode is on.
let t:zoom_mode_enabled = 1
echo "nozoom"
endif
endfunction
" Toggle zoom mode on/off.
map <leader>z :call ZoomMode()<cr>
" Environments GUI
if has('gui_running')
"set guifont=Inconsolota:h11
set guifont=Inconsolota-dz for Pow:h11
set guicursor=n-c:block-Cursor-blinkon0
set guicursor+=v:block-vCursor-blinkon0
set guicursor+=i-ci:ver20-iCursor
else
" Non-MacVim GUI, like Gvim
hi ColorColumn ctermbg=0 guibg=#1c1c1c
hi CursorLine ctermbg=236 guibg=#DDDDDD
hi Normal guibg=#cccccc ctermbg=233
hi NonText guibg=#cccccc ctermbg=233
" Vimux
function! VimuxSlime()
call VimuxSendText(@v)
call VimuxSendKeys("Enter")
endfunction
vmap <LocalLeader>vs "vy :call VimuxSlime()<CR>
nmap <LocalLeader>vs vip<LocalLeader>vs<CR>
" Vim TMUx
map <Leader>vp :VimuxPromptCommand <CR>
" Run last command executed by RunVimTmuxCommand
map <Leader>vl :RunLastVimTmuxCommand<CR>
" Inspect runner pane
map <Leader>vi :InspectVimTmuxRunner<CR>
let VimuxHeight = "28"
let VimuxUseNearestPane = 1
let g:VimuxOrientation = "h"
" for tmux to automatically set paste and nopaste mode at the time pasting (as
" happens in VIM UI)
function! WrapForTmux(s)
if !exists('$TMUX')
return a:s
endif
let tmux_start = "\<Esc>Ptmux;"
let tmux_end = "\<Esc>\\"
return tmux_start . substitute(a:s, "\<Esc>", "\<Esc>\<Esc>", 'g') . tmux_end
endfunction
let &t_SI .= WrapForTmux("\<Esc>[?2004h")
let &t_EI .= WrapForTmux("\<Esc>[?2004l")
function! XTermPasteBegin()
set pastetoggle=<Esc>[201~
set paste
return ""
endfunction
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()
endif
function! ZoomMode()
if exists("t:zoom_mode_enabled")
" If zoom mode is on, make windows a size usable for coding as we jump
" between them.
set winwidth=90
" We have to have a winheight bigger than we want to set winminheight.
" But if we set winheight to be huge before winminheight, the
" winminheight set will fail.
set winheight=15
set winminheight=15
set winheight=999
" Mark ZoomMode as off.
unlet t:zoom_mode_enabled
echo " zoom"
else
" If zoom mode is not on, set resize limits much lower.
set winwidth=20
set winheight=15
set winminheight=1
set winheight=1
" Mark that ZoomMode is on.
let t:zoom_mode_enabled = 1
echo "nozoom"
endif
endfunction
" Toggle zoom mode on/off.
map <leader>z :call ZoomMode()<cr>
" NEO VIM PARTS
if !has('nvim')
set ttymouse=xterm2
endif
if exists(':tnoremap')
tnoremap <Esc> <C-\><C-n>
endif