-
Notifications
You must be signed in to change notification settings - Fork 13
/
vimrc
414 lines (401 loc) · 16 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
set nocompatible
let iCanHazNeoBundle=1
let neobundle_readme=expand($HOME.'/.vim/bundle/neobundle.vim/README.md')
if !filereadable(neobundle_readme)
echo "Installing NeoBundle.."
echo ""
silent !mkdir -p $HOME/.vim/bundle
silent !git clone https://github.com/Shougo/neobundle.vim $HOME/.vim/bundle/neobundle.vim
let iCanHazNeoBundle=0
endif
if has('vim_starting')
set rtp+=$HOME/.vim/bundle/neobundle.vim/
endif
call neobundle#begin(expand($HOME.'/.vim/bundle/'))
NeoBundle 'Shougo/neobundle.vim'
NeoBundle 'bkad/CamelCaseMotion'
NeoBundle 'Shougo/neocomplcache.vim'
NeoBundle 'scrooloose/nerdtree'
NeoBundle 'altercation/vim-colors-solarized'
NeoBundle 'JarrodCTaylor/vim-256-color-schemes'
NeoBundle 'JarrodCTaylor/vim-reflection'
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'vim-airline/vim-airline-themes'
NeoBundle 'majutsushi/tagbar'
NeoBundle 'ervandew/supertab'
NeoBundle 'pangloss/vim-javascript'
NeoBundle 'scrooloose/syntastic'
NeoBundle 'kien/ctrlp.vim'
NeoBundle 'tpope/vim-commentary'
NeoBundle 'davidhalter/jedi-vim'
NeoBundle 'mhinz/vim-startify'
NeoBundle 'tpope/vim-surround'
NeoBundle 'JarrodCTaylor/vim-python-test-runner'
NeoBundle 'bling/vim-airline'
NeoBundle 'justinmk/vim-sneak'
NeoBundle 'JarrodCTaylor/vim-shell-executor'
NeoBundle 'epeli/slimux'
NeoBundle 'JarrodCTaylor/vim-qunit-special-blend'
NeoBundle 'JarrodCTaylor/spartan'
NeoBundle 'leafgarland/typescript-vim'
NeoBundle 'https://github.com/mattn/emmet-vim/'
NeoBundle 'osyo-manga/vim-over'
NeoBundle 'nathanaelkane/vim-indent-guides'
NeoBundle 'kien/rainbow_parentheses.vim'
NeoBundle 'wellle/targets.vim'
NeoBundle 'thinca/vim-qfreplace'
NeoBundle 'junegunn/vim-easy-align'
NeoBundle 'gilgigilgil/anderson.vim'
NeoBundle 'mustache/vim-mustache-handlebars'
NeoBundle 'trevordmiller/nova-vim'
NeoBundle '~/dotfiles/vim/my-plugins/nerd-ack', {'type': 'nosync'}
NeoBundle '~/dotfiles/vim/my-plugins/tmux-navigator', {'type': 'nosync'}
NeoBundle '~/dotfiles/vim/my-plugins/vim-ack', {'type': 'nosync'}
NeoBundle '~/dotfiles/vim/my-plugins/vim-grep-quickfix', {'type': 'nosync'}
NeoBundle '~/dotfiles/vim/my-plugins/vim-wiki-links', {'type': 'nosync'}
NeoBundle 'hhff/SpacegrayEighties.vim'
NeoBundle 'dracula/vim'
call neobundle#end()
filetype plugin on
filetype indent on
set t_Co=256
syntax on
set autoindent " Copy indent from current line
set autoread " Read open files again when changed outside Vim
set autowrite " Write a modified buffer on each :next , ...
set backspace=indent,eol,start " Backspacing over everything in insert mode
set history=200 " Keep 200 lines of command line history
set hlsearch " Highlight the last used search pattern
set incsearch " Do incremental searching
set listchars="" " Empty the listchars
set listchars=tab:>. " A tab will be displayed as >...
set listchars+=trail:. " Trailing white spaces will be displayed as .
set nobackup " Don't constantly write backup files
set noswapfile " Ain't nobody got time for swap files
set noerrorbells " Don't beep
set nowrap " Do not wrap lines
set popt=left:8pc,right:3pc " Print options
set shiftwidth=4 " Number of spaces to use for each step of indent
set showcmd " Display incomplete commands in the bottom line of the screen
set ignorecase " Ignore case when searching....
set smartcase " ...unless uppercase letter are used
set tabstop=4 " Number of spaces that a <Tab> counts for
set expandtab " Make vim use spaces and not tabs
set undolevels=1000 " Never can be too careful when it comes to undoing
set hidden " Don't unload the buffer when we switch between them. Saves undo history
set visualbell " Visual bell instead of beeping
set wildignore=*.swp,*.bak,*.pyc,*.class,tmp/**,dist/**,node_modules/** " wildmenu: ignore these extensions
set wildmenu " Command-line completion in an enhanced mode
set shell=bash " Required to let zsh know how to run things on command line
set ttimeoutlen=50 " Fix delay when escaping from insert with Esc
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline)
set showbreak=↪\
set synmaxcol=256
set scrolloff=3
set clipboard=unnamed
au BufNewFile,BufRead *.json set ft=javascript
set pastetoggle=<F3>
set nofoldenable
if has("autocmd")
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
endif
syntax enable
set t_Co=256
set t_ut=
colorscheme nova
set background=dark
hi clear
hi String ctermfg=81 ctermbg=NONE cterm=NONE guifg=#5fd7ff guibg=NONE gui=NONE
hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white
" set notermguicolors
let g:mustache_abbreviations = 1
if has("autocmd")
au BufNewFile,BufRead *.{mustache,handlebars,hbs}{,.erb} set filetype=html syntax=mustache | runtime! ftplugin/mustache.vim ftplugin/mustache*.vim ftplugin/mustache/*.vim
endif
:iabbr teh the
:iabbr condole console
nnoremap <Left> :vertical resize +1<CR>
nnoremap <Right> :vertical resize -1<CR>
nnoremap <Up> :resize +1<CR>
nnoremap <Down> :resize -1<CR>
set laststatus=2 " Make the second to last line of vim our status line
let g:airline_theme='understated' " Use the custom theme I wrote
let g:airline_left_sep='' " No separator as they seem to look funky
let g:airline_right_sep='' " No separator as they seem to look funky
let g:airline#extensions#branch#enabled = 0 " Do not show the git branch in the status line
let g:airline#extensions#syntastic#enabled = 1 " Do show syntastic warnings in the status line
let g:airline#extensions#tabline#show_buffers = 0 " Do not list buffers in the status line
let g:airline_section_x = '' " Do not list the filetype or virtualenv in the status line
let g:airline_section_y = '[R%04l,C%04v] [LEN=%L]' " Replace file encoding and file format info with file position
let g:airline_section_z = '' " Do not show the default file position info
let g:airline#extensions#virtualenv#enabled = 0
nnoremap <Leader>fr :call VisualFindAndReplace()<CR>
xnoremap <Leader>fr :call VisualFindAndReplaceWithSelection()<CR>
nnoremap Y y$
autocmd BufReadPost quickfix nnoremap <buffer> <CR> :.cc<CR>
autocmd BufReadPost quickfix nnoremap <buffer> o :.cc<CR>
nnoremap <Leader>W :%s/\s\+$//<CR>:let @/=''<CR>
cmap w!! w !sudo tee %
let g:syntastic_check_on_open=1 " check for errors when file is loaded
let g:syntastic_loc_list_height=5 " the height of the error list defaults to 10
let g:syntastic_python_checkers = ['flake8'] " sets flake8 as the default for checking python files
let g:syntastic_javascript_checkers = ['jshint'] " sets jshint as our javascript linter
let g:syntastic_filetype_map = { 'handlebars.html': 'handlebars' }
let g:syntastic_mode_map={ 'mode': 'active',
\ 'active_filetypes': [],
\ 'passive_filetypes': ['html', 'handlebars'] }
let g:neocomplcache_enable_at_startup=0
let g:jedi#auto_vim_configuration = 0
let g:jedi#goto_command = "<leader>j"
if !exists('g:neocomplcache_force_omni_patterns')
let g:neocomplcache_force_omni_patterns = {}
endif
let g:neocomplcache_force_omni_patterns.python = '[^. \t]\.\w*'
let g:neocomplcache_force_overwrite_completefunc = 1
let g:neocomplcache_auto_completion_start_length = 99
set completeopt-=preview
let g:ctrlp_use_caching=0
let g:ctrlp_custom_ignore = '\v[\/](transpiled)|dist|tmp|bower_components|node_modules|(\.(swp|git|bak|pyc|DS_Store))$'
let g:ctrlp_working_path_mode = 0
let g:ctrlp_max_files=0
let g:ctrlp_max_height = 18
let g:ctrlp_open_multiple_files = '1vjr'
let g:ctrlp_buffer_func = { 'enter': 'MyCtrlPMappings' }
func! MyCtrlPMappings()
nnoremap <buffer> <silent> <F6> :call <sid>DeleteBuffer()<cr>
endfunc
set tags=./.ctags,.ctags;
let NERDTreeIgnore = ['\.pyc$']
let g:NERDTreeMapJumpNextSibling = ''
let g:NERDTreeMapJumpPrevSibling = ''
let g:jedi#use_tabs_not_buffers = 0 " Use buffers not tabs
let g:jedi#popup_on_dot = 0
let g:jedi#rename_command = "<leader>rn"
let g:ctrlp_reuse_window = 'startify'
let g:startify_change_to_dir = 0
hi StartifyHeader ctermfg=124
let g:startify_show_files = 1
let g:startify_show_files_number = 10
let g:startify_bookmarks = [ '~/.vimrc' ]
let g:SuperTabDefaultCompletionType = "<c-n>"
let g:gundo_preview_bottom = 1
let g:markdown_fold_style = 'nested'
let g:markdown_fenced_languages = ['python', 'sh', 'vim', 'javascript', 'html', 'css', 'c', 'sql']
nmap f <Plug>SneakForward
nmap F <Plug>SneakBackward
let g:sneak#streak = 1
let g:sneak#target_labels = "sfgkqwetyupzcvbnmSDFGHJKLQWERTYUPZXCVBNM1234567890rx"
let g:user_emmet_install_global = 0
autocmd FileType html,htmldjango,handlebars EmmetInstall
let g:user_emmet_leader_key=','
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
let g:indent_guides_exclude_filetypes = ['help', 'nerdtree']
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=238
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=249
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['black', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['darkred', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['red', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ]
let g:rbpt_max = 16
let g:rbpt_loadcmd_toggle = 0
nnoremap <Esc><Esc> :nohlsearch<CR>
function! RenewTagsFile()
exe 'silent !rm -rf .ctags'
exe 'silent !ctags -a -Rf .ctags --languages=javascript --exclude=.git --exclude="*.min.js" --exclude=node_modules --exclude=tmp 2>/dev/null'
exe 'redraw!'
endfunction
function! SortLines() range
execute a:firstline . "," . a:lastline . 's/^\(.*\)$/\=strdisplaywidth( submatch(0) ) . " " . submatch(0)/'
execute a:firstline . "," . a:lastline . 'sort n'
execute a:firstline . "," . a:lastline . 's/^\d\+\s//'
endfunction
function! CopyFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
redraw!
endif
endfunction
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
nnoremap <silent> n n:call HLNext(0.4)<cr>
nnoremap <silent> N N:call HLNext(0.4)<cr>
function! HLNext (blinktime)
highlight HighlightStyle ctermfg=none ctermbg=160 cterm=none
let [bufnum, lnum, col, off] = getpos('.')
let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/))
let target_pat = '\c\%#'.@/
let ring = matchadd('HighlightStyle', target_pat, 101)
redraw
exec 'sleep ' . float2nr(a:blinktime * 500) . 'm'
call matchdelete(ring)
redraw
endfunction
" Code totally boosted from Tim Pope
function! s:setup_paste() abort
let s:paste = &paste
set paste
endfunction
nnoremap <silent> <Plug>unimpairedPaste :call <SID>setup_paste()<CR>
nnoremap <silent> yp :call <SID>setup_paste()<CR>a
nnoremap <silent> yP :call <SID>setup_paste()<CR>i
nnoremap <silent> yo :call <SID>setup_paste()<CR>o
nnoremap <silent> yO :call <SID>setup_paste()<CR>O
nnoremap <silent> yA :call <SID>setup_paste()<CR>A
nnoremap <silent> yI :call <SID>setup_paste()<CR>I
augroup unimpaired_paste
autocmd!
autocmd InsertLeave *
\ if exists('s:paste') |
\ let &paste = s:paste |
\ unlet s:paste |
\ endif
augroup END
map <silent> W <Plug>CamelCaseMotion_w
map <silent> E <Plug>CamelCaseMotion_e
map <silent> B <Plug>CamelCaseMotion_b
omap <silent> iW <Plug>CamelCaseMotion_iw
xmap <silent> iW <Plug>CamelCaseMotion_iw
omap <silent> iE <Plug>CamelCaseMotion_ie
xmap <silent> iE <Plug>CamelCaseMotion_ie
omap <silent> iB <Plug>CamelCaseMotion_ib
xmap <silent> iB <Plug>CamelCaseMotion_ib
function! Incr()
let a = line('.') - line("'<")
let c = virtcol("'<")
if a > 0
execute 'normal! '.c.'|'.a."\<C-a>"
endif
normal `<
endfunction
vnoremap <C-a> :call Incr()<CR>
function! s:DeleteBuffer()
let line = getline('.')
let bufid = line =~ '\[\d\+\*No Name\]$' ? str2nr(matchstr(line, '\d\+'))
\ : fnamemodify(line[2:], ':p')
exec "bd" bufid
exec "norm \<F5>"
endfunction
function! ToggleTodoCheckbox()
let line = getline('.')
if(match(line, "\\[ \\]") != -1)
let line = substitute(line, "\\[ \\]", "[√]", "")
let line = substitute(line, "$", " @done (" . strftime("%m/%d/%y %H:%M") . ")", "")
elseif(match(line, "\\[√\\]") != -1)
let line = substitute(line, "\\[√\\]", "[ ]", "")
let line = substitute(line, " @done.*$", "", "")
endif
call setline('.', line)
endfunction
let g:quickfix_is_open = 0
function! QuickfixToggle()
if g:quickfix_is_open
cclose
let g:quickfix_is_open = 0
execute g:quickfix_return_to_window . "wincmd w"
else
let g:quickfix_return_to_window = winnr()
copen
let g:quickfix_is_open = 1
endif
endfunction
function! FormatJSON()
:'<,'>!python -m json.tool
endfunction
command! -range FormatJSON call FormatJSON()
function! VisualFindAndReplace()
:OverCommandLine%s/
:w
endfunction
function! VisualFindAndReplaceWithSelection() range
:'<,'>OverCommandLine s/
:w
endfunction
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()
let mapleader=" "
nnoremap j gj
nnoremap k gk
nnoremap <Leader>ff :CtrlP<CR>
noremap <Leader>sp :set spell spelllang=en_us<CR>
nnoremap <Leader>tb :TagbarToggle<CR>
map <Leader>a :Ack!<space>
map <Leader>d :NERDTreeToggle<CR>
nmap <Leader>nt :NERDTreeFind<CR>
map <Leader>tw :DjangoTestApp<CR>
map <Leader>tf :DjangoTestFile<CR>
map <Leader>tc :DjangoTestClass<CR>
map <Leader>tm :DjangoTestMethod<CR>
map<Leader>nf :NosetestFile<CR>
map<Leader>nc :NosetestClass<CR>
map<Leader>nm :NosetestMethod<CR>
nnoremap<Leader>ta :RerunLastTests<CR>
map <Leader>fs :CtrlPTag<CR>
map <Leader>fd :CtrlPCurFile<CR>
map <Leader>fb :CtrlPBuffer<CR>
nmap <Leader><Leader> <c-^>
nnoremap <Leader>q :call QuickfixToggle()<CR>
nnoremap <Leader>ed <C-w><C-v><C-l>:e $MYVIMRC<CR>
map <Leader>rf :call RenameFile()<CR>
map <Leader>cf :call CopyFile()<CR>
nnoremap <Leader>ri :call RenewTagsFile()<CR>
inoremap jj <ESC>
inoremap jk <ESC>
nnoremap<Leader>tn :set relativenumber!<CR>
nnoremap <Leader>fr :call VisualFindAndReplace()<CR>
xnoremap <Leader>fr :call VisualFindAndReplaceWithSelection()<CR>
imap <C-e> <C-o>$
imap <C-a> <C-o>0
imap <C-f> <C-o>l
imap <C-b> <C-o>h
nnoremap <Leader>W :%s/\s\+$//<CR>:let @/=''<CR>
nmap <Leader>tm :RunSingleQunitTest<CR>
nmap <Leader>tc :RunSingleQunitModule<CR>
nmap <Leader>ta :!gulp test<CR>
nmap <Leader>j :call InvokeJumpToByType()<CR>
function! InvokeJumpToByType()
let filetype=&ft
if filetype == 'python'
exe ':call jedi#goto_definitions()'
else
:exe "norm \<C-]>"
endif
endfunction
let g:special_blend_run='gulp test'
let g:syntastic_javascript_checkers = ['']
map <Leader>hi :set cursorline! cursorcolumn!<CR>
vmap <Enter> <Plug>(EasyAlign)