-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
392 lines (330 loc) · 9.78 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
set nocompatible " be iMproved, required
set encoding=utf-8
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" core plugins
" Plugin 'flazz/vim-colorschemes'
Plugin 'kien/ctrlp.vim'
" vim main plugins
Plugin 'sjl/gundo.vim'
" Plugin 'bling/vim-airline'
" Plugin 'vim-airline/vim-airline-themes'
Plugin 'jlanzarotta/bufexplorer'
Plugin 'scrooloose/syntastic.git'
Plugin 'vim-scripts/tComment'
Plugin 'tpope/vim-surround'
Plugin 'mileszs/ack.vim'
Plugin 'rking/ag.vim'
Plugin 'edsono/vim-matchit'
Plugin 'tpope/vim-fugitive'
Plugin 'henrik/vim-indexed-search'
Plugin 'tpope/vim-abolish'
Plugin 'tpope/vim-repeat'
Plugin 'jiangmiao/auto-pairs'
Plugin 'xolox/vim-session'
Plugin 'xolox/vim-misc'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'godlygeek/tabular'
Plugin 'airblade/vim-gitgutter'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'rhysd/clever-f.vim'
" Plugin 'yegappan/grep'
" togglable panels
Plugin 'scrooloose/nerdtree'
Plugin 'tpope/vim-vinegar'
" Plugin 'vim-scripts/taglist.vim'
Plugin 'majutsushi/tagbar'
" language vundles
Plugin 'plasticboy/vim-markdown'
" databases
Plugin 'vim-scripts/SQLUtilities'
Plugin 'NagatoPain/AutoSQLUpperCase.vim'
" autocomplete
Plugin 'Valloric/YouCompleteMe'
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
" snippets
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
" TaskWarrior
Plugin 'farseer90718/vim-taskwarrior'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" Put your non-Plugin stuff after this line
""""""""""""""""""""""""""""""""
"
" SETTINGS & KEYBINDINGS
"
""""""""""""""""""""""""""""""""
set expandtab
set smarttab
set shiftwidth=2
set softtabstop=2
set tabstop=2
set autoindent
set ruler
set hidden
set ignorecase
set smartcase
set showmatch
set incsearch
set hls
set relativenumber
set ls=2
set cursorline
set nowrap
set backspace=indent,eol,start
set shell=/bin/bash
set completeopt -=preview
set textwidth=80
set wildmenu
set ttyfast
set noshowmode
set cmdheight=1
" set autoread
" backup/persistance settings
set undodir=~/.vim/tmp/undo//
set backupdir=~/.vim/tmp/backup//
set directory=~/.vim/tmp/swap//
set backupskip=/tmp/*,/private/tmp/*"
set backup
set writebackup
set noswapfile
" persist (g)undo tree between sessions
set undofile
set history=100
set undolevels=100
" set <leader>
let mapleader=","
" show trailing whitespaces
set list
set listchars=tab:▸\ ,trail:¬,nbsp:.,extends:❯,precedes:❮
" syntax highlighting
syntax on
" set background=dark
" colorscheme solarized
" session management
let g:session_directory = "~/.vim/session"
let g:session_autoload = "no"
let g:session_autosave = "no"
let g:session_command_aliases = 1
nnoremap <leader>so :OpenSession
nnoremap <leader>ss :SaveSession
nnoremap <leader>sd :DeleteSession<CR>
nnoremap <leader>sc :CloseSession<CR>
" togglables without FN keys
nnoremap <leader>1 :GundoToggle<CR>
set pastetoggle=<leader>2
nnoremap <leader>3 :TlistToggle<CR>
nnoremap <leader>4 :TagbarToggle<CR>
nnoremap <leader>5 :NERDTreeToggle<CR>
" visual reselect of just pasted
nnoremap gp `[v`]
"make enter break and do newlines
nnoremap <CR> O<Esc>j
nnoremap <leader>j i<CR><Esc>==
"make space in normal mode add space
nnoremap <Space> i<Space><Esc>l
" better scrolling
nnoremap <C-j> <C-d>
nnoremap <C-k> <C-u>
" consistent menu navigation
inoremap <C-j> <C-n>
inoremap <C-k> <C-p>
" intellij style autocomplete shortcut
inoremap <C-@> <C-x><C-o>
inoremap <C-Space> <C-x><C-o>
" ctrlP config
" Below settings are taken from
" https://joshldavis.com/2014/04/05/vim-tab-madness-buffers-vs-tabs/
" Setup some default ignores
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.(git|hg|svn)|\_site)$',
\ 'file': '\v\.(exe|so|dll|class|png|jpg|jpeg)$',
\}
" Use Ctrl+p to run CtrlP
let g:ctrlp_map = "<c-p>"
" Use the nearest .git directory as the cwd
" This makes a lot of sense if you are working on a project that is in version
" control. It also supports works with .svn, .hg, .bzr.
let g:ctrlp_working_path_mode = 'r'
" Use a leader instead of the actual named binding
nmap <leader>p :CtrlP<cr>
" Easy bindings for its various modes
nmap <leader>bb :CtrlPBuffer<cr>
nmap <leader>bm :CtrlPMixed<cr>
nmap <leader>b :CtrlPMRU<cr>
" ctrlP config end
" easy motion rebinded
nmap <leader>f <Plug>(easymotion-f2)
nmap <leader>F <Plug>(easymotion-F2)
" open vimrc
nnoremap <leader>v :e ~/.vim/.vimrc<CR>
nnoremap <leader>V :tabnew ~/.vim/.vimrc<CR>
" reload all open buffers
nnoremap <leader>Ra :tabdo exec "windo e!"
"map next-previous jumps
nnoremap <leader>m <C-o>
nnoremap <leader>. <C-i>
" Keep search matches in the middle of the window.
nnoremap n nzzzv
nnoremap N Nzzzv
" Use sane regexes
nnoremap <leader>/ /\v
vnoremap <leader>/ /\v
" Use :Subvert search
nnoremap <leader>// :S /
vnoremap <leader>// :S /
" Use regular replace
nnoremap <leader>s :%s /
vnoremap <leader>s :%s /
" Use :Subvert replace
nnoremap <leader>S :%S /
vnoremap <leader>S :%S /
" clever-f prompt
let g:clever_f_show_prompt = 1
let g:clever_f_across_no_line = 1
" powerline
let g:powerline_pycmd = "py3"
" airline
"""if !exists("g:airline_symbols")
""" let g:airline_symbols = {}
"""endif
"""let g:airline_theme="zenburn"
"""let g:airline_powerline_fonts=1
"""let g:airline#extensions#branch#empty_message = "no .git"
"""let g:airline#extensions#whitespace#enabled = 0
"""let g:airline#extensions#syntastic#enabled = 1
"""let g:airline#extensions#tabline#enabled = 1
"""let g:airline#extensions#tabline#tab_nr_type = 1 " tab number
"""let g:airline#extensions#tabline#fnamecollapse = 1 " /a/m/model.rb
"""let g:airline#extensions#hunks#non_zero_only = 1 " git gutter
" YouCompleteMe
let g:ycm_filetype_blacklist = {}
let g:ycm_key_list_select_completion = []
let g:ycm_key_list_previous_completion = []
let g:ycm_key_invoke_completion = "<C-j>"
let g:ycm_collect_identifiers_from_tags_files = 1
if executable("ag")
let g:ackprg = "ag --nogroup --column"
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
endif
" reload ctags
nnoremap <leader>C :!ctags -R --exclude=.git --exclude=log --exclude=tmp *<CR><CR>
" git and ack stuff
let g:gitgutter_enabled = 1
let g:gitgutter_realtime = 0
let g:gitgutter_eager = 0
nnoremap <leader>G mG:Git!
nnoremap <leader>g :Git
nnoremap <leader>A :!ag
nnoremap <leader>a :Ag!
" General file runners for various languages
function! LangRunner()
if(&ft=="python")
nnoremap <leader>r :!python %<cr>
elseif(&ft=="ruby")
nnoremap <leader>r :!ruby %<cr>
elseif(&ft=="php")
nnoremap <leader>r :!php %<cr>
endif
endfunction
au BufEnter * call LangRunner()
" TaskWarrior
let g:task_rc_override = 'rc.defaultwidth=0 rc.defaultheight=0'
""""""""""""""""""""""""""""""""
"
" COOL HACKS
"
""""""""""""""""""""""""""""""""
" Make sure Vim returns to the same line when you reopen a file.
augroup line_return
au!
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute 'normal! g`"zvzz' |
\ endif
augroup END
" Visual Mode */# from Scrooloose
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>
" Text Highlighter = <leader>h[1-4]
function! HiInterestingWord(n)
" Save our location.
normal! mz
" Yank the current word into the z register.
normal! "zyiw
" Calculate an arbitrary match ID. Hopefully nothing else is using it.
let mid = 86750 + a:n
" Clear existing matches, but don't worry if they don't exist.
silent! call matchdelete(mid)
" Construct a literal pattern that has to match at boundaries.
let pat = '\V\<' . escape(@z, '\') . '\>'
" Actually match the words.
call matchadd("InterestingWord" . a:n, pat, 1, mid)
" Move back to our original location.
normal! `z
endfunction
nnoremap <leader>hh :call clearmatches()<CR>:noh<CR>
nnoremap <silent> <leader>h1 :call HiInterestingWord(1)<cr>
nnoremap <silent> <leader>h2 :call HiInterestingWord(2)<cr>
nnoremap <silent> <leader>h3 :call HiInterestingWord(3)<cr>
nnoremap <silent> <leader>h4 :call HiInterestingWord(4)<cr>
nnoremap <silent> <leader>h5 :call HiInterestingWord(5)<cr>
nnoremap <silent> <leader>h6 :call HiInterestingWord(6)<cr>
hi def InterestingWord1 guifg=#000000 ctermfg=16 guibg=#ffa724 ctermbg=214
hi def InterestingWord2 guifg=#000000 ctermfg=16 guibg=#aeee00 ctermbg=154
hi def InterestingWord3 guifg=#000000 ctermfg=16 guibg=#8cffba ctermbg=121
hi def InterestingWord4 guifg=#000000 ctermfg=16 guibg=#b88853 ctermbg=137
hi def InterestingWord5 guifg=#000000 ctermfg=16 guibg=#ff9eb8 ctermbg=211
hi def InterestingWord6 guifg=#000000 ctermfg=16 guibg=#ff2c4b ctermbg=195
highlight search ctermfg=white ctermbg=3423513
" better retab
fu! Retab()
:retab
:%s/\s\+$//
endfunction
""""""""""""""""""""""""""""""""
"
" BUG WORKAROUNDS
"
""""""""""""""""""""""""""""""""
" realign buffers when iterm goes fullscreen
augroup FixProportionsOnResize
au!
au VimResized * exe "normal! \<c-w>="
augroup END
" vim mode-switch lag fix
if ! has("gui_running")
set ttimeoutlen=10
augroup FastEscape
autocmd!
au InsertEnter * set timeoutlen=0
au InsertLeave * set timeoutlen=1000
augroup END
endif
" macos vs linux clipboard
if has("mac")
set clipboard+=unnamed
else
set clipboard=unnamedplus
endif
" make C-a, C-x work properly
set nrformats=
" potential lag fix
let g:matchparen_insert_timeout=1
" fix bufexplorer bug with hidden
let g:bufExplorerFindActive=0