forked from braintreeps/vim_dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
344 lines (268 loc) · 9.52 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
" ========= Setup ========
set nocompatible
if &shell == "/usr/bin/sudosh"
set shell=/bin/bash
endif
" Install vim plugins
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
if filereadable(expand("/etc/vim/vimrc.bundles"))
source /etc/vim/vimrc.bundles
endif
" ========= Options ========
compiler ruby
syntax on
set hlsearch
set number
set showmatch
set incsearch
set background=dark
set hidden
set backspace=indent,eol,start
set textwidth=0 nosmartindent tabstop=2 shiftwidth=2 softtabstop=2 expandtab
set ruler
set wrap
set dir=/tmp//
set scrolloff=5
set ignorecase
set smartcase
set wildignore+=*.pyc,*.o,*.class,*.lo,.git
set tags+=gems.tags
set mouse=
if version >= 703
set undodir=~/.vim/undodir
set undofile
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
endif
set undolevels=1000 "maximum number of changes that can be undone
" Color
colorscheme vibrantink
au FileType diff colorscheme desert
au FileType git colorscheme desert
au BufWinLeave * colorscheme vibrantink
augroup markdown
au!
au BufNewFile,BufRead *.md,*.markdown setlocal filetype=ghmarkdown
augroup END
augroup Drakefile
au!
au BufNewFile,BufRead Drakefile,drakefile setlocal filetype=ruby
augroup END
" File Types
autocmd FileType php setlocal tabstop=4 shiftwidth=4 softtabstop=4
autocmd FileType python setlocal tabstop=4 shiftwidth=4 softtabstop=4
autocmd FileType java setlocal tabstop=4 shiftwidth=4 softtabstop=4
autocmd FileType cs setlocal tabstop=4 shiftwidth=4 softtabstop=4
autocmd FileType tex setlocal textwidth=78
autocmd BufNewFile,BufRead *.txt setlocal textwidth=78
autocmd FileType ruby runtime ruby_mappings.vim
autocmd FileType python runtime python_mappings.vim
if version >= 700
autocmd BufNewFile,BufRead *.txt setlocal spell spelllang=en_us
autocmd FileType tex setlocal spell spelllang=en_us
endif
" Highlight trailing whitespace
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd BufRead,InsertLeave * match ExtraWhitespace /\s\+$/
" Autoremove trailing spaces when saving the buffer
autocmd FileType c,cpp,elixir,eruby,html,java,javascript,php,ruby autocmd BufWritePre <buffer> :%s/\s\+$//e
" Highlight too-long lines
autocmd BufRead,InsertEnter,InsertLeave * 2match LineLengthError /\%126v.*/
highlight LineLengthError ctermbg=black guibg=black
autocmd ColorScheme * highlight LineLengthError ctermbg=black guibg=black
" Set up highlight group & retain through colorscheme changes
highlight ExtraWhitespace ctermbg=red guibg=red
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
" Status
set laststatus=2
set statusline=
set statusline+=%<\ " cut at start
set statusline+=%2*[%n%H%M%R%W]%*\ " buffer number, and flags
set statusline+=%-40f\ " relative path
set statusline+=%= " seperate between right- and left-aligned
set statusline+=%1*%y%*%*\ " file type
set statusline+=%10(L(%l/%L)%)\ " line
set statusline+=%2(C(%v/125)%)\ " column
set statusline+=%P " percentage of file
" ========= Plugin Options ========
let g:AckAllFiles = 0
let g:AckCmd = 'ack --type-add ruby=.feature --ignore-dir=tmp 2> /dev/null'
" Side Search {{{
let g:side_search_prg = 'ack-grep --word-regexp'
\. " --heading -C 2 --group"
let g:side_search_splitter = 'vnew'
let g:side_search_split_pct = 0.4
" SideSearch current word and return to original window
nnoremap <Leader>ss :SideSearch <C-r><C-w><CR> | wincmd p
" SS shortcut and return to original window
command! -complete=file -nargs=+ SS execute 'SideSearch <args>'
" }}}
let html_use_css=1
let html_number_lines=0
let html_no_pre=1
let g:gist_clip_command = 'pbcopy'
let g:gist_detect_filetype = 1
let g:rubycomplete_buffer_loading = 1
let g:no_html_toolbar = 'yes'
let coffee_no_trailing_space_error = 1
let NERDTreeIgnore=['\.pyc$', '\.o$', '\.class$', '\.lo$']
let NERDTreeHijackNetrw = 0
let g:netrw_banner = 0
let g:VimuxUseNearestPane = 1
let g:CommandTMaxHeight = 15
let g:CommandTMatchWindowAtTop = 1
let g:CommandTCancelMap = ['<ESC>', '<C-c>']
let g:CommandTSelectNextMap = ['<C-n>', '<C-j>', '<ESC>OB']
let g:CommandTSelectPrevMap = ['<C-p>', '<C-k>', '<ESC>OA']
let g:CommandTWildIgnore=&wildignore . ",vendor/*,node_modules/**,bower_components/**"
let g:vim_markdown_folding_disabled=1
if exists(':RainbowParenthesesToggle')
autocmd VimEnter * RainbowParenthesesToggle
autocmd Syntax clojure RainbowParenthesesLoadRound
autocmd Syntax clojure RainbowParenthesesLoadSquare
autocmd Syntax clojure RainbowParenthesesLoadBraces
endif
let g:puppet_align_hashes = 0
" ========= Shortcuts ========
" NERDTree
map <silent> <LocalLeader>nt :NERDTreeToggle<CR>
map <silent> <LocalLeader>nr :NERDTree<CR>
map <silent> <LocalLeader>nf :NERDTreeFind<CR>
" CommandT
map <silent> <leader>ff :CommandT<CR>
map <silent> <leader>fb :CommandTBuffer<CR>
map <silent> <leader>fr :CommandTFlush<CR>
" Ack
map <LocalLeader>aw :Ack '<C-R><C-W>'
" TComment
map <silent> <LocalLeader>cc :TComment<CR>
map <silent> <LocalLeader>uc :TComment<CR>
" Vimux
map <silent> <LocalLeader>rl :wa<CR> :VimuxRunLastCommand<CR>
map <silent> <LocalLeader>vi :wa<CR> :VimuxInspectRunner<CR>
map <silent> <LocalLeader>vk :wa<CR> :VimuxInterruptRunner<CR>
map <silent> <LocalLeader>vx :wa<CR> :VimuxClosePanes<CR>
map <silent> <LocalLeader>vp :VimuxPromptCommand<CR>
vmap <silent> <LocalLeader>vs "vy :call VimuxRunCommand(@v)<CR>
nmap <silent> <LocalLeader>vs vip<LocalLeader>vs<CR>
map <silent> <LocalLeader>ds :call VimuxRunCommand('clear; grep -E "^ *describe[ \(]\|^ *context[ \(]\|^ *it[ \(]" ' . bufname("%"))<CR>
map <silent> <LocalLeader>rt :!ctags -R --exclude=".git\|.svn\|log\|tmp\|db\|pkg" --extra=+f --langmap=Lisp:+.clj<CR>
map <silent> <LocalLeader>cj :!clj %<CR>
map <silent> <LocalLeader>gd :e product_diff.diff<CR>:%!git diff<CR>:setlocal buftype=nowrite<CR>
map <silent> <LocalLeader>pd :e product_diff.diff<CR>:%!svn diff<CR>:setlocal buftype=nowrite<CR>
map <silent> <LocalLeader>nh :nohls<CR>
map <silent> <LocalLeader>bd :bufdo :bd<CR>
cnoremap <Tab> <C-L><C-D>
nnoremap <silent> k gk
nnoremap <silent> j gj
nnoremap <silent> Y y$
map <silent> <LocalLeader>ws :highlight clear ExtraWhitespace<CR>
map <silent> <LocalLeader>pp :set paste!<CR>
" Pasting over a selection does not replace the clipboard
xnoremap <expr> p 'pgv"'.v:register.'y'
" ========= Insert Shortcuts ========
imap <C-L> <SPACE>=><SPACE>
" ========= Functions ========
command! SudoW w !sudo tee %
" http://techspeak.plainlystated.com/2009/08/vim-tohtml-customization.html
function! DivHtml(line1, line2)
exec a:line1.','.a:line2.'TOhtml'
%g/<style/normal $dgg
%s/<\/style>\n<\/head>\n//
%s/body {/.vim_block {/
%s/<body\(.*\)>\n/<div class="vim_block"\1>/
%s/<\/body>\n<\/html>/<\/div>
"%s/\n/<br \/>\r/g
set nonu
endfunction
command! -range=% DivHtml :call DivHtml(<line1>,<line2>)
function! GitGrepWord()
cgetexpr system("git grep -n '" . expand("<cword>") . "'")
cwin
echo 'Number of matches: ' . len(getqflist())
endfunction
command! -nargs=0 GitGrepWord :call GitGrepWord()
nnoremap <silent> <Leader>gw :GitGrepWord<CR>
function! Trim()
%s/\s*$//
''
endfunction
command! -nargs=0 Trim :call Trim()
nnoremap <silent> <Leader>cw :Trim<CR>
function! StartInferiorSlimeServer()
let g:__InferiorSlimeRunning = 1
call VimuxRunCommand("inferior-slime")
endfunction
command! -nargs=0 StartInferiorSlimeServer :call StartInferiorSlimeServer()
function! __Edge()
colorscheme Tomorrow-Night
au BufWinLeave * colorscheme Tomorrow-Night
set ttyfast
map <leader>nf :e%:h<CR>
map <C-p> :CommandT<CR>
let g:VimuxOrientation = "h"
let g:VimuxHeight = "40"
endfunction
function! __HardMode()
nmap h <nop>
nmap j <nop>
nmap k <nop>
nmap l <nop>
nmap <up> <nop>
nmap <down> <nop>
nmap <left> <nop>
nmap <right> <nop>
endfunction
" cleans up the way the default tabline looks
" will show tab numbers next to the basename of the file
" from :help setting-tabline
function MyTabLine()
let s = ''
for i in range(tabpagenr('$'))
" select the highlighting
if i + 1 == tabpagenr()
let s .= '%#TabLineSel#'
else
let s .= '%#TabLine#'
endif
let s .= '[' . (i + 1) . ']' " set the tab page number (for viewing)
let s .= '%' . (i + 1) . 'T' " set the tab page number (for mouse clicks)
let s .= '%{MyTabLabel(' . (i + 1) . ')} ' " the label is made by MyTabLabel()
endfor
" after the last tab fill with TabLineFill and reset tab page nr
let s .= '%#TabLineFill#%T'
return s
endfunction
" with help from http://vim.wikia.com/wiki/Show_tab_number_in_your_tab_line
function MyTabLabel(n)
let buflist = tabpagebuflist(a:n)
let winnr = tabpagewinnr(a:n)
let bufnr = buflist[winnr - 1]
let file = bufname(bufnr)
let buftype = getbufvar(bufnr, 'buftype')
if buftype == 'nofile'
if file =~ '\/.'
let file = substitute(file, '.*\/\ze.', '', '')
endif
else
let file = fnamemodify(file, ':p:t')
endif
if file == ''
let file = '[No Name]'
endif
return file
endfunction
set tabline=%!MyTabLine()
"-------- Local Overrides
""If you have options you'd like to override locally for
"some reason (don't want to store something in a
""publicly-accessible repository, machine-specific settings, etc.),
"you can create a '.local_vimrc' file in your home directory
""(ie: ~/.vimrc_local) and it will be 'sourced' here and override
"any settings in this file.
""
"NOTE: YOU MAY NOT WANT TO ADD ANY LINES BELOW THIS
if filereadable(expand('~/.vimrc_local'))
source ~/.vimrc_local
end