-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
executable file
·393 lines (345 loc) · 10 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
" VIMRC Configuration File
" philipp@fehre.co.uk
" http://www.sideshowcoder.com
" Setup bundles via Vundle
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'kien/ctrlp.vim'
Plugin 'JazzCore/ctrlp-cmatcher'
Plugin 'rizzatti/dash.vim'
Plugin 'terryma/vim-expand-region'
Plugin 'tpope/vim-fugitive'
Plugin 'rizzatti/funcoo.vim'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/nerdtree'
Plugin 'rodjek/vim-puppet'
Plugin 'tpope/vim-rvm'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'bronson/vim-trailing-whitespace'
Plugin 'tpope/vim-sensible'
Plugin 'altercation/vim-colors-solarized'
Plugin 'scrooloose/syntastic'
Plugin 'Valloric/YouCompleteMe'
Plugin 'endel/vim-github-colorscheme'
Plugin 'vim-erlang/vim-erlang-runtime'
Plugin 'vim-erlang/vim-erlang-compiler'
Plugin 'vim-erlang/vim-erlang-omnicomplete'
Plugin 'vim-erlang/vim-erlang-tags'
Plugin 'vim-erlang/vim-rebar'
Plugin 'vim-erlang/vim-dialyzer'
Plugin 'ppikula/vim-wrangler'
Plugin 'danielmiessler/VimBlog'
" All of your Plugins must be added before the following line
" To install new plugins after changing run :PluginInstall
call vundle#end() " required
filetype plugin indent on " required
" Autoload bundles and setup spelling
runtime! autoload/pathogen.vim
if exists('g:loaded_pathogen')
call pathogen#infect()
end
" Language and encoding
set encoding=utf-8
set langmenu=en_US.UTF-8
let maplocalleader = ","
let mapleader = ","
" Clear Vim quickfix list
function ClearQuickfixList()
call setqflist([])
endfunction
command! ClearQuickfixList call ClearQuickfixList()
nmap <leader>cf :ClearQuickfixList<cr>
" Jump to next location in current window, this is useful to jump between
" errors
map <leader>ln :lnext<cr>
map <leader>lp :lprevious<cr>
" Linewrap Navigation
map j gj
map k gk
" disable the arrow key default behavior
map <Up> <Nop>
map <Down> <Nop>
map <Left> <Nop>
map <Right> <Nop>
inoremap <Left> <NOP>
inoremap <Right> <NOP>
inoremap <Up> <NOP>
inoremap <Down> <NOP>
" Make arrowkey do something usefull, resize the viewports accordingly
nnoremap <Left> :vertical resize +5<CR>
nnoremap <Right> :vertical resize -5<CR>
nnoremap <Up> :resize +5<CR>
nnoremap <Down> :resize -5<CR>
"
" Split switching made easy
nnoremap <C-J> <C-W>w
nnoremap <C-K> <C-W>W
nnoremap <C-H> <C-W>h
nnoremap <C-L> <C-W>l
set splitbelow
set splitright
" get rid of the F1 help menu
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" vim like tab navigation
nnoremap th :tabfirst<CR>
nnoremap tj :tabnext<CR>
nnoremap tk :tabprev<CR>
nnoremap tl :tablast<CR>
nnoremap tt :tabedit<Space>
nnoremap tn :tabnext<Space>
nnoremap tm :tabm<Space>
nnoremap td :tabclose<CR>
" copy paste from the systemclipboard via ,p
vmap <leader>y "+y
vmap <leader>d "+d
nmap <leader>p "+p
nmap <leader>P "+P
vmap <leader>p "+p
vmap <leader>P "+P
" jump to the end of the pasted text by default
vnoremap <silent> y y`]
vnoremap <silent> p p`]
nnoremap <silent> p p`]
" visual paste should not replace my paste buffer
function! RestoreRegister()
let @" = s:restore_reg
return ''
endfunction
function! s:Repl()
let s:restore_reg = @"
return "p@=RestoreRegister()\<cr>"
endfunction
vmap <silent> <expr> p <sid>Repl()
" Vim expand region
vmap v <Plug>(expand_region_expand)
vmap <C-v> <Plug>(expand_region_shrink)
" interface
" turn off icons in interface
if has("gui_running")
set guioptions-=T
endif
" set best fonts for system
if has("gui_macvim") || has("gui_mac")
set guifont=Inconsolata:h13
endif
" don't blink and whistle
set visualbell
set t_vb=
set noerrorbells
" show something usefull in statusline
set statusline=%F%m%r%h%w\ [TYPE=%Y]\ %=%{rvm#statusline()}\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
" always show the status line
set laststatus=2
" dont show the scrollbars since they are useless anyway
set guioptions-=L
set guioptions-=r
set guioptions-=T
" number the lines
set number
" Miscellaneous
set autoread
set nobackup
set nowritebackup
set noswapfile
" tmux does not use the unnamed clipboard? WTF?
if $TMUX == ''
set clipboard+=unnamed
endif
set showmode
set ruler
set hidden
set history=500
set ignorecase
set mouse=nvi
set wildmenu
set wildmode=list:longest
" Editing
if &t_Co > 2 || has("gui_running")
syntax on
syntax sync fromstart
endif
if has("autocmd")
filetype on
filetype indent on
filetype plugin on
endif
set backspace=2
set autoindent
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
set textwidth=0
set wrap
set linebreak
set nolist
set langmenu=en
set incsearch
set showcmd
set hlsearch
set showmatch
set mousehide
set backspace=indent,eol,start
nnoremap / /\v
vnoremap / /\v
set gdefault
nnoremap <leader><space> :noh<cr>
" Theme
set t_Co=256
if has("gui_running")
set background=light
colorscheme github
else
set background=dark
colorscheme solarized
end
" Make the sign colum color same as line number column
highlight clear SignColumn
set mat=10
set showtabline=1
set wiw=84
set winminwidth=40
set so=10
" Filetypes
au BufNewFile,BufRead *.ejs set filetype=html
" Just make Txt look like markdown... it's all the same!
au BufNewFile,BufRead *.txt set filetype=markdown
au BufNewFile,BufRead todo.txt set filetype=todotxt
au BufNewFile,BufRead *.mdown set filetype=markdown
au BufNewFile,BufRead *.markdown set filetype=markdown
au BufNewFile,BufRead *.md set filetype=markdown
au BufNewFile,BufRead *.txt set filetype=text
au BufNewFile,BufRead *.json set filetype=javascript
au BufNewFile,BufRead *.ru set filetype=ruby
au BufNewFile,BufRead *.pill set filetype=ruby
au BufNewFile,BufRead *.god set filetype=ruby
au BufNewFile,BufRead *.thor set filetype=ruby
au BufNewFile,BufRead Gemfile set filetype=ruby
au BufNewFile,BufRead Gruntfile set filetype=javascript
au BufNewFile,BufRead Vagrantfile set filetype=ruby
au BufNewFile,BufRead Podfile set filetype=ruby
" Erlang filetypes proudly presented by OTP and rebar
au BufNewFile,BufRead *.app.src set filetype=erlang
au BufNewFile,BufRead rebar.conf set filetype=erlang
au BufNewFile,BufRead rebar.config set filetype=erlang
au BufNewFile,BufRead app.config set filetype=erlang
" Switch to last open file
nnoremap <leader><leader> <c-^>
" Spellchecker ,sp
if v:version >= 700
set spellfile=~/.vim/spellfile.add
set spelllang=en,de
setlocal spell spelllang=en_us
nmap <leader>sp :set spell!<CR>
endif
set nospell
" toggle show whitespace ,w
nmap <silent> <leader>w :set nolist!<cr>
set listchars=tab:▸\ ,eol:¬
set nolist
function OpenGUIEditor()
if executable('mvim')
let cmd = "!mvim '" . expand("%") . "'"
exec cmd
endif
endfunction
command! OpenInGUI call OpenGUIEditor()
" Ctrl-P
let g:ctrlp_map = '<leader>t'
let g:ctrlp_cmd = 'CtrlPMixed'
let g:ctrlp_working_path_mode = 'r'
let g:ctrlp_max_files = 0
let g:ctrlp_max_height = 20
let g:ctrlp_max_depth = 40
" This depends on the cmatcher plugin
let g:ctrlp_match_func = {'match' : 'matcher#cmatch' }
" Text
autocmd Filetype text,markdown set textwidth=80
" Todo
autocmd BufRead todo.txt set filetype=todotxt
" Closetag
let g:closetag_html_style=1
autocmd Filetype html,xml,eruby source ~/.vim/scripts/closetag.vim
" Ctags so we can use Ctrl-] to jump down and Ctrl-T to jump up
command! ReTag !ctags -R .
nmap <leader>rt :ReTag<cr>
" ErlangTags for erlang
autocmd Filetype erlang nmap <leader>rt :ErlangTags<cr>
let g:erlangWranglerPath = '/Users/phil/Source/wrangler'
"sample wrangler bindings
autocmd FileType erlang vnoremap <leader>e :WranglerExtractFunction<ENTER>
autocmd FileType erlang noremap <leader>m :WranglerRenameModule<ENTER>
autocmd FileType erlang noremap <leader>f :WranglerRenameFunction<ENTER>
autocmd FileType erlang noremap <leader>v :WranglerRenameVariable<ENTER>
autocmd FileType erlang noremap <leader>p :WranglerRenameProcess<ENTER>
autocmd FileType erlang noremap <leader>mv :WranglerMoveFunction<ENTER>
autocmd FileType erlang noremap <leader>u :WranglerUndo<ENTER>
" NERDTree
" Close NERDTree when it is the last window
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
let NERDTreeIgnore = ['\.pyc$', '\.beam$', '\.o$']
map <F8> :NERDTreeToggle<cr>
" rooter
let g:rooter_patterns = ['Rakefile', '.git/', 'Gemfile', 'rebar.config']
let g:rooter_manual_only = 1
" Custom mappings
map <leader>mt :vsplit ~/Dropbox/todo.txt\|:set filetype=todotxt<cr>
map <leader>rs :source $MYVIMRC<cr>
map <leader>ev :vsplit $MYVIMRC<cr>
" reindet the whole buffer and save position
map <leader>ri :norm mz<cr>gg=G:norm 'z<cr>
map <leader>lt <Plug>TaskList
" highlight long lines
nnoremap <Leader>H :call<SID>LongLineHLToggle()<cr>
hi OverLength ctermbg=none cterm=none
match OverLength /\%>80v/
fun! s:LongLineHLToggle()
if !exists('w:longlinehl')
let w:longlinehl = matchadd('ErrorMsg', '.\%>80v', 0)
echo "Long lines highlighted"
else
call matchdelete(w:longlinehl)
unl w:longlinehl
echo "Long lines unhighlighted"
endif
endfunction
" remove trailing whitespace by command or on save
map <leader>fw :FixWhitespace<cr>
" configure dash
nmap <silent> <leader>g <Plug>DashSearch
nmap <silent> <leader>G <Plug>DashGlobalSearch
let g:dash_map = {
\ 'ruby' : 'ruby2',
\ 'java' : 'java',
\ 'javascript' : 'javascript',
\ 'erlang' : 'erlang'
\ }
" use ag instead of grep
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
" bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
" bind \ (backward slash) to grep shortcut
command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
nnoremap \ :Ag<SPACE>
" gist vim
let g:gist_clip_command = 'pbcopy'
let g:gist_detect_filetype = 1
let g:gist_open_browser_after_post = 1
let g:gist_browser_command = 'open -a Firefox %URL%'
" Syntastic
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_enable_erlang_checker = 0