-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
481 lines (373 loc) · 12.4 KB
/
vimrc
File metadata and controls
481 lines (373 loc) · 12.4 KB
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
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
" install vundle if it doesn't exist
let neobundle_initialized=1
let neobundle_readme=expand('~/.vim/bundle/neobundle.vim/README.md')
if !filereadable(neobundle_readme)
echo "Installing NeoBundle..."
echo ""
silent !mkdir -p ~/.vim/plugin
silent !git clone https://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim
let neobundle_initialized=0
endif
if version >= 720
set colorcolumn=80
set undofile
set undodir=~/.vim/tmp/undo//,~/.tmp//,/tmp//
" save my undo history for this buff along with the file
" could save some headaches
" the // causes fully qualified path to be in the swp name
" max number of undos; default is 1000 on UNIX
"set undolevels=500
" max number of lines to save in the .un file, default is 10000
"set undorelad=500
endif
set nocompatible
filetype off
set rtp+=~/.vim/bundle/neobundle.vim
" Required:
call neobundle#begin(expand('~/.vim/bundle/'))
" Let NeoBundle manage NeoBundle
" Required:
NeoBundleFetch 'Shougo/neobundle.vim'
" My Bundles here:
" Refer to |:NeoBundle-examples|.
" Note: You don't set neobundle setting in .gvimrc!
NeoBundle 'Shougo/vimproc.vim', {
\ 'build' : {
\ 'windows' : 'make -f make_mingw32.mak',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'unix' : 'make -f make_unix.mak',
\ },
\ }
NeoBundle 'Shougo/unite.vim'
NeoBundle 'Shougo/neomru.vim'
NeoBundle 'bling/vim-airline'
NeoBundle 'scrooloose/nerdcommenter.git'
NeoBundle 'majutsushi/tagbar.git'
NeoBundle 'scrooloose/nerdtree.git'
NeoBundle 'Shougo/neocomplete.git'
NeoBundle 'Shougo/vimshell.git'
NeoBundle 'kien/ctrlp.vim.git'
NeoBundle 'kien/rainbow_parentheses.vim.git'
NeoBundle 'tpope/vim-dispatch.git'
NeoBundle 'tpope/vim-fugitive.git'
NeoBundle 'gregsexton/gitv.git'
NeoBundle 'altercation/vim-colors-solarized.git'
NeoBundle 'tomasr/molokai.git'
call neobundle#end()
" Required:
filetype plugin indent on
" If there are uninstalled bundles found on startup,
" this will conveniently prompt you to install them.
NeoBundleCheck
" ================
" GENERAL SETTINGS
" ================
""""""""""""""""""""""
" Colors and Fonts
""""""""""""""""""""""
syntax enable
" old vim?
if version >= 720
set colorcolumn=80
" save my undo history for this buff along with the file
" could save some headaches
" the // causes fully qualified path to be in the swp name
set undofile
set undodir=~/.vim/tmp/undo//,~/.tmp//,/tmp//
" max number of undos; default is 1000 on UNIX
"set undolevels=500
" max number of lines to save in the .un file, default is 10000
"set undorelad=500
endif
"set bg=dark
"let g:Powerline_symbols = 'fancy'
"
" NOTE: SWAP 'symbols' AND 'fonts' lines to enable fancy symbols
" this requires patched fonts, see https://github.com/bling/vim-airline
" for for powerline fonts documentation
"
"let g:airline_powerline_fonts = 1
let g:Powerline_symbols = 'compatible'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#whitespace#enabled = 0
let g:airline_theme="dark"
" Terminal 256 colors
set t_Co=256
set encoding=utf8
try
lang en_US
catch
endtry
set ffs=unix,dos,mac
" show line numbers
set number
" better filename completion in vim command line
set wildmode=list:longest,full
set wildmenu
" underline!
set cursorline
"set cursorcolun
" Search/replace word under cursor
nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
" tell me when i'm in insert or visual mode
set showmode
" show me the command being typed currently
set showcmd
" don't ding at me
set noerrorbells
set novisualbell
" where to put swp files
set directory=~/.vim/tmp/swp//,~/.tmp//,/tmp//
" don't create foo~ files
set nobackup
" to try to get rid of 'hit ENTER to continue' prompts
set shortmess=a
set cmdheight=1
" always give me at least 3 lines before and after cursor
set scrolloff=3
" tab settings
set expandtab
set shiftwidth=4
set tabstop=4
set softtabstop=4
set smarttab
set ttyfast " we have a fast terminal
" remap ; to : in command mode and replace it with , (saves a key press)
"nore ; :
"nore , ;
" avoid that damn "no write since last change" warning when
" switching buffers
set hidden
set encoding=utf-8
set shell=/bin/bash
set lazyredraw " don't redraw when we don't have to
" tell Ctags to recurse up directories
" for the tags file
set tags=tags;/
" use cscope in addition to ctags
source ~/.vim/cscope_maps.vim
" aesthetics
set background=dark
" not all terms are 256 :(
if &t_Co == 256
colorscheme molokai
"let g:solarized_termcolors=256
"colorscheme solarized
endif
" show status line at bottom 0=never, 1=when > 1 window open
" 2=always
set laststatus=2
" with these, if you include capitals in a search it'll do
" the right thing, if you just use lowercase,
" it'll be case insensitive
set ignorecase
set smartcase
" %s/p/r -> %s/p/r/g
set gdefault
" highlight search results as I type
set incsearch
set showmatch
" but allow me to get rid of the highlighting afterwards with ,space
nnoremap <CR> :noh<CR>
set hls!
" line wrapping
"set wrap
"set textwidth=80
set formatoptions=qrtn1
" tell me when i'm running on too long
"highlight OverLength ctermbg=red
"ctermfg=white
"match OverLength /\%80v.\+/
"set up code folding
set nofoldenable "don't fold by default
set foldmethod=indent " fold on indentations
set foldnestmax=10 "only fold up to 10 levels
set foldlevel=1 " only show me first fold level
nnoremap j gj
nnoremap k gk
nnoremap <right> :bn<CR>
nnoremap <left> :bp<CR>
inoremap <right> <ESC>:bn<CR>
inoremap <left> <ESC>:bp<CR>
" save buffers when we move away from vim
"au FocusLost * :wa
" allow bs to erase previously entered chars, autoindent, \n's etc
set backspace=indent,eol,start
" When opening a new line and no filetype-specific indenting is enabled, keep
" the same indent as the line you're currently on. Useful for READMEs, etc.
set autoindent
"set smartindent
" Tell vim to remember certain things when we exit
" '10 : marks will be remembered for up to 10 previously edited files
" "100 : will save up to 100 lines for each register
" :20 : up to 20 lines of command-line history will be remembered
" % : saves and restores the buffer list
" n... : where to save the viminfo files
set viminfo='10,\"100,:20,%,n~/.viminfo
" do the restore
function! ResCur()
if line("'\"") <= line("$")
normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
au BufWinEnter * call ResCur()
augroup END
" === KEY MAPPINGS ===
" change <leader> key. defaults is '\', hard to reach
let mapleader=","
" quick window split with ,s[vh] (vertical, horizontal)
nnoremap <leader>sv <C-w>v<C-w>l
nnoremap <leader>sh <C-w>s<C-w>j
" move around splits faster
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" move around tabs faster
nnoremap <leader>tn :tabnext<CR>
nnoremap <leader>tp :tabprev<CR>
nnoremap <leader>to :tabnew<CR>
nnoremap <leader>tc :tabclose<CR>
nnoremap <leader>t1 :tabn 1<CR>
nnoremap <leader>t2 :tabn 2<CR>
nnoremap <leader>t3 :tabn 3<CR>
nnoremap <leader>t4 :tabn 4<CR>
" key mapping to toggle spell checker (apparently this will do the right thing in
" source files. Use zg to whitelist a word
nnoremap <leader>sp :setlocal spell!<CR>
" let me edit my vimrc quickly with ,ev
nnoremap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<CR>
" autoreload vimrc when it's edited
autocmd! bufwritepost vimrc source ~/.vim/vimrc
" quickly reload vimrc
nnoremap <leader>rv :source $MYVIMRC<CR>
" quicker than reaching for escape
inoremap jj <ESC>
" quick save
nnoremap <leader>w :w<CR>
" sudo save
cnoremap w!! w !sudo tee % > /dev/null
set title
" Insert a lambda: mostly for scheme and haskell
"imap <C-Bslash> λ
" Use better syntax highlighting for ASM
"let g:asmsyntax="asmx86"
" Haskell Mode
"let g:haddock_browser = "/usr/bin/google-chrome"
"au Bufenter *.hs compiler ghc
" =======================
" PLUGIN-SPECIFIC OPTIONS
" =======================
" ++++++++++ TagBar ++++++++++++
"make TagBar a little easier: press ',1' in command mode to bring it up
let g:tagbar_usearrows = 1
nnoremap <leader>1 :TagbarToggle<CR>
" Uncomment this line to open Tagbar on startup for code files
" au BufRead *.[ch],*.cpp,*.java,*.js,*.py,*.pl TagbarOpen
" !++++++++++ TagBar ++++++++++++!
" ++++++++ NERDTree ++++++++++
nnoremap <leader>2 :NERDTreeToggle<CR>
" !++++++++ NERDTree ++++++++++!
" +++++++ Rainbow Parens ++++++++++
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
" !+++++++ Rainbow Parens ++++++++++!
" +++++++++ NEOCOMPLETE +++++++++
"Note: This option must set it in .vimrc(_vimrc). NOT IN .gvimrc(_gvimrc)!
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 3
let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
" Define dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
" Define keyword.
if !exists('g:neocomplete#keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'
" Plugin key-mappings.
inoremap <expr><C-g> neocomplete#undo_completion()
inoremap <expr><C-l> neocomplete#complete_common_string()
" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return neocomplete#close_popup() . "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplete#close_popup()
inoremap <expr><C-e> neocomplete#cancel_popup()
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
"let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
"let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
" !+++++++++ NEOCOMPLETE +++++++++!
" +++++++++ CtrlP ++++++++++++++++++
let g:ctrlp_cmd = "CtrlPBuffer"
" Setup some default ignores
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.(git|hg|svn)|\_site)$',
\ 'file': '\v\.(iso|bin|o|ko|d|exe|so|dll|class|png|jpg|jpeg)$',
\}
" 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'
" no file limit
let g:ctrlp_max_files = 0
" Easy bindings for its various modes
nnoremap <leader>pb :CtrlPBuffer<cr>
nnoremap <leader>pm :CtrlPMixed<cr>
nnoremap <leader>pu :CtrlPMRU<cr>
" !+++++++++ CtrlP ++++++++++++++++++!
" Use dispatch to run tig if we have it
if exists(":Start")
command! Tig :Start tig<CR>
command! Tigit :Start tig %<CR>
else
command! Tig execute "!tig"<CR>
command! Tigit execute "!tig %"<CR>
endif
" +++++++++ VimShell ++++++++++++++++++
nnoremap <leader>sh :new \| VimShell zsh<CR>
nnoremap <leader>sv :vnew \| VimShell zsh<CR>
nnoremap <leader>st :VimShellTab zsh<CR>
" !+++++++++ VimShell ++++++++++++++++++!
" ++++++++++ Dispatch ++++++++++++++++
nnoremap <leader>mk :make isoimage -j8<CR>
nnoremap <leader>scp :!make isoimage && scp nautilus.iso root@v-test-r415-8.cs.northwestern.edu:/root/kyle/<CR>
function! Can_use_dispatch()
if exists(":Make")
nnoremap <leader>mk :Make isoimage -j8<CR>
nnoremap <leader>scp :Dispatch make isoimage && scp nautilus.iso root@v-test-r415-8.cs.northwestern.edu:/root/kyle/<CR>
endif
endfunction
autocmd VimEnter * call Can_use_dispatch()
" !++++++++++ Dispatch ++++++++++++++++!