-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
793 lines (662 loc) · 24.9 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
" Vundle setup
filetype off
" set the runtime path to include Vundle and initialize
let g:textobj_entire_no_default_key_mappings=1
if has("win32")
set rtp+=$HOME/vimfiles/bundle/Vundle.vim/
call vundle#begin('$USERPROFILE/vimfiles/bundle/')
else
set rtp+=$HOME/.vim/bundle/Vundle.vim/
call vundle#begin()
endif
" Plugin 'git://github.com/dhruvasagar/vim-prosession'
" Plugin 'git://github.com/eagletmt/ghcmod-vim'
" Plugin 'git://github.com/endel/vim-github-colorscheme'
" Plugin 'git://github.com/goldfeld/vim-seek'
" Plugin 'git://github.com/justinmk/vim-sneak'
" Plugin 'git://github.com/kana/vim-smartword'
" Plugin 'git://github.com/kshenoy/vim-signature'
" Plugin 'git://github.com/junegunn/vim-easy-align'
" Plugin 'git://github.com/nice/sweater'
Plugin 'git://github.com/freeo/vim-kalisi'
" Plugin 'git://github.com/Julian/vim-textobj-brace'
" Plugin 'git://github.com/Julian/vim-textobj-variable-segment.git'
" Plugin 'git://github.com/Lokaltog/vim-easymotion'
" Plugin 'git://github.com/Shougo/neocomplete.vim'
" Plugin 'git://github.com/Shougo/vimproc.vim'
Plugin 'git://github.com/SirVer/ultisnips'
" Plugin 'git://github.com/Twinside/vim-haskellConceal'
Plugin 'git://github.com/airblade/vim-gitgutter'
" Plugin 'git://github.com/altercation/vim-colors-solarized'
" Plugin 'git://github.com/beloglazov/vim-textobj-quotes'
Plugin 'git://github.com/bronson/vim-visual-star-search'
Plugin 'git://github.com/dag/vim-fish'
Plugin 'git://github.com/dag/vim2hs'
Plugin 'git://github.com/dan-t/vim-hdevtools'
" Plugin 'git://github.com/eagletmt/neco-ghc'
" Plugin 'git://github.com/glts/vim-textobj-comment'
Plugin 'git://github.com/gmarik/Vundle.vim'
Plugin 'git://github.com/godlygeek/tabular'
" Plugin 'git://github.com/honza/vim-snippets'
Plugin 'git://github.com/itchyny/lightline.vim'
" Plugin 'git://github.com/kana/vim-textobj-entire'
" Plugin 'git://github.com/kana/vim-textobj-lastpat'
" Plugin 'git://github.com/kana/vim-textobj-line'
" Plugin 'git://github.com/kana/vim-textobj-user'
" Plugin 'git://github.com/kana/vim-textobj-diff'
" Plugin 'git://github.com/lervag/vim-latex'
Plugin 'git://github.com/majutsushi/tagbar'
" Plugin 'git://github.com/michaeljsmith/vim-indent-object'
" Plugin 'git://github.com/mileszs/ack.vim'
" Plugin 'git://github.com/nanotech/jellybeans.vim'
" Plugin 'git://github.com/rbonvall/vim-textobj-latex'
" Plugin 'git://github.com/scrooloose/syntastic'
" Plugin 'git://github.com/sgur/vim-textobj-parameter'
Plugin 'git://github.com/sjl/gundo.vim'
Plugin 'git://github.com/chrisbra/Colorizer'
" Plugin 'git://github.com/thinca/vim-textobj-between'
Plugin 'git://github.com/tommcdo/vim-exchange'
Plugin 'git://github.com/tomtom/tcomment_vim'
Plugin 'git://github.com/tpope/vim-abolish'
Plugin 'git://github.com/tpope/vim-dispatch'
Plugin 'git://github.com/maxbrunsfeld/vim-yankstack'
Plugin 'git://github.com/tpope/vim-eunuch'
Plugin 'git://github.com/tpope/vim-fugitive'
Plugin 'git://github.com/tpope/vim-obsession'
Plugin 'git://github.com/tpope/vim-repeat'
Plugin 'git://github.com/tpope/vim-sensible'
Plugin 'git://github.com/tpope/vim-surround'
Plugin 'git://github.com/tpope/vim-unimpaired'
Plugin 'git://github.com/vim-scripts/ReplaceWithRegister'
Plugin 'git://github.com/vim-scripts/UnconditionalPaste'
" Plugin 'git://github.com/vim-scripts/argtextobj.vim'
" Plugin 'git://github.com/xolox/vim-misc'
" Plugin 'git://github.com/yegappan/mru'
Plugin 'git://github.com/zeis/vim-kolor'
call vundle#end()
call yankstack#setup() " initialization to hijack key bindings
" Basic
set encoding=utf-8
set updatetime=1000 " ms
set confirm
" Minimal pathogen setup…
" execute pathogen#infect()
syntax on
filetype plugin indent on
set dictionary=/usr/share/hunspell/en_GB.dic,/usr/share/hunspell
" Backup
" set no ~ files, no .swp files, updatecount = 0 makes swapfile option irrelevant
set nobackup
set noswapfile
" Disable swap files
set updatecount=0
" Terminal
" if !has('gui')
" set term=$TERM " Make arrow and other keys work
" endif
if &shell =~# 'fish$'
set shell=bash\ --login
endif
set ttyfast
set title " terminal title
" mouse
set mouse=a " Automatically enable mouse usage
set mousehide " Hide the mouse cursor while typing
" viminfo stores the the state of your previous editing session
set viminfo+=n~/.vim/viminfo
" session options
set sessionoptions+=localoptions
set sessionoptions+=resize
set sessionoptions+=winpos
" Move undo and info files to .vim
if exists("+undofile")
" 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/undo') == 0
silent !mkdir -p ~/.vim/undo > /dev/null 2>&1
endif
set undodir=~/.vim/undo/
set undofile
endif
" Display
" → ⎆ ⇨ ⟸ ⥰ ⬱ ␊ ⫘ ⩊ ⏖ ↔ ↪ ⨭ ◖ 𝌻 ⌇ ⌒ …
set showbreak=…
set t_Co=256 " must be before colorscheme
set background=dark
colorscheme molokai
" highlight normal ctermbg=234
" List invisible characters
set list
" set listchars=tab:➝\ ,eol:¬
set listchars=tab:⤑\ ,extends:❯,precedes:❮
"· ⇾ ⇨ ⇀ ➝ → ⇥ ⟶ ⟼ ⤏ ⧐ ―
set cursorline
set nowrap
set textwidth=80
set formatoptions=qrn1
set relativenumber
set number
" c: autowrap comments
" t: autowrap text
" r: automatically insert comment leader
" q: allow formatting of comments with gq
" a: autoformat paragraphs
" n: recognize numbered lists
" 1: avoid line break after 1-letter word.
" j: remove superflous comments when joining lines
set formatoptions=cqrn1lj
set relativenumber
" Search
set showmatch
set matchtime=5
" Fold presentation
set foldtext=MyFoldText()
function! MyFoldText()
let line = getline(v:foldstart)
if match( line, '^[ \t]*\(\/\*\|\/\/\)[*/\\]*[ \t]*$' ) == 0
let initial = substitute( line, '^\([ \t]\)*\(\/\*\|\/\/\)\(.*\)', '\1\2', '' )
let linenum = v:foldstart + 1
while linenum < v:foldend
let line = getline( linenum )
let comment_content = substitute( line, '^\([ \t\/\*]*\)\(.*\)$', '\2', 'g' )
if comment_content != ''
break
endif
let linenum = linenum + 1
endwhile
let sub = initial . ' ' . comment_content
else
let sub = line
let startbrace = substitute( line, '^.*{[ \t]*$', '{', 'g')
if startbrace == '{'
let line = getline(v:foldend)
let endbrace = substitute( line, '^[ \t]*}\(.*\)$', '}', 'g')
if endbrace == '}'
let sub = sub.substitute( line, '^[ \t]*}\(.*\)$', '...}\1', 'g')
endif
endif
endif
let n = v:foldend - v:foldstart + 1
let info = " " . n . " lines"
let sub = sub . " "
let num_w = getwinvar( 0, '&number' ) * getwinvar( 0, '&numberwidth' )
let fold_w = getwinvar( 0, '&foldcolumn' )
" ↲ ↪ ⧽ 【 ▛ ▟ 】 ⤹ ⬇ ∋ 𝌞 ■ ▌ ▟ ▚ ▼ ◤ ┏ ⎩ ⎝ ⤥ ( ❨ ⟮ ⟫ ⎡ ▏ ▍ ▐
let rsign = '⤶'
let lsign = '𝌻'
let sub = lsign . strpart( sub, 0, winwidth(0) - strlen( info ) - num_w - fold_w - 1 )
return sub . rsign . info
endfunction
" Behavior
set autochdir " sync current directory with current file
set lazyredraw " avoid redrawing screen while macro is running
set virtualedit=onemore,block " Allow for cursor beyond last character
" set iskeyword-=_ " treat _ as a word boundary
" autocompletions
set completeopt=menuone,preview
set complete+=kspell
set omnifunc=syntaxcomplete#Complete
set tags=./.tags,.tags,/home/s/.vim/tags;
" Completion
" to be able to use wildchar in macros
set wildcharm=<C-Z>
set wildmenu
set wildmode=list:longest,full
set wildignore=*.swp,*.acn,*.aux,*.bak,*.bmp,*.exe,*.glo,*.hi,*.jpg,*.log,*.o,*.out,*.pdf,*.pyc,*.thm,*.toc,*.xdy,*~,*.gz,*.xz,*.tar,*.zip,*.gz(busy),*.png
set wildignorecase
" Fold
" set foldclose=all
set foldlevel=2
" Autocommands
" hide cursorline when inserting
augroup cline
autocmd!
autocmd InsertEnter * set nocursorline
autocmd FocusGained * set cursorline
augroup END
" set only cursorline for active window
augroup showActiveWindow
autocmd!
autocmd BufEnter * set cursorline
autocmd BufLeave * set nocursorline
augroup END
augroup behaviour
autocmd!
" Save all on lost focus if buffer has name
autocmd FocusLost * silent! wall
" Strip trailing whitespace on save
autocmd BufWritePre * call myautoloads#StripTrailingWhitespaces()
augroup END
" equalize window on resized
augroup windows
autocmd!
autocmd VimResized * wincmd =
augroup END
augroup fileTypes
autocmd!
" Treat .rss files as XML
autocmd BufNewFile,BufRead *.rss setfiletype xml
autocmd FileType c,h setlocal tags+=~/.vim/tags/c
autocmd FileType cpp,hpp setlocal tags+=~/.vim/tags/c++
autocmd FileType py setlocal tags+=~/.vim/tags/py_2.7,~/.vim/tags/tags_py_3.2
" Enable omni completion.
autocmd FileType cpp setlocal omnifunc=omni#cpp#complete#Main
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 python setlocal tabstop=4 noexpandtab shiftwidth=4
autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" ISSUE doesn't work autocmd FileType markdown setlocal makeprg=markdown\ %\ >%.html
autocmd BufEnter *.md setlocal makeprg=markdown\ %\ >%:t:r.html
autocmd BufWritePost vimrc source $MYVIMRC
augroup END
set formatprg=par\ -w70
set smartindent
set splitright
set splitbelow
" Automatically update file if it has been modified outside vim
set autoread
set autowrite
" hide buffer instead of closing them
set hidden
set scrolljump=20
set sidescroll=1
set sidescrolloff=10
set sessionoptions=blank,buffers,curdir,folds,tabpages,winsize
" Tabbing
" search term contains upper case
set smarttab
set softtabstop=4
set shiftwidth=4
set shiftround
set tabstop=4
" conceal feature
" conceal everything but sub / superscripts
let g:tex_conceal="adgm"
" searching
set ignorecase " when searching
set smartcase " case-sensitife if uppercase in expression
" highlight as you type
set incsearch
set gdefault " default global on substitute command
" hack: avoid inserting characters instead of the action of an arrow in
" terminal
imap <ESC>oA <ESC>ki
imap <ESC>oB <ESC>ji
imap <ESC>oC <ESC>li
imap <ESC>oD <ESC>hi
" Keymaps
let mapleader = "\\"
let maplocalleader = "-"
" Error on quickly quitting
nnoremap :W :w
" Repeat last Ex command
nnoremap <leader>q q:k<CR>
" Exit insert mode and write
inoremap <C-W> <esc>:w<CR>
" Kill window
nnoremap K :q<CR>
" Go to matching
nnoremap <Tab> %
" Bufferlist
nnoremap <Leader>b :b <C-Z>
" Display search matches in center of screen
nnoremap n nzzzv
nnoremap N Nzzzv
" Same when jumping around
nnoremap g; g;zz
nnoremap g, g,zz
nnoremap <c-o> <c-o>zz
nnoremap <c-i> <c-i>zz
" Easier start / end move in line
noremap H ^
noremap L g_
" Format
nnoremap Q gqip
vnoremap Q gq
" Sudo write
cnoremap w!! SudoWrite
" Execute last ex command
nnoremap <leader>q q:k<CR>
" LEARN
inoremap <C-W> <esc>:w<CR>
" Vim-textobj-entire
xmap aE <Plug>(textobj-entire-a)
omap aE <Plug>(textobj-entire-a)
xmap iE <Plug>(textobj-entire-i)
omap iE <Plug>(textobj-entire-i)
" Find last match in line
nnoremap gf $F
" Complete word from line above / under
"<Esc>gi ensures Insert (not Replace) mode
" inoremap <C-l> <Esc>gi<Space><Esc>gkywgjvpa
" inoremap <C-b> <Esc>gi<Space><Esc>gjywgkvpa
" Dmenu integration
" map <leader-t> :call DmenuOpen("tabe")<cr>
" map <leader-f> :call DmenuOpen("e")<cr>
" Strip the newline from the end of a string
function! Chomp(str)
return substitute(a:str, '\n$', '', '')
endfunction
" Find a file and pass it to cmd
function! DmenuOpen(cmd)
let fname = Chomp(system("locate `pwd` | dmenu -i -l 20 -p " . a:cmd))
if empty(fname)
return
endif
execute a:cmd . " " . fname
endfunction
" Yank to end of line
nnoremap Y yg_
" Dot command in visual mode
vnoremap . :norm.<CR>
" Move in insert
inoremap <C-O>b <Esc>bi
inoremap <C-O>w <Esc>wi
inoremap <C-O>e <Esc>ei
inoremap <C-O>h <Esc>eh
inoremap <C-O>j <Esc>ej
inoremap <C-O>k <Esc>ek
inoremap <C-O>l <Esc>el
" Help
cabbrev h tab h
" Mru
nnoremap <Leader>m :Mru<Space>
" Diff
nnoremap do do]c
nnoremap dp do]c
" Symbols
" imap ... …
" imap -> →
imap :) ☺
imap :-) ☺
" I use the colon more often than the semicolon
nnoremap : ;
nnoremap ; :
cnoremap : ;
cnoremap ; :
xnoremap : ;
xnoremap ; :
vnoremap : ;
vnoremap ; :
" keep only marked area
vnoremap o ygg"_dGpkdd
" Window focus and create
nnoremap <Leader>h : call myautoloads#WinMove('h')<cr>
nnoremap <Leader>k : call myautoloads#WinMove('k')<cr>
nnoremap <Leader>l : call myautoloads#WinMove('l')<cr>
nnoremap <Leader>j : call myautoloads#WinMove('j')<cr>
" window rotate
nnoremap <A-w>r <C-W>r
" Window resize
nnoremap <left> :12wincmd <<cr>
nnoremap <right> :12wincmd ><cr>
nnoremap <up> :12wincmd +<cr>
nnoremap <down> :12wincmd -<cr>
vnoremap <right> :12wincmd ><cr>
vnoremap <left> :12wincmd <<cr>
vnoremap <up> :12wincmd +<cr>
vnoremap <down> :12wincmd -<cr>
" alternative resizing
nnoremap <silent> <Leader>+ :exe "resize " . (winheight(0) * 3/2)<CR>
nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR>
" map go to tags interactively
noremap <C-]> g<C-]>
" remap command line serch
cnoremap <C-j> <Up>
cnoremap <C-k> <Down>
" replace mode: treat tabs as several spaces
nnoremap R gR
" Esc remappings
inoremap jk <Esc>
inoremap <Esc> <Esc>
" open url in browser
nnoremap <C-LeftMouse> :call myautoloads#Browser()<cr>
" Indent whole file
noremap g= mzgg=G`z<CR>m'z
" delete text to black hole
nnoremap <Leader>d "_d
" Visual shifting (does not exit Visual mode)
vnoremap < <gv
vnoremap > >gv
" Visual line repeat {{{2
xnoremap . :normal .<CR>
xnoremap @ :<C-u>call myautoloads#ExecuteMacroOverVisualRange()<CR>
" Count folded lines as several
nnoremap j gj
nnoremap k gk
" Bubbl multiple lines in visual mode
vmap <C-k> [egv
vmap <C-j> ]egv
" Visually select the text that was last edited/pasted
nnoremap gV `[v`]
" Paste
nnoremap <Leader>v :Paste<CR>
vnoremap <Leader>v :Paste<CR>
" make * and # search work in visual mode too
xnoremap * :<C-u>call myautoloads#VSetSearch('/')<CR>/<C-R>=@/<CR><CR>
xnoremap # :<C-u>call myautoloads#VSetSearch('?')<CR>?<C-R>=@/<CR><CR>
" recursively vimgrep for word under cursor or selection if you hit leader-star
nnoremap <leader>* :execute 'noautocmd vimgrep /\V' . substitute(escape(expand("<cword>"), '\'), '\n', '\\n', 'g') . '/ **'<CR>
vnoremap <leader>* :<C-u>call myautoloads#VSetSearch()<CR>:execute 'noautocmd vimgrep /' . @/ . '/ **'<CR>
" search without regex normally
cnoremap s/ s/\v
nnoremap / /\v
vnoremap / /\v
" Tabular.vim
cabbrev tab Tabularize /
" Tasklist, todo, bug, issue
command! Issue :execute 'vimgrep ISSUE '.expand('%') | :copen | :cc
command! Bug :execute 'vimgrep BUG '.expand('%') | :copen | :cc
command! Todo :execute 'vimgrep TODO '.expand('%') | :copen | :cc
" Plugins
" Bufexplorer
let g:bufExplorerShowTabBuffer = 1
" Easyclip
let g:EasyClipUseSubstituteDefaults = 1
let g:EasyClipDoSystemSync = 0
" Reenable marks
nnoremap gm m
" Syntastic
let g:syntastic_haskell_checkers = ['hdevtools']
" Easytags
let g:easytags_async = 1
let g:easytags_dynamic_files = 1
" let g:easytags_by_filetype = '~/.vim/filetype_tags'
let g:easytags_file = '~/.vim/tags'
let g:easytags_languages = {
\ 'haskell': {
\ 'cmd': '~/.cabal/bin/lushtags',
\ 'args': [],
\ 'fileoutput_opt': '-f',
\ 'stdout_opt': '-f-',
\ 'recurse_flag': '-R'
\ }
\}
" Gitgutter
" ⊛ ⁕ ✵ ⚝ ✦ ✶ ❉ ᶯ ␡ ⎌' ⥃' ↚ ⇄
let g:gitgutter_sign_added = '→'
let g:gitgutter_sign_removed = '␡'
let g:gitgutter_sign_modified = '↔'
let g:gitgutter_sign_modified_removed = '↜'
nnoremap <leader>n :call NextHunkAndView()<cr>
nnoremap <leader>p :call PrevHunkAndView()<cr>
function! NextHunkAndView()
call gitgutter#hunk#next_hunk(1)
call gitgutter#preview_hunk()
endfunction
function! PrevHunkAndView()
call gitgutter#hunk#prev_hunk(1)
call gitgutter#preview_hunk()
endfunction
" Lightline
let g:lightline = {
\ 'component': {
\ 'lineinfo': ' %3l:%-2v',
\ },
\ 'component_function': {
\ 'readonly': 'MyReadonly',
\ 'fugitive': 'MyFugitive'
\ },
\ 'subseparator': { 'left': '', 'right': '' }
\ }
function! MyReadonly()
return &readonly ? '' : ''
endfunction
function! MyFugitive()
if exists("*fugitive#head")
let _ = fugitive#head()
" return strlen(_) ? '⎇'._ : ''
return strlen(_) ? '⎇'._ : ''
endif
return ''
endfunction
" neocomplete
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#sources#syntax#min_keyword_length = 3
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return pumvisible() ? neocomplete#close_popup() . "\<Esc>" : "\<CR>"
endfunction
ret
inoremap <expr><C-g> neocomplete#undo_completion()
inoremap <expr><C-l> neocomplete#complete_common_string()
inoremap <expr><Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr><C-Tab> pumvisible() ? "\<C-n><esc>" : "\<Tab>"
" haskell
highlight HaskellType ctermbg=232
let g:ghcmod_type_highlight = 'HaskellType'
" ultisnips
let g:UltiSnipsExpandTrigger="<C-a>"
let g:UltiSnipsJumpForwardTrigger="<C-j>"
let g:UltiSnipsJumpBackwardTrigger="<C-k>"
let g:UltiSnipsEditSplit="vertical"
set rtp+=~/.vim/UltiSnips
" airline
let g:airline#extensions#bufferline#enabled = 1
let g:airline#extensions#syntastic#enabled = 1
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#fnamemod = 1
let g:airline#extensions#tagbar#enabled = 1
let g:airline#extensions#hunks#enabled = 1
let g:airline#extensions#hunks#non_zero_only = 0
" let g:airline#extensions#tagbar#flags = 'f'
" let g:airline#extensions#tagbar#flags = 's'
" let g:airline#extensions#tagbar#flags = 'p'
let g:airline#extensions#whitespace#enabled = 0
let g:airline_exclude_preview = 1
let g:airline_inactive_collapse = 1
let g:airline_powerline_fonts = 1
let g:airline_theme = "powerlineish"
" Most recently used
let MRU_File = $HOME . "/.vim/mru-files"
let MRU_Window_Height = 20
" YankStack
let g:yankstack_map_keys = 0
nmap <c-p> <Plug>yankstack_substitute_older_paste
nmap <c-n> <Plug>yankstack_substitute_newer_paste
" nerdtree
" autocmd vimenter * if !argc() | NERDTree | endif
noremap qnn :NERDTreeToggle<CR>
" close vim if only nerdtree is open
"autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" necoghc
let g:necoghc_enable_detailed_browse = 1
" Tagbar
nnoremap <Leader>t :TagbarToggle<CR>
let g:tagbar_autoclose = 1
let g:tagbar_autofocus = 1
" Functions
" Diff of current content with saved content
function! s:DiffWithSaved()
let filetype=&ft
diffthis
vnew | r # | normal! 1Gdd
diffthis
exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
endfunction
com! DiffSaved call s:DiffWithSaved()
" paste convenient
function! Paste()
set paste
normal "+p
set nopaste
endfunction
command! Paste call Paste()<CR>
" remove duplicates
function! RemoveDuplicates()
%sort
g/^\(.*\)$\n\1$/d
endfunction
" Startup
if glob("Session.vim") != ''
silent source Session.vim
endif
" " Text objects
" call textobj#user#plugin('number', {
" \ 'natural': {
" \ 'pattern': '\v\d+',
" \ 'select': ['ad', 'id']
" \ },
" \ 'frac': {
" \ 'pattern': '\v\d+(\.\d+)?\/\d+(\.\d+)?',
" \ 'select': ['af', 'if'],
" \ },
" \ 'real': {
" \ 'pattern': '\d\+\(\.\d\+\)\?',
" \ 'select': ['an', 'in'],
" \ }
" \ })
"
" call textobj#user#plugin('block', {
" \ 'vertical': {
" \ 'select-a-function': 'VerticalBlockOuter',
" \ 'select-a': 'aV',
" \ 'select-i-function': 'VerticalBlockInner',
" \ 'select-i': 'iV',
" \ },
" \ 'horizontal': {
" \ 'select-a-function': 'HorizontalBlockOuter',
" \ 'select-a': 'aH',
" \ 'select-i-function': 'HorizontalBlockInner',
" \ 'select-i': 'iH',
" \ },
" \ })
"
" set rtp+=~/.vim/pythonx
" python << endpython
" from block_object import find_block
" endpython
"
" function! VerticalBlockInner()
" python << endpython
" find_block()
" endpython
" endfunction
"
" function! HorizontalBlockInner()
" python << endpython
" find_block(vertical = False)
" endpython
" endfunction
"
" function! VerticalBlockOuter()
" python << endpython
" find_block(outer = True)
" endpython
" endfunction
"
" function! HorizontalBlockOuter()
" python << endpython
" find_block(vertical = False, outer = True)
" endpython
" endfunction
" TODO
" unset hlsearch after substitute command
" fix paste command
" vim: set ft=vim foldmethod=indent: