-
Notifications
You must be signed in to change notification settings - Fork 3
/
vimrc
443 lines (365 loc) · 10.4 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
436
437
438
439
440
441
442
443
set nocompatible
filetype off
set runtimepath+=~/.vim/bundle/vundle/
call vundle#rc()
" Bundles {{{1
Bundle 'gmarik/vundle'
Bundle 'ervandew/supertab'
Bundle 'kien/ctrlp.vim'
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/syntastic'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-commentary'
Bundle 'tpope/vim-repeat'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-unimpaired'
Bundle 'tpope/vim-ragtag'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'Lokaltog/vim-powerline'
Bundle 'vim-scripts/camelcasemotion'
Bundle 'vim-scripts/ReplaceWithRegister'
Bundle 'bronson/vim-trailing-whitespace'
Bundle 'godlygeek/tabular'
Bundle 'gregsexton/MatchTag'
Bundle 'michaeljsmith/vim-indent-object'
Bundle 'coderifous/textobj-word-column.vim'
Bundle 'kana/vim-textobj-user'
Bundle 'tpope/vim-git'
Bundle 'othree/html5.vim'
Bundle 'kchmck/vim-coffee-script'
Bundle 'groenewege/vim-less'
Bundle 'wavded/vim-stylus'
Bundle 'vim-scripts/indentpython.vim--nianyang'
Bundle 'vim-scripts/VimClojure'
Bundle 'aliva/vim-fish'
Bundle 'leafgarland/typescript-vim'
Bundle 'nelstrom/vim-textobj-rubyblock'
Bundle 'altercation/vim-colors-solarized'
Bundle 'vim-scripts/Zenburn'
Bundle 'sjl/badwolf'
" }}}1
" Options {{{1
filetype plugin indent on
set shell=/bin/bash
set cpoptions+=J
set novisualbell t_vb=
set title
set t_Co=256
set ttyfast
set lazyredraw " Do not redraw buffer then executing macros etc.
set mousehide
set termencoding=utf-8
set fileencodings=utf-8,windows-1251,iso-8859-15,koi8-r
set encoding=utf8
set hidden
set virtualedit=all
set backspace=indent,eol,start
set nojoinspaces
set formatoptions-=o " Do not continue comments when pressing o/O
set shellslash
set autoread
set autowrite
set scrolljump=1
set scrolloff=7
set sidescrolloff=10
set sidescroll=10
set incsearch
set hlsearch
set wrapscan
set ignorecase
set smartcase
set noinfercase
set gdefault
set autoindent
set smartindent
set shiftwidth=4
set softtabstop=4
set tabstop=4
set expandtab
set nowrap
set textwidth=79
set showmatch
set list
set listchars=tab:¬¬,extends:»,precedes:«
if exists('&colorcolumn')
set colorcolumn=80
endif
set foldmethod=indent
set foldlevel=20
set wildmenu
set wildcharm=<TAB>
set wildmode=list:longest
set wildignore+=.git,.hg,_darcs,.svn
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest
set wildignore+=*.pyc,*.pyo
set wildignore+=*.hi
set wildignore+=*.luac
set wildignore+=*.aux,*.out,*.toc
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg
set wildignore+=*.spl
set wildignore+=*.sw?
set wildignore+=*.DS_Store?
set wildignore+=*.mo
set wildignore+=node_modules
set wildignore+=env
set nobackup
set directory=$HOME/.vim/tmp
set viminfo='128,/32,:32,<64,@32,s10,h,n$HOME/.vim/viminfo
set sessionoptions=blank,buffers,curdir,slash,tabpages,unix
set cryptmethod=blowfish
set diffopt+=iwhite
set splitright
set splitbelow
set fillchars="" " Get rid of the silly characters in window separators
set showcmd " Show partial command (or visual selection size) in cmd line
set cmdheight=2
set laststatus=2
set statusline=%1*%m%*
set statusline+=%2*%r%*
set statusline+=%f%=
set statusline+=\ Col:%3*%03v%*\ Ln:%3*%03l%*/%3*%03L%*
set statusline+=\ File:%{&filetype}/%{&fileformat}/%{&fileencoding}
set statusline+=\ Char:%04b/0x%03B%*%<
set numberwidth=3
set nonumber
if exists('&relativenumber')
set norelativenumber
endif
if has('gui_running') " {{{2
set mouse=a
set mousemodel=popup
set guioptions-=T " No toolbar
set guioptions-=l " No scrollbars
set guioptions-=r
set guioptions-=L
set guioptions-=R
set guioptions-=m " No menu
set guicursor=n-v-c:block-Cursor-blinkon0
set guicursor+=ve:ver35-Cursor
set guicursor+=o:hor50-Cursor
set guicursor+=i-ci:ver25-Cursor
set guicursor+=r-cr:hor20-Cursor
set guicursor+=sm:block-Cursor-blinkwait175-blinkoff150-blinkon17
set guifont=Ubuntu\ Mono
endif " }}}2
syntax on
set synmaxcol=512
" }}}1
" Mappings {{{1
let mapleader = ","
let maplocalleader = "\\"
set pastetoggle=<F12>
nnoremap ; :
inoremap jj <ESC>
inoremap jk <ESC>
inoremap kj <ESC>
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
nnoremap / /\v
nnoremap H <C-w>h
nnoremap L <C-w>l
nnoremap K <C-w><C-w>
nnoremap <left> <C-w>h
nnoremap <right> <C-w>l
nnoremap <up> <C-w>k
nnoremap <down> <C-w>j
nnoremap Y y$
" - to toggle folds.
nnoremap - za
vnoremap - za
nnoremap _ zM
nnoremap + zR
" nnoremap <BS>
" Center screen on search match
nnoremap n nzzzv
nnoremap N Nzzzv
" Select just pasted text
nnoremap <leader>v V`]
" Paste in visual mode without losing register content
xnoremap <expr> p v:register=='"'?'pgvy':'p'
" Allow command line editing like emacs
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-B> <Left>
cnoremap <C-F> <Right>
cnoremap <C-N> <Down>
cnoremap <C-P> <Up>
" Write as sudo
cnoremap w!! w !sudo tee % >/dev/null
" Toggle wrap
nnoremap <leader>iw :set invwrap<CR>:set wrap?<CR>
" Toggle line numbers
nnoremap <leader>in :set invnumber<CR>:set number?<CR>
" Toggle spell checking
nnoremap <leader>is :set invspell<CR>:set spell?<CR>
" Disable search highlight
nnoremap <leader>dh :silent nohlsearch<CR>
" Highlight all instances of the current word under the cursor
nnoremap <silent> <leader>hh :setl hls<CR>:let @/="\\<<C-r><C-w>\\>"<CR>
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
nnoremap <leader>rv :source $MYVIMRC<cr>
" Plugins
let g:ctrlp_map = '<leader>t'
let g:EasyMotion_leader_key = '<Space>'
nnoremap <leader>it :NERDTreeToggle<CR>
nnoremap ys<space> ysl<space><space>
nnoremap <silent> <leader>gs :Gstatus<CR>
nnoremap <silent> <leader>gl :Glog<CR>
nnoremap <silent> <leader>gc :Gcommit<CR>
nnoremap <silent> <leader>gd :Gdiff<CR>
nnoremap <silent> <leader>gw :Gwrite<CR>
nnoremap <silent> <leader>gr :Gread<CR>
nnoremap <silent> <leader>ge :Gedit<CR>
nnoremap <silent> <leader>gg :Ggrep <C-r><C-w><CR>
nnoremap <leader>a= :Tabularize /=<CR>
vnoremap <leader>a= :Tabularize /=<CR>
nnoremap <leader>a: :Tabularize /:\zs<CR>
vnoremap <leader>a: :Tabularize /:\zs<CR>
nnoremap <F6> :GundoToggle<CR>
nnoremap <F7> :SyntasticCheck<CR>
" }}}1
" Plugins {{{1
runtime macros/matchit.vim
" Fugitive
if has("autocmd")
augroup fugutiveAU
autocmd!
autocmd BufReadPost fugitive://* set bufhidden=delete
autocmd User fugitive
\ if fugitive#buffer().type() =~# '^\%(tree\|blob\)$' |
\ nnoremap <buffer> .. :edit %:h<CR> |
\ endif
augroup END
endif
let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp'
if has('win32')
let g:ctrlp_cache_dir = $TEMP.'/ctrlp'
endif
let g:Powerline_symbols='compatible'
if has('gui_running')
let g:Powerline_symbols='fancy'
endif
let g:uritality_color_insert = "#d9cec3"
let g:uritality_color_normal = "#aeee00"
let g:syntastic_mode_map = { 'mode': 'active',
\ 'active_filetypes': [],
\ 'passive_filetypes': ['java'] }
" }}}1
" Autocommands {{{1
if has("autocmd")
augroup FTOptions " {{{2
autocmd!
autocmd FileType vim setlocal foldmethod=marker
autocmd FileType sh setlocal foldmethod=marker
autocmd FileType zsh setlocal foldmethod=marker
autocmd FileType gitcommit setlocal spell textwidth=72
autocmd FileType html,htmldjango,eco,yaml,coffee setlocal sw=2 sts=2 ts=2 et tw=0
autocmd FileType mail setlocal wrap
autocmd FileType python setlocal nosmartindent
autocmd FileType ruby,eruby setlocal sw=2 sts=2 ts=2 et
autocmd FileType lisp setlocal commentstring=;;%s
autocmd FileType css,less setlocal tw=0
autocmd BufNewFile,BufRead *.sls setfiletype yaml
augroup END " }}}2
augroup Misc " {{{2
autocmd!
autocmd FocusLost * :wa
autocmd VimResized * exe "normal! \<c-w>="
augroup END " }}}2
end
" }}}1
" Commands {{{1
command! -bar Invert :let &background = (&background == "light" ? "dark" : "light")
function! OpenURL(url)
if has("win32")
exe "!start cmd /cstart /b ".a:url.""
elseif $DISPLAY !~ '^\w'
exe "silent !firefox \"".a:url."\""
else
exe "silent !firefox -T \"".a:url."\""
endif
redraw!
endfunction
command! -nargs=1 OpenURL :call OpenURL(<q-args>)
nnoremap gG :OpenURL https://encrypted.google.com/search?q=<cword><CR>
function! s:VSetSearch()
let temp = @@
norm! gvy
let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
let @@ = temp
endfunction
vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR><c-o>
vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR><c-o>
" Next and Last {{{
" Motion for "next/last object". "Last" here means "previous", not "final".
" Unfortunately the "p" motion was already taken for paragraphs.
"
" Next acts on the next object of the given type in the current line, last acts
" on the previous object of the given type in the current line.
"
" Currently only works for (, [, {, b, r, B, ', and ".
"
" Some examples (C marks cursor positions, V means visually selected):
"
" din' -> delete in next single quotes foo = bar('spam')
" C
" foo = bar('')
" C
"
" canb -> change around next parens foo = bar('spam')
" C
" foo = bar
" C
"
" vil" -> select inside last double quotes print "hello ", name
" C
" print "hello ", name
" VVVVVV
onoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr>
xnoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr>
onoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr>
xnoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr>
onoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr>
xnoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr>
onoremap il :<c-u>call <SID>NextTextObject('i', 'F')<cr>
xnoremap il :<c-u>call <SID>NextTextObject('i', 'F')<cr>
function! s:NextTextObject(motion, dir)
let c = nr2char(getchar())
if c ==# "b"
let c = "("
elseif c ==# "B"
let c = "{"
elseif c ==# "r"
let c = "["
endif
exe "normal! ".a:dir.c."v".a:motion.c
endfunction
" }}}
" }}}
" Abbreviations {{{1
function! EatChar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunction
function! MakeSpacelessIabbrev(from, to)
execute "iabbrev <silent> ".a:from." ".a:to."<C-R>=EatChar('\\s')<CR>"
endfunction
call MakeSpacelessIabbrev('***', '*args, **kwargs')
call MakeSpacelessIabbrev('pdb', 'import pdb; pdb.set_trace()')
iabbrev dm@ dmedvinsky@gmail.com
iab wekk week
iab Wekk Week
iab chage change
iab Chage Change
iab reutrn return
iab reutn return
iab reurn return
iab labmda lambda
iab consoel console
" }}}
if filereadable($HOME."/.vim/local/vimrc")
set runtimepath+=$HOME/.vim/local/
source $HOME/.vim/local/vimrc
endif