-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
436 lines (372 loc) · 11.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
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
scriptencoding utf-8
set encoding=utf-8
" ----------------------------------------
" Bindings
" ----------------------------------------
" Set leader to ,
" Note: This line MUST come before any <leader> mappings
let mapleader=","
let localmapleader=","
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle
" required!
Plugin 'gmarik/Vundle.vim'
nmap <Leader>bi :PluginInstall<CR>
nmap <Leader>bu :PluginInstall!<CR> " Because this also updates
nmap <Leader>bc :PluginClean<CR>
""""""""""""""""""""
" My Plugins here:
""""""""""""""""""""
" Programming langueges
" JavaScript
Plugin 'pangloss/vim-javascript'
Plugin 'kchmck/vim-coffee-script'
Plugin 'leshill/vim-json'
Plugin 'JarrodCTaylor/vim-ember-cli-test-runner'
nmap <Leader>res :RunSingleEmberTest<CR>
nmap <Leader>rem :RunSingleEmberTestModule<CR>
nmap <Leader>re :RunAllEmberTests<CR>
nmap <Leader>rre :RerunLastEmberTests<CR>
" HTML
Plugin 'mustache/vim-mustache-handlebars'
let g:syntastic_html_tidy_quiet_messages = { "level" : "warnings" }
Plugin 'othree/html5.vim'
Plugin 'indenthtml.vim'
Plugin 'mattn/emmet-vim'
" Other Languages
Plugin 'mutewinter/nginx.vim'
Plugin 'timcharper/textile.vim'
Plugin 'hail2u/vim-css3-syntax'
Plugin 'mutewinter/vim-markdown'
Plugin 'jQuery'
Plugin 'tpope/vim-haml'
Plugin 'slim-template/vim-slim'
Plugin 'groenewege/vim-less'
Plugin 'ap/vim-css-color'
Plugin 'heartsentwined/vim-emblem'
Plugin 'elixir-lang/vim-elixir'
" Ruby
Plugin 'vim-ruby/vim-ruby'
" Toggle between do/end and curly brackets
Plugin 'blockle.vim'
" Rails
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-rake'
Plugin 'tpope/vim-bundler'
Plugin 'tpope/vim-cucumber'
Plugin 'ecomba/vim-ruby-refactoring'
Plugin 'tpope/vim-dispatch'
" NERDTree
Plugin 'scrooloose/nerdtree'
nnoremap <leader>nn :NERDTreeToggle<CR>
let NERDTreeIgnore=[ '\.pyc$', '\.pyo$', '\.py\$class$', '\.obj$', '\.o$', '\.so$', '\.egg$', '^\.git$' ]
let NERDTreeHighlightCursorline=1
let NERDTreeShowFiles=1
Plugin 'Xuyuanp/nerdtree-git-plugin'
" Git wrapper -----------
Plugin 'tpope/vim-fugitive'
nmap <Leader>gc :Gcommit -v<CR>
nmap <Leader>gw :Gwrite<CR>
nmap <Leader>gs :Gstatus<CR>
nmap <Leader>gp :Git push<CR>
" Mnemonic, gu = Git Update
nmap <Leader>gu :Git pull<CR>
nmap <Leader>gd :Gdiff<CR>
nmap <Leader>dgl :diffget LO<CR> :diffupdate<CR>
nmap <Leader>dgr :diffget RE<CR> :diffupdate<CR>
nmap <Leader>do :only<CR>
" Exit a diff by closing the diff window
nmap <Leader>gx :wincmd h<CR>:q<CR>
" Indent Guides --------
Plugin 'nathanaelkane/vim-indent-guides'
let g:indent_guides_enable_on_vim_startup=1
" Powerline ----------
Plugin 'bling/vim-airline'
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols = {}
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
" MiniBufExplorer ----------
Plugin 'fholgado/minibufexpl.vim'
map <Leader>l :MBEToggle<CR>:MBEFocus<CR>
let g:miniBufExplBRSplit = 1
let g:miniBufExplVSplit = 35
let g:miniBufExplAutoStart = 0
" Tabular --------
Plugin 'junegunn/vim-easy-align'
vmap <Enter> <Plug>(EasyAlign)
" Zoomwin ----------
Plugin 'ZoomWin'
noremap <Leader>o :ZoomWin<CR>
vnoremap <Leader>o <C-C>:ZoomWin<CR>
inoremap <Leader>o <C-O>:ZoomWin<CR>
noremap <C-W>+o :ZoomWin<CR>
" Yanking hictory management
Plugin 'YankRing.vim'
let g:yankring_replace_n_pkey = '<C-M>'
nnoremap <silent> ,yy :YRShow<CR>
nnoremap <silent> ,yc :YRClear<CR>
" CtrlP -------
Plugin 'kien/ctrlp.vim'
let g:ctrlp_map = '<c-p>'
let g:ctrlp_custom_ignore = '/\.\|\.o\|\.so\|vendor\|tmp'
let g:ctrlp_open_new_file='r'
let g:ctrlp_max_height=30
let g:ctrlp_lazy_update=1
" Gundo ---------
Plugin 'sjl/gundo.vim'
nnoremap <C-u> :GundoToggle<CR>
let g:gundo_width = 35
" QuickFixSigns
Plugin 'tomtom/quickfixsigns_vim'
let g:quickfixsigns_classes=['qfl', 'vcsdiff', 'breakpoints']
" Color schemes
Plugin 'nanotech/jellybeans.vim'
" Nice start screen
Plugin 'mhinz/vim-startify'
let g:startify_bookmarks = ['~/.vimrc',]
let g:startify_custom_footer = map(split(system('fortune ~/.vim/fortunes | cowthink -W 80'), '\n'), '" ". v:val') + ['','']
" Utilities
Plugin 'justinmk/vim-sneak'
Plugin 'tpope/vim-surround'
Plugin 'ervandew/supertab'
Plugin 'tpope/vim-endwise'
Plugin 'msanders/snipmate.vim'
Plugin 'matchit.zip'
Plugin 'tomtom/tcomment_vim'
" Plugin 'TaskList.vim'
Plugin 'rking/ag.vim'
" Plugin 'Valloric/YouCompleteMe'
Plugin 'IndexedSearch'
Plugin 'Raimondi/delimitMate'
Plugin 'AutoTag'
Plugin 'bkad/CamelCaseMotion'
Plugin 'lukaszkorecki/CoffeeTags'
" Time tracker
Plugin 'wakatime/vim-wakatime'
" Highlight when replace
Plugin 'osyo-manga/vim-over'
function! VisualFindAndReplace()
:OverCommandLine%s/
:w
endfunction
function! VisualFindAndReplaceWithSelection() range
:'<,'>OverCommandLine s/
:w
endfunction
nnoremap <Leader>fr :call VisualFindAndReplace()<CR>
xnoremap <Leader>fr :call VisualFindAndReplaceWithSelection()<CR>
Plugin 'scrooloose/syntastic'
let g:syntastic_check_on_open=1
let g:syntastic_enable_signs=1
call vundle#end() " required!
filetype plugin indent on " required!
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" -----------------------------
" Backups, swapfiles, Tmp Files
" -----------------------------
set nobackup
set nowritebackup
set noswapfile
" Undo
set undolevels=10000
if has("persistent_undo")
set undodir=~/.vim/.undo " Allow undoes to persist even after a file is closed
set undofile
endif
" viminfo: remember certain things when we exit
" (http://vimdoc.sourceforge.net/htmldoc/usr_21.html)
" % : saves and restores the buffer list
" '100 : marks will be remembered for up to 30 previously edited files
" /100 : save 100 lines from search history
" h : disable hlsearch on start
" "500 : save up to 500 lines for each register
" :100 : up to 100 lines of command-line history will be remembered
" n... : where to save the viminfo files
set viminfo=%100,'100,/100,h,\"500,:100,n~/.vim/viminfo
"--------------------------
" Display options
"--------------------------
syntax on
set cursorline
set number
set list! " Display unprintable characters
set listchars=tab:▸\ ,trail:•,extends:»,precedes:«
if $TERM =~ '256color'
set t_Co=256
elseif $TERM =~ '^xterm$'
set t_Co=256
endif
set laststatus=2 " Always show the statusline
set background=dark
colorscheme jellybeans
"--------------------------
" Copy/paste from/to Window clipboard
"--------------------------
set clipboard=unnamed " Paste to vim from Window Clipboard
nnoremap <C-y> "+y
vnoremap <C-y> "+y
"--------------------------
" Resizing splits
"--------------------------
if bufwinnr(1)
nmap = <C-W>=
nmap + <C-W>+
nmap - <C-W>-
nmap <c-n> <C-w><
nmap <c-m> <C-w>>
endif
"--------------------------
" Moving between splits
"--------------------------
noremap <C-J> <C-W>j
noremap <C-K> <C-W>k
noremap <C-H> <C-W>h
noremap <C-L> <C-W>l
"--------------------------
" Keybindings to native vim features
nnoremap <leader>s :%s/
vnoremap <leader>s :%s/
map <Leader>/ :nohlsearch<cr>
"--------------------------
" Git blame to how modified lines
"--------------------------
vmap <leader>w :<C-U>!git blame <C-R>=expand("%:p") <CR> \| sed -n <C-R>=line("'<") <CR>,<C-R>=line("'>") <CR>p <CR>
"--------------------------
" Edit another file in same directory
"--------------------------
map <leader>ee :e <C-R>=expand("%:p:h") . '/'<CR>
map <leader>es :split <C-R>=expand("%:p:h") . '/'<CR>
map <leader>ev :vnew <C-R>=expand("%:p:h") . '/'<CR>
"--------------------------
" Subsitude
"--------------------------
nnoremap <leader>s :%s/
vnoremap <leader>s :%s/
"--------------------------
" Ctags options
"--------------------------
"set tags+=./tags;/
map <leader>] <C-]>
map <leader>]p <C-T>
map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
map <leader>]v :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
map <leader>]h :sp <CR>:exec("tag ".expand("<cword>"))<CR>
autocmd BufWritePost *
\ if filereadable('tags') |
\ call system('ctags -a '.expand('%')) |
\ endif
"--------------------------
" Misc
"--------------------------
filetype plugin indent on " Do filetype detection and load custom file plugins and indent files
set hidden " Don't abandon buffers moved to the background
set wildmenu " Enhanced completion hints in command line
set backspace=eol,start,indent " Allow backspacing over indent, eol, & start
set complete=.,w,b,u,U,t,i,d " Do lots of scanning on tab completion
set diffopt=filler,iwhite " In diff mode, ignore whitespace changes and align unchanged lines
set scrolloff=3 " Start scrolling 3 lines before the horizontal window border
set noerrorbells " Disable error bells
set cpoptions+=$ " Put '$' at the end of the changed text
" Check syntax for ruby
autocmd FileType ruby map <F9> :w !ruby -c<CR>
" up/down on displayed lines, not real lines. More useful than painful.
noremap k gk
noremap j gj
" Map Ctrl-a to highlight all code
nmap <C-a> gg<S-v><S-g>
"--------------------------
" Folding
"--------------------------
set foldenable
set foldmethod=syntax
set foldlevel=1
"--------------------------
" Sintax highlighting
"--------------------------
" Hamlc syntax highlighting
au BufRead,BufNewFile *.hamlc set ft=haml
" add jbuilder syntax highlighting
au BufNewFile,BufRead *.json.jbuilder set ft=ruby
"--------------------------
" Editing vimrc
"--------------------------
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
"--------------------------
" Indentation and tabbing
"--------------------------
set autoindent smartindent
set smarttab
set tabstop=2
set shiftwidth=2 " Indentation
set softtabstop=2 " This makes the backspace key treat the spaces like a tab
set expandtab " Spaces instead of tab
" Search settings
set ignorecase
set smartcase
set hlsearch
set incsearch
set showmatch
" ---------------
" Mouse
" ---------------
set mousehide " Hide mouse after chars typed
set mouse=a " Mouse in all modes
set ttymouse=xterm2 " fix mouse support inside tmux
"""""""""""""""""""""""""
" Custom functions
"""""""""""""""""""""""""
nmap fc :call CleanClose(1)<cr>
nmap fq :call CleanClose(0)<cr>
" Prettify json
nmap =j :%!python -m json.tool<CR>
function! CleanClose(tosave)
if (a:tosave == 1)
w!
endif
let todelbufNr = bufnr("%")
let newbufNr = bufnr("#")
if ((newbufNr != -1) && (newbufNr != todelbufNr) && buflisted(newbufNr))
exe "b".newbufNr
else
bnext
endif
if (bufnr("%") == todelbufNr)
new
endif
exe "bd!".todelbufNr
endfunction
" When opening a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
" Always edit file, even when swap file is found
set shortmess+=A
" Toggle paste mode while in insert mode with F12
set pastetoggle=<F12>
au BufNewFile,BufRead *.less set filetype=less
" cscope
if has("cscope")
set cscopetag " use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
" check cscope for definition of a symbol before checking ctags: set to 1
" if you want the reverse search order.
set csto=0
" add any cscope database in current directory
if filereadable("cscope.out")
cs add cscope.out
endif
" show msg when any other cscope db added
set cscopeverbose
end
" ruby path if you are using RVM
let g:ruby_path = system('rvm current')