-
Notifications
You must be signed in to change notification settings - Fork 2
/
.vimrc
354 lines (275 loc) · 9.07 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
" Turn off vi compat
set nocompatible
set nonumber
" set rtp+=~/.vim/bundle/vundle/
" call vundle#rc()
"Bundle 'chriskempson/base16-vim'
"Bundle 'ervandew/supertab'
"Bundle 'godlygeek/tabular'
"Bundle 'groenewege/vim-less'
"Bundle 'itspriddle/vim-javascript-indent'
"Bundle 'itspriddle/vim-jekyll'
"Bundle 'itspriddle/vim-jquery'
"Bundle 'itspriddle/vim-stripper'
"Bundle 'kchmck/vim-coffee-script'
"Bundle 'kien/ctrlp.vim'
"Bundle 'majutsushi/tagbar'
"Bundle 'mileszs/ack.vim'
"Bundle 'scrooloose/nerdtree'
"Bundle 'thoughtbot/vim-rspec'
"Bundle 'tomtom/tcomment_vim'
"Bundle 'tpope/vim-dispatch'
"Bundle 'tpope/vim-endwise'
"Bundle 'tpope/vim-fugitive'
"Bundle 'tpope/vim-git'
"Bundle 'tpope/vim-haml'
"Bundle 'tpope/vim-liquid'
"Bundle 'tpope/vim-markdown'
"Bundle 'tpope/vim-rails'
"Bundle 'tpope/vim-rbenv'
"Bundle 'tpope/vim-sensible'
"Bundle 'tpope/vim-speeddating'
"Bundle 'tpope/vim-eunuch'
"Bundle 'vim-ruby/vim-ruby'
"Bundle 'vim-scripts/ZoomWin'
"Bundle 'itspriddle/vim-marked'
"Bundle 'jnwhiteh/vim-golang'
"Bundle 'tpope/vim-unimpaired'
"Bundle 'tpope/vim-jdaddy'
"Bundle 'sickill/vim-monokai'
"Bundle 'chriskempson/tomorrow-theme', {'rtp': 'vim/'}
"Bundle 'rizzatti/funcoo.vim'
"Bundle 'rizzatti/dash.vim'
"Bundle 'ekalinin/Dockerfile.vim'
"Bundle 'itchyny/lightline.vim'
"Bundle 'lambdalisue/vim-manpager'
execute pathogen#infect()
syntax on
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Remember more
set history=1000
let mapleader=","
" Make tab completion for files/buffers act like bash
set wildmenu
" Make searches case-sensitive only if they contain upper-case characters
set ignorecase
set smartcase
" GRB: sane editing configuration"
set expandtab
set tabstop=2
set shiftwidth=2
set softtabstop=2
set autoindent
" set smartindent
set laststatus=2
set showmatch
set incsearch
set bs=2
" Horizontal splits open below the current buffer
set splitbelow
" Vertical splits open to the right of the current buffer
set splitright
" Store temporary files in a central spot
set backupdir=~/.vim/.backup
set directory=~/.vim/.backup
" STOP FLASHING AT ME
set noerrorbells visualbell t_vb=
" Preserve undo across sessions
if exists("&undodir")
set undodir=~/.vim/.tmp/undo//
set undofile
endif
" Preview size
set previewheight=50
" Resize splits when the window is resized
au VimResized * :wincmd =
" Turn off arrow scrolling
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
" Window Jumping
map <C-J> <C-W>j<15C-W>_
map <C-K> <C-W>k<15C-W>
map <C-h> <C-W>h<15C-W>_
map <C-l> <C-W>l<15C-W>
" ,s - Open the associated file in a horizontal split (ruby)
map <leader>s :AS<cr>
" ,v - Open the associated file in a vertical split (ruby)
map <leader>v :AV<cr>
" Searching
let g:ackprg = 'ag --nogroup --nocolor --column'
map <Leader>f :Ack<space>
map <Leader>F :AckFromSearch<CR>
" Show NERDTree
map <Leader>d :NERDTreeToggle<CR>
" Reselect the last visual select
nmap gV `[v`]
" colorscheme Tomorrow-Night
colorscheme default
" Chef
map <M-a> :ChefFindAny<CR>
" Stripper
set exrc
set secure
" Command-T
set wildignore=*.o,*.obj,.git,*.rbc,*.class,.svn,vendor/gems/*,coverage/*,public/*,tmp/*,log/*,doc/*
" Tabular
nmap <Leader>a= :Tabularize /^[^=]*\zs=>\?<CR>
vmap <Leader>a= :Tabularize /^[^=]*\zs=>\?<CR>
nmap <Leader>a: :Tabularize /:\zs/l0r1<CR>
vmap <Leader>a: :Tabularize /:\zs/l0r1<CR>
nmap <Leader>a, :Tabularize /,\zs/l1r0<CR>
vmap <Leader>a, :Tabularize /,\zs/l1r0<CR>
" Format XML
nmap <Leader>x :%!xmllint --format -<CR>
vmap <Leader>x :!xmllint --format -<CR>
" Folding
" set viewdir=~/.vim/view
" set viewoptions=folds,cursor
" Toggle folds with space
" nnoremap <silent> <Space> @=(foldlevel('.')?'za':'l')<CR>
" vnoremap <Space> zf
" ,wr to toggle wrap/no wrap
map <leader>wr :set nowrap! nowrap?<CR>
" ,pa to toggle paste mode
map <leader>pa :set paste! paste?<CR>
" ,n to toggle line numbers
map <leader>n :set number! number?<CR>
" ,l to toggle list
map <leader>l :set list! list?<CR>
" ,y show Yanks
map <leader>y :YRShow<CR>
" Remap space to :
noremap <space> :
" Show tags
map <leader>T :TagbarToggle<cr>
" Zoom in on a buffer
map <leader><leader> :ZoomWin<cr>
" Focus the window when it's launched
let g:tagbar_autofocus = 1
" Already handled
" let g:ctrlp_working_path_mode = 0
let g:ctrlp_map = '<c-t>'
" Squash commits
function SquashCommits()
'<,'>s/pick /fixup /ge
endfunction
autocmd VimEnter .git/rebase-merge/git-rebase-todo vmap <buffer> <leader>s :call SquashCommits()<CR>
" Function used to identify where to place the cursor, editing an email.
function FirstInPost (...) range
let cur = a:firstline
while cur <= a:lastline
let str = getline(cur)
" Found an _empty_ subject in the headers.
" NOTE: you can put similar checks to handle other empty headers
" like To, From, Newgroups, ...
if str == 'Subject: '
execute cur
:start!
break
endif
" We have reached the end of the headers.
if str == ''
let cur = cur + 1
" If the first line of the body is an attribution, put
" the cursor _after_ that line, otherwise the cursor is
" leaved right after the headers (assuming we're writing
" a new mail, and not editing a reply).
" NOTE: modify the regexp to match your mail client's attribution!
if strlen(matchstr(getline(cur), '^On.*wrote:.*')) > 0
let cur = cur - 1
endif
execute cur
:start
break
endif
let cur = cur + 1
endwhile
endfunction
" Command to be called.
com Fip :set tw=0<Bar>:%call FirstInPost()
" Format mail
function FT_mail()
:Fip
set textwidth=72
set spell
set spelllang=en_us
set textwidth=77
set expandtab
set noautoindent
endfunction
if has("autocmd")
autocmd FileType mail call FT_mail()
autocmd GUIEnter * set visualbell t_vb=
" Save folds
" autocmd BufWinLeave * silent! mkview
" autocmd BufWinEnter * silent! loadview
"
" Open git commits at the first line
autocmd VimEnter .git/COMMIT_EDITMSG exe "normal! gg"
" Add :Rfactory command
autocmd User Rails Rnavcommand factory spec/factories test/factories -suffix=.rb -default=model()
" Add :Rconfig command
autocmd User Rails Rnavcommand config config -glob=*.* -suffix= -default=routes.rb
" CoffeeScript
augroup ft_coffee
autocmd!
" Place the cursor at the top of the buffer
autocmd VimEnter .git/COMMIT_EDITMSG exe 'normal! gg'
" Rebase shortcuts, press P, R, E, S, F to change the current line to the
" given command. Press C to cycle through available commands.
autocmd VimEnter .git/rebase-merge/git-rebase-todo nnoremap <buffer> <silent> P :Pick<cr>
autocmd VimEnter .git/rebase-merge/git-rebase-todo nnoremap <buffer> <silent> R :Reword<cr>
autocmd VimEnter .git/rebase-merge/git-rebase-todo nnoremap <buffer> <silent> E :Edit<cr>
autocmd VimEnter .git/rebase-merge/git-rebase-todo nnoremap <buffer> <silent> S :Squash<cr>
autocmd VimEnter .git/rebase-merge/git-rebase-todo nnoremap <buffer> <silent> F :Fixup<cr>
autocmd VimEnter .git/rebase-merge/git-rebase-todo nnoremap <buffer> <silent> C :Cycle<cr>
" Compile the current buffer in a vertical split
autocmd FileType coffee nnoremap <buffer> <leader>cc :CoffeeCompile vert<cr>
" Compile the current selection in a vertical split
autocmd FileType coffee vnoremap <buffer> <leader>cc :CoffeeCompile vert<cr>
" Compile and run the current buffer
autocmd FileType coffee nnoremap <buffer> <leader>cr :CoffeeRun<cr>
autocmd FileType coffee vnoremap <buffer> <leader>cR :CoffeeRun<cr>
" Compile the current buffer, output the result to a new file.
autocmd FileType coffee nnoremap <buffer> <leader>cm :CoffeeMake<cr>
" Same as above, Intentionally has no <cr> so an option can be added
autocmd FileType coffee nnoremap <buffer> <leader>cM :CoffeeMake
augroup END
" Git
augroup ft_git
autocmd!
" Place the cursor at the top of the buffer
autocmd VimEnter .git/COMMIT_EDITMSG exe 'normal! gg'
" Alias Gpush
autocmd User Fugitive command! -buffer Gpush exe 'Git push'
" Show git status for the repo
autocmd User Fugitive noremap <buffer> <leader>gs :Gstatus<cr>
" Write the current buffer to git index
autocmd User Fugitive noremap <buffer> <leader>gw :Gwrite<cr>
" Commit current git index
autocmd User Fugitive noremap <buffer> <leader>gc :Gcommit -m ""<left>
" Push current branch upstream
autocmd User Fugitive noremap <buffer> <leader>gp :Gpush<cr>
autocmd VimEnter .git/PULLREQ_EDIT_MSG setl wrap textwidth=0
augroup END
end
" Gist clipboard
let g:gist_clip_command = 'pbcopy'
" Show my private gists
let g:gist_show_privates = 1
" Open in a browser
let g:gist_open_browser_after_post = 0
let g:gist_browser_command = 'open %URL% &'
" Don't complete before nothing, after space, comma or ]
let g:SuperTabNoCompleteBefore=[]
let g:SuperTabNoCompleteAfter=[',','\s', ']']
let g:rspec_command = "Dispatch rspec {spec}"
let g:lightline = {
\ 'colorscheme': 'solarized_dark',
\ }