forked from arunthampi/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
349 lines (285 loc) · 8.74 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
set nocompatible " choose no compatibility with legacy vi
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
Bundle 'kien/ctrlp.vim'
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/nerdcommenter'
Bundle 'mileszs/ack.vim'
Bundle 'tpope/vim-fugitive'
" color themes
Bundle 'altercation/vim-colors-solarized'
Bundle 'jpo/vim-railscasts-theme'
Bundle 'fugalh/desert.vim'
Bundle 'nanotech/jellybeans.vim'
Bundle 'tomasr/molokai'
Bundle 'scrooloose/syntastic'
Bundle 'nathanaelkane/vim-indent-guides'
" languages
Bundle 'tpope/vim-git'
Bundle 'tpope/vim-bundler'
Bundle 'vim-ruby/vim-ruby'
Bundle 'tpope/vim-rails'
Bundle 'skwp/vim-rspec'
Bundle 'tpope/vim-cucumber'
Bundle 'pangloss/vim-javascript'
Bundle 'mmalecki/vim-node.js'
Bundle 'kchmck/vim-coffee-script'
Bundle 'nono/jquery.vim'
Bundle 'briancollins/vim-jst'
Bundle 'othree/html5.vim'
Bundle 'hail2u/vim-css3-syntax'
Bundle 'ap/vim-css-color'
Bundle 'cakebaker/scss-syntax.vim'
Bundle 'groenewege/vim-less'
Bundle 'wavded/vim-stylus'
Bundle 'tpope/vim-haml'
Bundle 'digitaltoad/vim-jade'
Bundle 'nono/vim-handlebars'
Bundle 'tpope/vim-liquid'
Bundle 'msanders/cocoa.vim'
Bundle 'tpope/vim-markdown'
Bundle 'timcharper/textile.vim'
Bundle 'jnwhiteh/vim-golang'
Bundle 'Blackrush/vim-gocode'
Bundle 'vim-scripts/csv.vim'
" pete --------------
Bundle 'fholgado/minibufexpl.vim'
Bundle 'vim-scripts/bufkill.vim'
" -----------
"------------------------------------------------------------------------------
" Key Bindings
" Map the Leader to , and remap ; to :
"
let mapleader = ","
nnoremap ; :
" Forcing me to use vim the right way
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
nnoremap j gj
nnoremap k gk
" ,w is used to create a vertical split pane
nnoremap <leader>w <C-w>v<C-w>l
" ,h is used to create a horizontal split pane
nnoremap <leader>h <C-w>s<C-w>l
" Ctrl-h,j,k,l is used to move between panes
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" upper/lower word
nmap <leader>u mQviwU`Q
nmap <leader>l mQviwu`Q
" upper/lower first char of word
nmap <leader>U mQgewvU`Q
nmap <leader>L mQgewvu`Q
" To switch between the currently open buffer and the previous one
nnoremap <leader><leader> <c-^>
" Strip all trailing whitespaces in the current file
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" Escape to normal mode quickly
inoremap jj <ESC>
"------------------------------------------------------------------------------
" set default color theme
"
"------------------------------------------------------------------------------
" basic
"
set number
set ruler " show line and column number
syntax enable
set encoding=utf-8
set visualbell " shut vim up
set noerrorbells
set nobackup
"------------------------------------------------------------------------------
" Whitespace
"
set nowrap " don't wrap lines
set tabstop=2 shiftwidth=2 " a tab is two spaces (or set this to 4)
set expandtab " use spaces, not tabs (optional)
set backspace=indent,eol,start " backspace through everything in insert mode
set list
set listchars="" " reset listchars
set listchars=tab:\|\ " display tabs with a sign
set listchars+=trail:· " display trailing whitespaces with a dot
set listchars+=extends:» " right wrap
set listchars+=precedes:« " left wrap
"------------------------------------------------------------------------------
" Searching
"
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase " searches are case insensitive...
set smartcase " ... unless they contain at least one capital letter
"------------------------------------------------------------------------------
" wild
"
set wildmode=list:longest
set wildmenu
set wildignore=*.o,*.out,*.obj,*.class
set wildignore+=*.swp,*~,._*
set wildignore+=*.png,*.jpg,*.gif
set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz
set wildignore+=.git,.svn
set wildignore+=*vim/backups*
set wildignore+=*sass-cache*
set wildignore+=*DS_Store*
set wildignore+=*/vendor/rails/**
set wildignore+=*/vendor/cache/**
set wildignore+=*/vendor/bundle/**
set wildignore+=*/vendor/submodules/**
set wildignore+=*/vendor/plugins/**
set wildignore+=*/vendor/gems/**
set wildignore+=*/.bundle/**
set wildignore+=*.gem
set wildignore+=*/log/**
set wildignore+=*/tmp/**
"------------------------------------------------------------------------------
" backup & swap
"
set backupdir=~/.vim/_backup// " backup
set directory=~/.vim/_temp// " swap
"-----------------------------------------------------------------------------
" omnifunc
"
set omnifunc=syntaxcomplete#Complete
"------------------------------------------------------------------------------
" fugitive
"
nmap <leader>gb :Gblame<CR>
nmap <leader>gs :Gstatus<CR>
nmap <leader>gd :Gdiff<CR>
nmap <leader>gl :Glog<CR>
nmap <leader>gc :Gcommit<CR>
nmap <leader>gp :Git push<CR>
"------------------------------------------------------------------------------
" nerdtree
"
let NERDTreeIgnore=['\.pyc$', '\.pyo$', '\.rbc$', '\.rbo$', '\.class$', '\.o$', '\~$']
let NERDTreeHijackNetrw = 0
augroup AuNERDTreeCmd
autocmd AuNERDTreeCmd VimEnter * call s:CdIfDirectory(expand("<amatch>"))
autocmd AuNERDTreeCmd FocusGained * call s:UpdateNERDTree()
" If the parameter is a directory, cd into it
function s:CdIfDirectory(directory)
let explicitDirectory = isdirectory(a:directory)
let directory = explicitDirectory || empty(a:directory)
if explicitDirectory
exe "cd " . fnameescape(a:directory)
endif
" Allows reading from stdin
" ex: git diff | mvim -R -
if strlen(a:directory) == 0
return
endif
if directory
NERDTree
wincmd p
bd
endif
if explicitDirectory
wincmd p
endif
endfunction
" NERDTree utility function
function s:UpdateNERDTree(...)
let stay = 0
if(exists("a:1"))
let stay = a:1
end
if exists("t:NERDTreeBufName")
let nr = bufwinnr(t:NERDTreeBufName)
if nr != -1
exe nr . "wincmd w"
exe substitute(mapcheck("R"), "<CR>", "", "")
if !stay
wincmd p
end
endif
endif
endfunction
" nerd tree
map <leader>n :NERDTreeToggle<CR>
" nerd commenter
map <leader>/ <plug>NERDCommenterToggle<CR>
" ack shortcut
nnoremap <leader>a :Ack
" -- pete
map <C-c> <ESC>
map <leader>] :tabn<CR>
map <leader>[ :tabp<CR>
nmap <leader>; :bp<CR>
nmap <leader>' :bn<CR>
" much more natural cursor movement when wrapping lines are present
map j gj
map k gk
map <Down> gj
map <Up> gk
" ctrl-p
map <C-t> :CtrlP<CR>
imap <C-t> <ESC>:CtrlP<CR>
map <leader>t :CtrlP<CR>
" Some helpers to edit mode
" http://vimcasts.org/e/14
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>ew :e %%
map <leader>es :sp %%
map <leader>ev :vsp %%
map <leader>et :tabe %%
let g:solarized_termcolors=256
let g:solarized_termtrans=1
let g:solarized_visibility="high"
set background=dark
colorscheme solarized
if has("autocmd")
au FileType scala set tabstop=2 shiftwidth=2 expandtab
endif
"------------------------------------------------------------------------------
" filetypes
" https://raw.github.com/carlhuda/janus/master/janus/vim/core/before/plugin/filetypes.vim
"
function! s:setupWrapping()
set wrap
set linebreak
set textwidth=72
set nolist
endfunction
filetype plugin on " Turn on filetype plugins (:help filetype-plugin)
filetype plugin indent on
" In Makefiles, use real tabs, not tabs expanded to spaces
au FileType make set noexpandtab
" make Python follow PEP8 ( http://www.python.org/dev/peps/pep-0008/ )
au FileType python set softtabstop=4 tabstop=4 shiftwidth=4 textwidth=79
" Go: use tabs not spaces
au FileType go set noexpandtab
au BufWritePre *.go Fmt
" Remember last location in file, but not for commit messages.
" see :help last-position-jump
au BufReadPost * if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g`\"" | endif
au BufNewFile,BufRead *.{md,markdown,mdown,mkd,mkdn,txt} setf markdown | call s:setupWrapping()
au BufNewFile,BufRead *.json set ft=javascript
au BufNewFile,BufRead Podfile,*.podspec set filetype=ruby
au BufNewFile,BufRead *.hamlc,*.hbs.haml set filetype=haml
"------------------------------------------------------------------------------
" other settings
"
"
" https://github.com/carlhuda/janus/blob/master/janus/vim/tools/janus/after/plugin/syntastic.vim
let g:syntastic_enable_signs=1
let g:syntastic_quiet_messages = {'level': 'warnings'}
let g:syntastic_auto_loc_list=2
" ack on ubuntu
let g:ackprg="ack-grep -H --nocolor --nogroup --column"
" gitcommit
autocmd Filetype gitcommit setlocal spell textwidth=72