-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy path.vimrc
319 lines (256 loc) · 10.6 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
" ---------------------------------------------------------------------------
" General
" ---------------------------------------------------------------------------
set nocompatible " essential
set history=1000 " lots of command line history
set cf " error files / jumping
set ffs=unix,dos,mac " support these files
set isk+=_,$,@,%,#,- " none word dividers
set viminfo='1000,f1,:100,@100,/20
set modeline " make sure modeline support is enabled
set autoread " reload files (no local changes only)
set tabpagemax=50 " open 50 tabs max
" --------------------------------------------------------------------------
" Vundle
" --------------------------------------------------------------------------
filetype off " required
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'Align'
Bundle 'tpope/vim-rails'
Bundle 'tpope/vim-surround'
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/syntastic'
Bundle 'kchmck/vim-coffee-script'
Bundle 'Shougo/neocomplcache'
Bundle 'scrooloose/nerdcommenter'
" snipmate
Bundle 'MarcWeber/vim-addon-mw-utils'
Bundle 'tomtom/tlib_vim'
Bundle 'garbas/vim-snipmate'
Bundle 'honza/vim-snippets'
" end snipmate
Bundle 'skwp/vim-colors-solarized'
Bundle 'mileszs/ack.vim'
Bundle 'slim-template/vim-slim'
Bundle 'kien/ctrlp.vim'
Bundle 'Lokaltog/vim-powerline'
Bundle 'Townk/vim-autoclose'
Bundle 'nathanaelkane/vim-indent-guides'
Bundle 'pangloss/vim-javascript'
Bundle 'HTML-AutoCloseTag'
Bundle 'mattn/webapi-vim'
Bundle 'mattn/gist-vim'
Bundle 'elixir-lang/vim-elixir'
Bundle 'othree/html5.vim'
Bundle 'junegunn/goyo.vim'
filetype plugin indent on " required
syntax enable
set background=dark
colorscheme solarized
" --------------------------------------------------------------------------
" Gist.vim
" --------------------------------------------------------------------------
let g:gist_post_private = 1
" --------------------------------------------------------------------------
" Powerline
" --------------------------------------------------------------------------
let g:Powerline_symbols = 'fancy'
let g:Powerline_colorscheme = 'solarized'
" --------------------------------------------------------------------------
" NeoComplCache
" --------------------------------------------------------------------------
let g:neocomplcache_enable_at_startup = 1
" <CR>: close popup and save indent
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return pumvisible() ? neocomplcache#close_popup() : "\<CR>"
endfunction
" --------------------------------------------------------------------------
" Syntastic
" --------------------------------------------------------------------------
let g:syntastic_check_on_open = 1
" --------------------------------------------------------------------------
" NERD_commenter.vim
" --------------------------------------------------------------------------
let g:NERDSpaceDelims = 1
autocmd vimenter * if &filetype !=# 'gitcommit' | NERDTree | wincmd p | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" --------------------------------------------------------------------------
" ctrlp.vim
" --------------------------------------------------------------------------
let g:ctrlp_dont_split = 'nerdtree'
" Sane Ignore For ctrlp
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$\|\.yardoc\|public\/images\|public\/system\|data\|log\|tmp$',
\ 'file': '\.exe$\|\.so$\|\.dat$'
\ }
" ---------------------------------------------------------------------------
" Colors / Theme
" ---------------------------------------------------------------------------
" if &term =~ "xterm"
" if has("terminfo")
" set t_Co=8
" set t_Sf=<Esc>[3%p1%dm
" set t_Sb=<Esc>[4%p1%dm
" else
" set t_Co=8
" set t_Sf=<Esc>[3%dm
" set t_Sb=<Esc>[4%dm
" endif
" endif
if &t_Co > 2 || has("gui_running")
if has("terminfo")
set t_Co=16
set t_AB=[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
set t_AF=[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
else
set t_Co=16
set t_Sf=[3%dm
set t_Sb=[4%dm
endif
syntax on
set hlsearch
" colorscheme is disabled: using solarized from terminal
"colorscheme tomorrow_night_blue
endif
" ---------------------------------------------------------------------------
" Highlight
" ---------------------------------------------------------------------------
set cursorline
"highlight Comment ctermfg=DarkGrey guifg=#444444
"highlight StatusLineNC ctermfg=Black ctermbg=DarkGrey cterm=bold
"highlight StatusLine ctermbg=Black ctermfg=LightGrey
" ----------------------------------------------------------------------------
" Highlight Trailing Whitespace
" ----------------------------------------------------------------------------
set list listchars=trail:.,tab:>.
"highlight SpecialKey ctermfg=DarkGray ctermbg=Black
" ----------------------------------------------------------------------------
" Backups
" ----------------------------------------------------------------------------
set nobackup " do not keep backups after close
set nowritebackup " do not keep a backup while working
set noswapfile " don't keep swp files either
set backupdir=$HOME/.vim/backup " store backups under ~/.vim/backup
set backupcopy=yes " keep attributes of original file
set backupskip=/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*
set directory=~/.vim/swap,~/tmp,. " keep swp files under ~/.vim/swap
" ----------------------------------------------------------------------------
" UI
" ----------------------------------------------------------------------------
set ruler " show the cursor position all the time
set noshowcmd " don't display incomplete commands
set nolazyredraw " turn off lazy redraw
set number " line numbers
set wildmenu " turn on wild menu
set wildmode=list:longest,full
" ----
set wildignore=*.o,*.obj,*~ "stuff to ignore when tab completing
set wildignore+=*vim/backups*
set wildignore+=*sass-cache*
set wildignore+=*DS_Store*
set wildignore+=vendor/rails/**
set wildignore+=vendor/cache/**
set wildignore+=*.gem
set wildignore+=log/**
set wildignore+=tmp/**
set wildignore+=*.png,*.jpg,*.gif
" ----
set ch=2 " command line height
set backspace=2 " allow backspacing over everything in insert mode
set whichwrap+=<,>,h,l,[,] " backspace and cursor keys wrap to
set shortmess=filtIoOA " shorten messages
set report=0 " tell us about changes
set nostartofline " don't jump to the start of line when scrolling
" ----------------------------------------------------------------------------
" Visual Cues
" ----------------------------------------------------------------------------
set showmatch " brackets/braces that is
set mat=5 " duration to show matching brace (1/10 sec)
set incsearch " do incremental searching
set laststatus=2 " always show the status line
set ignorecase " ignore case when searching
set nohlsearch " don't highlight searches
set visualbell " shut the fuck up
" ----------------------------------------------------------------------------
" Text Formatting
" ----------------------------------------------------------------------------
set autoindent " automatic indent new lines
set smartindent " be smart about it
set nowrap " do not wrap lines
set softtabstop=2 " yep, two
set shiftwidth=2 " ..
set tabstop=4
set expandtab " expand tabs to spaces
set nosmarttab " fuck tabs
set formatoptions+=n " support for numbered/bullet lists
set textwidth=80 " wrap at 80 chars by default
set virtualedit=block " allow virtual edit in visual block ..
set pastetoggle=<F4> " toggle paste mode via f4 key
" ----------------------------------------------------------------------------
" Mappings
" ----------------------------------------------------------------------------
" remap <LEADER> to ',' (instead of '\')
let mapleader = ","
" emacs movement keybindings in insert mode
imap <C-a> <C-o>0
imap <C-e> <C-o>$
map <C-e> $
map <C-a> 0
" ----------------------------------------------------------------------------
" Auto Commands
" ----------------------------------------------------------------------------
" jump to last position of buffer when opening
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g'\"" | endif
" ---------------------------------------------------------------------------
" Misc mappings
" ---------------------------------------------------------------------------
" duplicate current tab with same file+line
map ,t :tabnew %<CR>
" open directory dirname of current file, and in new tab
map ,d :e %:h/<CR>
map ,dt :tabnew %:h/<CR>
" open gf under cursor in new tab
map ,f :tabnew <cfile><CR>
" nerdtree mappings
map ,z :NERDTreeToggle<CR>
" goyo mappings
map ,g :Goyo<CR>
" navigation
map <Space> <PageDown>
nmap <Up> <c-w>k
nmap <Down> <c-w>j
nmap <Right> <c-w>l
nmap <Left> <c-w>h
" ---------------------------------------------------------------------------
" Strip all trailing whitespace in file
" ---------------------------------------------------------------------------
function! StripWhitespace ()
exec ':%s/ \+$//gc'
endfunction
map ,s :call StripWhitespace ()<CR>
" ---------------------------------------------------------------------------
" Strip all trailing whitespace in file before saving
" ---------------------------------------------------------------------------
fun! StripTrailingWhitespace()
" Don't strip on these filetypes
if &ft =~ 'mkd'
return
endif
%s/\s\+$//e
endfun
autocmd BufWritePre * call StripTrailingWhitespace()
" ---------------------------------------------------------------------------
" File Types
" ---------------------------------------------------------------------------
au BufRead,BufNewFile {Gemfile,Guardfile,Rakefile,Procfile,config.ru} set ft=ruby
au BufRead,BufNewFile *.rake set ft=ruby
au BufRead,BufNewFile *.json set ft=javascript
au BufRead,BufNewFile *.md set ft=mkd tw=80 ts=2 sw=2 expandtab
au BufRead,BufNewFile *.markdown set ft=mkd tw=80 ts=2 sw=2 expandtab
au Filetype gitcommit set tw=68 spell
au Filetype ruby set tw=80 ts=2
au Filetype slim set tw=0