-
Notifications
You must be signed in to change notification settings - Fork 21
/
vimrc
1720 lines (1261 loc) · 41.5 KB
/
vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
" ----------------------------------------------------------------------------
" FILE: .vimrc
" DESCRIPTION: Vim configuration file
" AUTHOR: Sorin Ionescu <[email protected]>
" VERSION: 1.3.26
" ----------------------------------------------------------------------------
" Version Check ---------------------------------------------------------- {{{
if v:version < 703
echo '.vimrc requires Vim 7.3 or greater'
finish
endif
" }}}
" Bundles ---------------------------------------------------------------- {{{
" Turn off vi compatibility.
set nocompatible
" Turning filetype off is necessary to load ftdetect files.
filetype off
" Install Vundle for bundles to work:
" git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" General ---------------------------------------------------------------- {{{
" Manages Vim bundles.
Bundle 'gmarik/vundle'
" A better status bar.
Bundle 'Lokaltog/vim-powerline'
" Identifies file indentation.
Bundle 'Raimondi/YAIFA'
" Aligns text.
Bundle 'godlygeek/tabular'
" Tree undo.
Bundle 'sjl/gundo.vim'
" Use the repeat command (.) with plugins.
Bundle 'tpope/vim-repeat'
" Provides pairs of bracket mappings for buffer, file navigation and editing.
Bundle 'tpope/vim-unimpaired'
" Renames the file in the current buffer.
Bundle 'vim-scripts/Rename2'
" Kills a buffer without closing the split.
Bundle 'vim-scripts/bufkill.vim'
" Emacs-style scratch buffer.
Bundle 'vim-scripts/scratch'
" Escape ANSI codes.
Bundle 'vim-scripts/AnsiEsc.vim'
" Resizes the current buffer to accommodate its content.
Bundle 'roman/golden-ratio'
" Show marks in a gutter.
Bundle 'vim-scripts/ShowMarks7'
" Easily navigate to a letter.
Bundle 'Lokaltog/vim-easymotion'
" History of yanks, changes, and deletes.
Bundle 'vim-scripts/YankRing.vim'
" }}}
" Color Scheme ----------------------------------------------------------- {{{
" A usable color scheme.
Bundle 'altercation/vim-colors-solarized'
Bundle 'chriskempson/vim-tomorrow-theme'
" }}}
" Syntax ----------------------------------------------------------------- {{{
Bundle 'tpope/vim-markdown'
" Bundle 'timcharper/textile.vim'
" Bundle 'andrewschleifer/nu-vim'
" }}}
" File Navigation -------------------------------------------------------- {{{
" Buffer and file navigation.
Bundle 'kien/ctrlp.vim'
" Bundle 'wincent/Command-T'
" Tag manager.
" Bundle 'kien/tabman.vim'
" }}}
" Programming ------------------------------------------------------------ {{{
" A better paste.
Bundle 'sickill/vim-pasta'
" Sends the buffer contents to a REPL.
" Bundle 'jpalardy/vim-slime'
" A better grep.
Bundle 'mileszs/ack.vim'
" Searches a file for todo, fixme.
Bundle 'vim-scripts/TaskList.vim'
" Browse tags of source code files.
Bundle 'majutsushi/tagbar'
" Syntax checking through external checkers.
Bundle 'scrooloose/syntastic'
" Comment and uncomment code.
Bundle 'tomtom/tcomment_vim'
" Insert-completion via the tab key.
Bundle 'ervandew/supertab'
" Colors parenthesis.
Bundle 'kien/rainbow_parentheses.vim'
" Surround selection with quotes, parenthesis, etc.
Bundle 'tpope/vim-surround'
" Automatically closes quotes, parenthesis, brackets, etc.
Bundle 'Raimondi/delimitMate'
" Automatically closes functions, blocks, etc.
Bundle 'tpope/vim-endwise'
" Allows for writing user-defined text objects.
Bundle 'kana/vim-textobj-user'
" Indentation-based text objects.
Bundle 'michaeljsmith/vim-indent-object'
" Displays indent levels.
Bundle 'nathanaelkane/vim-indent-guides'
" Configures % to match more than just single characters.
Bundle 'vim-scripts/matchit.zip'
" TextMate-like snippets.
" Bundle 'msanders/snipmate.vim'
" Snippets for snipMate.
" Bundle 'scrooloose/snipmate-snippets'
" }}}
" Version Control -------------------------------------------------------- {{{
" Git syntax highlighting.
Bundle 'tpope/vim-git'
" Git integration.
Bundle 'tpope/vim-fugitive'
" Git commit browser.
Bundle 'int3/vim-extradite'
" Gist paste.
Bundle 'mattn/gist-vim'
" Merge conflict resolution.
Bundle 'sjl/splice.vim'
" }}}
" Web Development -------------------------------------------------------- {{{
" Expands condensed HTML.
Bundle 'mattn/zencoding-vim'
" Translates markup languages into HTML for previewing.
Bundle 'matthias-guenther/hammer.vim'
" HTML langauge.
Bundle 'othree/html5.vim'
" Validate HTML files.
Bundle 'sorin-ionescu/vim-htmlvalidator'
" CSS language.
Bundle 'https://github.com/ChrisYip/Better-CSS-Syntax-for-Vim.git'
" LESS (dynamic CSS) language.
" Bundle 'groenewege/vim-less'
" JavaScript language.
Bundle 'pangloss/vim-javascript'
" Compiler for JavaScript Lint.
" Bundle 'vim-scripts/compilerjsl.vim'
" jQuery JavaScript framework.
" Bundle 'vim-scripts/jQuery'
" CoffeeScript language.
Bundle 'kchmck/vim-coffee-script'
" }}}
" Ruby/Rails ------------------------------------------------------------- {{{
" Ruby langauge.
Bundle 'vim-ruby/vim-ruby'
" Ruby refactoring tool (dependency: matchit).
" Bundle 'ecomba/vim-ruby-refactoring'
" Text object for selecting ruby blocks (dependency: matchit).
Bundle 'nelstrom/vim-textobj-rubyblock'
" Quickly converts Ruby blocks between {} and begin/end.
Bundle 'sorin-ionescu/vim-ruby-block-conv'
" Debug Ruby scripts and applications.
" Bundle 'astashov/vim-ruby-debugger'
" Runs bundler commands.
" Bundle 'tpope/vim-bundler'
" Runs rake commands.
" Bundle 'tpope/vim-rake'
" Ruby on Rails application development.
" Bundle 'tpope/vim-rails'
" Haml, Sass, and SCSS template langauges.
" Bundle 'tpope/vim-haml'
" Liquid template langauge.
" Bundle 'tpope/vim-liquid'
" Runs Ruby tests, RSpec, shoulda, cucumber.
" Bundle 'janx/vim-rubytest'
" Runs RSpec tests (dependency: hpricot gem).
" Bundle 'skwp/vim-rspec'
" A macro behavior-driven development testing framework.
" Bundle 'tpope/vim-cucumber'
" A micro behavior-driven development testing framework.
" Bundle 'tsaleh/vim-shoulda'
" }}}
" Python ----------------------------------------------------------------- {{{
" Almost everything needed for Python programming.
" Bundle 'klen/python-mode'
" }}}
" Org-Mode --------------------------------------------------------------- {{{
" Emacs Org-Mode for Vim.
" Bundle 'jceb/vim-orgmode'
" }}}
" }}}
" General Settings ------------------------------------------------------- {{{
" SECURE: Do not parse mode comments in files.
set modelines=0
" Large undo levels.
set undolevels=1000
" Size of command history.
set history=50
" Always use unicode.
set encoding=utf8
" Share the clipboard.
" set clipboard+=unnamed
" Fix backspace.
set backspace=indent,eol,start
" Keep a backup file.
set backup
" Do not back up temporary files.
set backupskip=/tmp/*,/private/tmp/*"
" Store backup files in one place.
set backupdir^=$HOME/.vim/backup//
" Store swap files in one place.
set dir^=$HOME/.vim/swap//
" Store undo files in one place.
set undodir^=$HOME/.vim/undo//
" Store view files in one place.
set viewdir=$HOME/.vim/view//
" Save undo tree.
set undofile
" Allow undoing a reload from disk.
set undoreload=1000
" Auto read externally modified files.
set autoread
" Auto write before certain commands.
set autowrite
" Set spell check language.
set spelllang=en_au
" Save battery by letting OS flush to disk.
set nofsync
" Set the default shell.
" set shell=bash
" Leaders ---------------------------------------------------------------- {{{
" Comma is easier to access than backslash.
let mapleader = ','
" Semicolon is second-easier to type than backslash.
let maplocalleader = ';'
" }}}
" }}}
" Presentation ----------------------------------------------------------- {{{
" Never let a window be less than 1px.
set winminheight=1
" Show short messages, no intro.
set shortmess=aIoO
" Show the current mode.
set showmode
" Show last command.
set showcmd
" Scroll n lines before vertical edge.
set scrolloff=3
" Scroll n lines before horizontal edge.
set sidescroll=3
" Page on extended output.
set more
" Ring bell on error messages.
set errorbells
" Show visual cue on error messages.
set visualbell
" Don't keep windows at equal size.
set noequalalways
" Split window appears below the current one.
set splitbelow
" Split window appears right the current one.
set splitright
" Line break at the characters in breakat.
set linebreak
" Show ↪ at the beginning of wrapped lines.
let &showbreak=nr2char(8618).' '
" Fast scrolling when on a decent connection.
set ttyfast
" Do not draw while executing macros.
set lazyredraw
" Set keys move cursor to next/previous line.
set ww+=<,>,[,]
" Show the cursor position.
set ruler
" Show how far a line is from current line.
" set relativenumber
" Allow hidden buffers.
set hidden
" Show matching parenthesis.
set showmatch
" Match for 3 tenths of a second.
set matchtime=3
" Pairs to match.
set matchpairs+=<:>
" Print syntax highlighting.
set printoptions+=syntax:y
" Print line numbers.
set printoptions+=number:y
" Enable error jumping.
set cf
" Set diff fill char.
set fillchars+=diff:⣿
" Enable syntax highlighting.
syntax on
" Detect file type.
filetype on
" Enable file indenting.
filetype indent on
" Load syntax files for better indenting.
filetype plugin indent on
" Color Scheme ----------------------------------------------------------- {{{
" Set the color scheme.
try
if match($TERM_PROGRAM, 'Apple_Terminal') != -1
let term_bg_rgb = split(system("osascript -e 'tell application \"Terminal\" to get background color of current settings of selected tab of front window'"), ', ')
elseif match($TERM_PROGRAM, 'iTerm') != -1
let term_bg_rgb = split(system("osascript -e 'tell application \"iTerm\" to get background color of current session of current terminal'"), ', ')
endif
" Calculate luminance.
" Y = 0.2126 * R + 0.7152 * G + 0.0722 * B
" http://en.wikipedia.org/wiki/Luminance_(relative)
let coefficients = [0.2126, 0.7152, 0.0722]
let luminance = 0
for i in range(3)
let luminance += coefficients[i] * term_bg_rgb[i]
endfor
" Use a dark theme if luminance is less than 30%.
if luminance < (65535 * 0.3)
set background=dark
colorscheme solarized
else
set background=light
colorscheme solarized
endif
catch
echo 'Error: Could not set prefered color scheme'
colorscheme default
endtry
" }}}
" Graphical Interface ---------------------------------------------------- {{{
if has('gui_running')
" Use a good font.
set guifont=Monaco\ for\ Powerline:h12
" Enable menu bar.
set guioptions+=m
" Disable the tool bar.
set guioptions-=T
" Disable left scrollbar.
set guioptions-=l
" Disable left scrollbar if split is present.
set guioptions-=L
" Disable right scrollbar.
set guioptions-=r
" Disable right scrollbar if split is present.
set guioptions-=R
" Do not auto copy selection to clipboard.
set guioptions-=a
if has('gui_macvim')
" Transparent background.
set transparency=5
" Real full screen.
set fuopt+=maxvert,maxhorz
" Shift+Arrows selection.
let macvim_hig_shift_movement = 1
" Command+Shift+Left.
macm Window.Select\ Previous\ Tab key=<D-S-Left>
" Command+Shift+Right.
macm Window.Select\ Next\ Tab key=<D-S-Right>
endif
endif
if has('mouse')
" Enable mouse everywhere.
set mouse=a
" Show a pop-up for right-click.
set mousemodel=popup_setpos
" Hide mouse while typing.
set mousehide
endif
" }}}
" Window Title ----------------------------------------------------------- {{{
if has('title') && (has('gui_running') || &title)
" Set the title.
set titlestring=
" File name.
set titlestring+=%f\ "
" Flags.
set titlestring+=%h%m%r%w
" Program name.
set titlestring+=\ -\ %{v:progname}
" Working directory.
set titlestring+=\ -\ %{substitute(getcwd(),\ $HOME,\ '~',\ '')}
endif
" }}}
" Terminal Interface ----------------------------------------------------- {{{
if &term =~ 'xterm'
if &termencoding == ''
set termencoding=utf-8
endif
if has('title')
" Restore the title of the shell upon exit.
let &titleold = 'Terminal'
" Set the title.
set title
endif
if has('mouse')
" Terminal type for mouse recognition.
set ttymouse=xterm2
endif
" Restore screen on exit.
set restorescreen
" Terminal in 'termcap' mode.
set t_ti=7[r[?47h
" Terminal out of 'termcap mode.
set t_te=[?47l8
" Cursor Shape ----------------------------------------------------------- {{{
" Tmux will only forward escape sequences to the terminal if surrounded by
" a DCS sequence (http://bit.ly/zImrzb).
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
" }}}
endif
" }}}
" Status Line ------------------------------------------------------------ {{{
" Always show status.
set laststatus=2
" Disable status line fill chars.
set fillchars+=stl:\ ,stlnc:\ " Space.
" }}}
" }}}
" Search and Replace ----------------------------------------------------- {{{
" Show partial matches as search is entered.
set incsearch
" Highlight search patterns.
set hlsearch
" Enable case insensitive search.
set ignorecase
" Disable case insensitivity if mixed case.
set smartcase
" Wrap to top of buffer when searching.
set wrapscan
" Make search and replace global by default.
set gdefault
" Use sane regexes.
nnoremap / /\v
vnoremap / /\v
nnoremap ? ?\v
vnoremap ? ?\v
" Keep search matches in the middle of the window.
nnoremap * *zzzv
nnoremap # #zzzv
nnoremap n nzzzv
nnoremap N Nzzzv
" Keep jumps in the middle of the window.
nnoremap g, g,zz
nnoremap g; g;zz
" Open a QuickFix window for the last search.
nnoremap <silent> <Leader>/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>
" Ack last search.
nnoremap <silent> <Leader>? :execute "Ack! '" .
\ substitute(
\ substitute(
\ substitute(
\ @/, "\\\\<", "\\\\b", ""),
\ "\\\\>", "\\\\b", ""),
\ "\\\\v", "", "") .
\ "'"<CR>
" }}}
" Whitespace ------------------------------------------------------------- {{{
" Do not select the end of line.
set selection=old
" Expand tabs into spaces.
set expandtab
" Set tab to equal 4 spaces.
set tabstop=4
" Set soft tabs equal to 4 spaces.
set softtabstop=4
" Set auto indent spacing.
set shiftwidth=4
" Shift to the next round tab stop.
set shiftround
" Insert spaces in front of lines.
set smarttab
" Copy indent from the current line.
set autoindent
" Wrap text.
set wrap
" Maximum line width before wrapping.
set textwidth=80
" Describes how auto formatting is to be done.
set formatoptions=qrn1
" Allow virtual editing in visual block mode.
set virtualedit+=block
" Invisible Characters ----------------------------------------------------{{{
" Do not show invisible characters.
set nolist
" List of characters to show instead of whitespace.
set listchars=tab:▸\ ,eol:¬,trail:⌴,extends:❯,precedes:❮
" Highlight VCS conflict markers.
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
" }}}
" }}}
" Folding ---------------------------------------------------------------- {{{
" Enable folding.
set foldenable
" Syntax dictates folding.
set foldmethod=syntax
" Use a one level fold.
set foldlevel=0
" Do not nest more than 2 folds.
set foldnestmax=2
" Focus the current fold.
nnoremap <Leader>z zMzvzz
" Make zO recursively open the top level fold regardless of cursor placement.
nnoremap zO zCzO
" Credit: Steve Losh
function! SJLFoldText()
let line = getline(v:foldstart)
let nucolwidth = &fdc + &number * &numberwidth
let windowwidth = winwidth(0) - nucolwidth - 3
let foldedlinecount = v:foldend - v:foldstart
" Expand tabs into spaces.
let onetab = strpart(' ', 0, &tabstop)
let line = substitute(line, '\t', onetab, 'g')
let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
return line . ' ...' .
\ repeat(" ",fillcharcount) .
\ foldedlinecount . ' ...' . ' '
endfunction
set foldtext=SJLFoldText()
" }}}
" File Name Auto Completion ---------------------------------------------- {{{
" Show a list entries.
set wildmenu
" Enable completion on tab.
set wildchar=<Tab>
" Insert mode completion.
set completeopt=longest,menu,preview
" Wildcard expansion completion.
set wildmode=list:longest,list:full
" Keyword completion for when Ctrl-P and Ctrl-N are pressed.
set complete=.,t
" Completion Ignored Files ----------------------------------------------- {{{
" VCS directories.
set wildignore+=.hg,.git,.svn
" LaTeX intermediate files.
set wildignore+=*.aux,*.out,*.toc
" Binary images.
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg
" Lua byte code.
set wildignore+=*.luac
" Compiled object files.
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest
" Python byte code.
set wildignore+=*.pyc
" Compiled spelling lists.
set wildignore+=*.spl
" Backup, auto save, swap, undo, and view files.
set wildignore+=*~,#*#,*.sw?,%*,*=
" Mac OS X.
set wildignore+=*.DS_Store
" }}}
" }}}
" Auto Commands ---------------------------------------------------------- {{{
" Auto save on lost focus. DISABLED: Closes help file when focus is lost.
" au FocusLost * silent bufdo if !empty(bufname('%')) && !&ro | update | endif
" au FocusLost * :wa
" Remember folds."
set viewoptions=folds
au BufWinLeave * silent! mkview
au BufWinEnter * silent! loadview
" Switch the CWD to the current buffer.
" au BufEnter * lcd %:p:h
" Resize splits when the window is resized.
au VimResized * exe "normal! \<c-w>="
" Strip trailing whitespace.
au BufWritePre,FileWritePre,FileAppendPre,FilterWritePre *
\ call StripTrailingWhitespace()
" Cursorline ------------------------------------------------------------- {{{
" Highlight the current line in the current window.
aug cursorline
au!
au BufEnter * set cursorline
au BufLeave * set nocursorline
au InsertEnter * set nocursorline
au InsertLeave * set cursorline
aug end
" }}}
" Trailing Whitespace ---------------------------------------------------- {{{
aug trailing
au!
au InsertEnter * :set listchars-=trail:⌴
au InsertLeave * :set listchars+=trail:⌴
aug end
" }}}
" }}}
" File Settings ---------------------------------------------------------- {{{
" BASH ------------------------------------------------------------------- {{{
aug ft_bash
au!
au BufNewFile,BufRead bash-fc-* setlocal filetype=sh
setlocal tabstop=2 softtabstop=2 shiftwidth=2
aug end
" }}}
" CoffeeScript ----------------------------------------------------------- {{{
aug ft_coffee
au!
au FileType coffee
\ setlocal
\ tabstop=4
\ softtabstop=4
\ shiftwidth=4
\ textwidth=79
\ colorcolumn=80
aug end
" }}}
" CSS -------------------------------------------------------------------- {{{
aug ft_css
au!
au BufNewFile,BufRead *.less setlocal filetype=less
" Use cc to change lines without borking the indentation.
au BufNewFile,BufRead *.css,*.less nnoremap <buffer> cc ddko
" Use <Leader>S to sort properties.
au BufNewFile,BufRead *.css,*.less
\ nnoremap <buffer> <LocalLeader>S ?{<CR>jV/\v^\s*\}?$<CR>k:sort<CR>:noh<CR>
" Make {<CR> insert a pair of brackets in such a way that the cursor is
" correctly positioned inside of them and the following code doesn't get
" unfolded.
au BufNewFile,BufRead *.css,*.less
\ inoremap <buffer> {<CR> {}<left><CR>.<CR><esc>kA<bs><tab>
aug end
" }}}
" Git -------------------------------------------------------------------- {{{
aug ft_git
au!
au FileType git* setlocal
\ noexpandtab
\ tabstop=4
\ shiftwidth=4
\ nofoldenable
\ textwidth=72
" Fugitive --------------------------------------------------------------- {{{
" Jump to the last known position when reopening a file.
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
" Map '..' to go up a directory in fugitive tree/blob buffers.
au User fugitive
\ if fugitive#buffer().type() =~# '^\%(tree\|blob\)$' |
\ nnoremap <buffer> .. :edit %:h<CR> |
\ endif
" Auto-clean fugitive buffers.
au BufReadPost fugitive://* set bufhidden=delete
" }}}
aug end
" }}}
" HTML ------------------------------------------------------------------- {{{
aug ft_html
au!
au FileType html compiler html
inoremap <C-_> <Space><BS><Esc>:call InsertCloseTag()<CR>a
aug end
" }}}
" Mail-------------------------------------------------------------------- {{{
aug ft_mail
au!
au Filetype mail setlocal spell
aug end
" }}}
" Markdown --------------------------------------------------------------- {{{
aug ft_markdown
au!
au BufNewFile,BufRead *.m*down setlocal filetype=markdown
aug end
" }}}
" Mercurial -------------------------------------------------------------- {{{
aug ft_mercurial
au!
au BufNewFile,BufRead .hgrc,hgrc,Mercurial.ini setlocal filetype=dosini
aug end
" }}}
" Python ----------------------------------------------------------------- {{{
aug ft_python
au!
au FileType python
\ noremap <buffer> <LocalLeader>rr :RopeRename<CR>
\ vnoremap <buffer> <LocalLeader>rm :RopeExtractMethod<CR>
\ noremap <buffer> <LocalLeader>ri :RopeOrganizeImports<CR>
\ setlocal
\ omnifunc=pythoncomplete#Complete
\ tabstop=4
\ softtabstop=4
\ shiftwidth=4
\ textwidth=79
\ colorcolumn=80
" Pydoc
au FileType python noremap <buffer> <
au FileType python noremap <buffer> <LocalLeader>ds :call ShowPyDoc('<C-R><C-W>', 1)<CR>
aug end
" }}}
" Python (Django) -------------------------------------------------------- {{{
aug ft_django
au!
au BufNewFile,BufRead dashboard.py normal! zR
au BufNewFile,BufRead settings.py setlocal foldmethod=marker
au BufNewFile,BufRead urls.py
\ setlocal nowrap
\ normal! zR
au BufNewFile,BufRead admin.py,urls.py,models.py,views.py,settings.py,forms.py
\ setlocal filetype=python.django
au BufNewFile,BufRead common_settings.py
\ setlocal filetype=python.django foldmethod=marker
aug end
" }}}
" QuickFix --------------------------------------------------------------- {{{
aug ft_quickfix
au!
au Filetype qf setlocal colorcolumn=0 nolist nocursorline nowrap
aug end
" }}}
" Text ------------------------------------------------------------------- {{{
aug ft_text
au!
" Enable soft-wrapping for text files
au FileType text,markdown,html,xhtml,eruby setlocal wrap linebreak nolist