-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
496 lines (407 loc) · 14.2 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
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
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
" Neobundle {{{
if has('vim_starting') " {{{
set nocompatible
set runtimepath+=~/.vim/bundle/neobundle.vim/
" Automatically download neobundle if it doesn't exist
if !isdirectory(expand('~/.vim/bundle/neobundle.vim'))
echo "Installing NeoBundle\n"
silent execute '!mkdir -p ~/.vim/bundle'
silent execute '!git clone https://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim'
endif
endif "}}}
filetype off
call neobundle#begin(expand('~/.vim/bundle'))
NeoBundleFetch 'Shougo/neobundle.vim'
NeoBundle 'Shougo/vimproc.vim', {
\ 'build' : {
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'linux' : 'make',
\ 'unix' : 'gmake',
\ },
\ }
NeoBundle 'Shougo/unite.vim'
NeoBundleLazy 'Shougo/unite-outline'
NeoBundleLazy 'Shougo/vimfiler.vim'
NeoBundle 'Shougo/neomru.vim'
NeoBundleLazy 'Shougo/unite-help'
NeoBundleLazy 'ujihisa/unite-colorscheme'
" NeoBundle 'Shougo/echodoc.vim'
" NeoBundle 'Shougo/vimshell.vim'
NeoBundle 'Shougo/neocomplete'
" NeoBundle 'Shougo/neosnippet.vim'
" NeoBundle 'Shougo/neosnippet-snippets'
NeoBundle 'SirVer/ultisnips'
NeoBundle 'honza/vim-snippets'
NeoBundleLazy 'osyo-manga/vim-marching', {
\ 'depends' : ['Shougo/vimproc.vim', 'osyo-manga/vim-reunions'],
\ 'autoload' : {'filetypes' : ['c', 'cpp']}
\}
NeoBundle 'sheerun/vim-polyglot'
NeoBundle 'tpope/vim-surround'
NeoBundle 'tpope/vim-repeat'
NeoBundle 'tpope/vim-unimpaired'
NeoBundle 'tpope/vim-rsi'
NeoBundle 'tpope/vim-dispatch'
NeoBundle 'scrooloose/syntastic'
NeoBundle 'tomtom/tcomment_vim'
NeoBundle 'Raimondi/delimitMate'
" NeoBundle 'Konfekt/FastFold'
NeoBundleLazy 'kien/rainbow_parentheses.vim'
NeoBundle 'itchyny/lightline.vim'
" NeoBundle 'Yggdroot/indentLine'
NeoBundle 'ntpeters/vim-better-whitespace'
NeoBundle 'wellle/tmux-complete.vim'
" NeoBundle 'christoomey/vim-tmux-navigator'
" NeoBundle 'ConradIrwin/vim-bracketed-paste'
" NeoBundle 'duff/vim-scratch'
NeoBundle 'OmniSharp/omnisharp-vim'
NeoBundle 'tomasr/molokai'
call neobundle#end()
filetype plugin indent on
NeoBundleCheck
" }}}
" General Settings {{{
let mapleader = ','
noremap \ ,
set encoding=utf-8
set history=1000
set backspace=indent,eol,start
set autoindent
" set smartindent
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set ignorecase
set smartcase
set number
set hlsearch
set undodir=~/.vim/tmp/undo//
set backupdir=~/.vim/tmp/backup//
set directory=~/.vim/tmp/swp//
set breakindent
set colorcolumn=80
set relativenumber
" Start with folds open
set foldlevelstart=99
set foldmethod=marker
" Save folds
" au BufWinLeave * silent! mkview
" au BufWinEnter * silent! loadview
" From Steve Losh's vimrc
set foldtext=MyFoldText()
function! MyFoldText() " {{{
let line = getline(v:foldstart)
let nucolwidth = &fdc + &number * &numberwidth
let windowwidth = winwidth(0) - nucolwidth - 3
let foldedlinecount = v:foldend - v:foldstart
" expand tabs into spaces
let onetab = strpart(' ', 0, &tabstop)
let line = substitute(line, '\t', onetab, 'g')
let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
endfunction " }}}
set hidden
set wildmenu
set wildignore+=*.o,*.class,*.git,*.svn,*/node_modules/*,*.meta
set title
set showmode
set laststatus=2
" open new splits towards bot right
set splitright
set splitbelow
" Resize splits when the window is resized
au VimResized * :wincmd =
" Disable bell
set vb t_vb=
" }}}
" Mappings {{{
nmap Y y$
cmap w!! %!sudo tee > /dev/null %
noremap H ^
noremap L $
nmap <silent> <Leader>ev :e $MYVIMRC<CR>
nmap <silent> <Leader>sv :so $MYVIMRC<CR>
nmap <silent> <Leader>es :UltiSnipsEdit<CR>
" recenter window on search match
nnoremap n nzzzv
nnoremap N Nzzzv
noremap <silent> <Leader><Space> :noh<cr>
nnoremap <leader>W :set wrap!<cr>
nnoremap <F1> :set paste!<cr>
" convert word to uppercase
inoremap <C-u> <esc>mzgUiw`za
noremap <leader>v <C-w>v
noremap <leader>x <C-w>s
" delete buffer without closing split
nnoremap <leader>d :bp\|bd #<CR>
" resize splits with arrow keys
nmap <Left> <C-W>>
nmap <Right> <C-W><
nmap <Up> <C-W>-
nmap <Down> <C-W>+
nmap <C-l> <C-W>l
nmap <C-h> <C-W>h
nmap <C-k> <C-W>k
nmap <C-j> <C-W>j
nnoremap <Space> za
vnoremap <Space> za
" }}}
" Filetypes {{{
augroup AutoC
autocmd!
autocmd FileType c,cpp setlocal foldmethod=marker foldmarker={,}
augroup END
augroup AutoVimrc
autocmd!
autocmd BufRead .vimrc setlocal foldmethod=marker foldlevel=0
augroup END
" au FileType c,cpp normal zR
" }}}
" Neocomplete settings {{{
let g:acp_enableAtStartup = 0
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#enable_camel_case_completion = 1
let g:neocomplete#enable_underbar_completion = 1
let g:neocomplete#min_syntax_length = 2
let g:neocomplete#sources#syntax#min_keyword_length = 2
let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
let g:neocomplete#enable_auto_close_preview = 1
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
if !exists('g:neocomplete#keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'
" if !exists('g:neocomplete#sources#omni#input_patterns')
" let g:neocomplete#sources#omni#input_patterns = {}
" endif
if !exists('g:neocomplete#force_omni_input_patterns')
let g:neocomplete#force_omni_input_patterns = {}
endif
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
autocmd FileType cs setlocal omnifunc=OmniSharp#Complete
" let g:neocomplete#sources#omni#input_patterns.cs = '.*[^=\);]'
let g:neocomplete#force_omni_input_patterns.cs = '.*[^=\);]'
" Let delimitmate cr expansion work with neocomplete
imap <expr> <CR> pumvisible() ? neocomplete#close_popup() : '<Plug>delimitMateCR'
" set completeopt-=preview
" }}}
" Neosnippet settings {{{
" let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets'
" imap <C-k> <Plug>(neosnippet_expand_or_jump)
" smap <C-k> <Plug>(neosnippet_expand_or_jump)
" xmap <C-k> <Plug>(neosnippet_expand_target)
" imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)"
" \: pumvisible() ? "\<C-n>" : "\<TAB>"
" smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" if has('conceal')
" set conceallevel=2 concealcursor=i
" endif
" }}}
" UltiSnips settings {{{
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
let g:ulti_expand_or_jump_res = 0
function! Ulti_Exp()
call UltiSnips#ExpandSnippetOrJump()
return (g:ulti_expand_or_jump_res > 0) ? "" : pumvisible() ? "\<c-n>" : "\<tab>"
endfunction
inoremap <tab> <c-r>=Ulti_Exp()<cr>
inoremap <s-tab> <c-r>=UltiSnips#JumpBackwards()<cr>
"}}}
" Marching.vim settings {{{
let g:marching_clang_command = '/usr/bin/clang'
let g:marching_clang_command_option="-std=c++1y"
let g:marching_include_paths = filter(
\ split(glob('/usr/include/c++/*'), '\n') +
\ split(glob('/usr/include/*/c++/*'), '\n') +
\ split(glob('/usr/include/*/'), '\n') +
\ split(glob('/usr/local/include/*/'), '\n') +
\ split(glob('/usr/include/c++/4.7/x86_64-linux-gnu/'), '\n'),
\'isdirectory(v:val)')
let g:marching_enable_neocomplete = 1
let g:neocomplete#force_omni_input_patterns.cpp =
\ '[^.[:digit:] *\t]\%(\.\|->\)\w*\|\h\w*::\w*'
set updatetime=200
imap <buffer> <C-x><C-o> <Plug>(marching_start_omni_complete)
imap <buffer> <C-x><C-x><C-o> <Plug>(marching_force_start_omni_complete)
" }}}
" Unite settings {{{
let g:unite_enable_start_insert = 1
let g:unite_enable_short_source_names = 1
let g:unite_source_history_yank_enable = 1
let g:unite_split_rule = "botright"
let g:unite_update_time = 300
let g:unite_source_rec_max_cache_files=5000
let g:unite_source_file_mru_limit = 100
let g:unite_source_session_enable_auto_save = 1
call unite#filters#matcher_default#use(['matcher_fuzzy'])
call unite#filters#sorter_default#use(['sorter_rank'])
" outline doesnt seem to be using default matcher?
call unite#custom#source('outline', 'matchers', ['matcher_fuzzy'])
call unite#custom#source('file_rec,file_rec/async,file_mru,file,buffer,grep',
\ 'ignore_pattern', join([
\ '\.git/',
\ 'tmp/',
\ 'node_modules/',
\ '.pyc',
\ ], '\|'))
if has('win32')
nnoremap <silent> <leader>f :Unite -buffer-name=files file_rec buffer bookmark<CR>
else
nnoremap <silent> <leader>f :Unite -buffer-name=files file_rec/async buffer bookmark<CR>
endif
nnoremap <silent> <leader>y :Unite -buffer-name=yanks history/yank<CR>
nnoremap <silent> <leader>o :Unite -buffer-name=outline -no-split -no-resize -prompt-direction="top" outline<CR>
nnoremap <silent> <leader>m :Unite -buffer-name=mru file_mru<CR>
nnoremap <silent> <leader>b :Unite -buffer-name=buffers buffer<CR>
nnoremap <silent> <leader>c :Unite -buffer-name=commands command<CR>
nnoremap <silent> <leader>G :UniteWithCursorWord -buffer-name=grep -auto-preview grep:.<CR>
nnoremap <silent> <leader>g :Unite -buffer-name=grep -auto-preview grep:.<CR>
nnoremap <silent> <leader>h :Unite -buffer-name=help help<CR>
nnoremap <silent> <leader>C :Unite -buffer-name=colors -auto-preview colorscheme<CR>
augroup UniteAutoCmd
autocmd!
augroup END
function! s:unite_mappings()
nmap <buffer> <ESC> <Plug>(unite_exit)
imap <buffer> <ESC> <Plug>(unite_exit)
imap <buffer> <c-j> <Plug>(unite_insert_leave)
imap <buffer> <c-k> <Plug>(unite_insert_leave)
nmap <buffer> <c-j> <Plug>(unite_loop_cursor_down)
nmap <buffer> <c-k> <Plug>(unite_loop_cursor_up)
nmap <buffer> <C-r> <Plug>(unite_redraw)
imap <buffer> <C-r> <Plug>(unite_redraw)
inoremap <silent><buffer><expr> <C-x> unite#do_action('split')
nnoremap <silent><buffer><expr> <C-x> unite#do_action('split')
inoremap <silent><buffer><expr> <C-v> unite#do_action('vsplit')
nnoremap <silent><buffer><expr> <C-v> unite#do_action('vsplit')
endfunction
autocmd UniteAutoCmd FileType unite call s:unite_mappings()
if executable('ag')
let g:unite_source_grep_command = 'ag'
let g:unite_source_grep_default_opts =
\ '--line-numbers --nocolor --nogroup --hidden --ignore ' .
\ '''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'' ' .
\ '--ignore ''**/*.pyc'''
let g:unite_source_grep_recursive_opt = ''
endif
" }}}
" OmniSharp Settings {{{
set completeopt=longest,menuone,preview
let g:omnicomplete_fetch_full_documentation=1
autocmd BufEnter,TextChanged,InsertLeave *.cs SyntasticCheck
" autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation()
" }}}
" Syntastic settings {{{
let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_cpp_compiler_options = ' -std=c++14'
let g:syntastic_cpp_check_header = 1
" let g:syntasitc_cpp_auto_refresh_includes = 1
let g:syntastic_c_compiler = 'clang'
let g:syntastic_c_check_header = 1
" let g:syntasitc_c_auto_refresh_includes = 1
" let g:syntastic_python_checkers = ['flake8']
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" }}}
" Lightline settings {{{
let g:lightline = {
\ 'active': {
\ 'right': [['syntastic', 'lineinfo'], ['percent'],
\ ['fileformat', 'fileencoding', 'filetype']]
\ },
\ 'component_expand': {
\ 'syntastic': 'SyntasticStatuslineFlag',
\ },
\ 'component_type': {
\ 'syntastic': 'error',
\ }
\ }
let g:syntastic_mode_map = { 'mode': 'passive' }
augroup AutoSyntastic
autocmd!
autocmd BufWritePost *.c,*.cpp call s:syntastic()
augroup END
function! s:syntastic()
SyntasticCheck
call lightline#update()
endfunction
function! MyFilename()
return ('' != MyReadonly() ? MyReadonly() . ' ' : '') .
\ (&ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ '' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != MyModified() ? ' ' . MyModified() : '')
endfunction
" }}}
" Misc plugin settings {{{
nmap <silent> <Leader>r :RainbowParenthesesToggleAll<CR>
"au BufRead * RainbowParenthesesActivate
" Disable meta binds in tpope/vim-rsi
let g:rsi_no_meta = 1
" FastFold settings
let g:fastfold_togglehook = 1
let g:fastfold_mapsuffixes = ['x','X','a','A']
" vimfiller settings
:let g:vimfiler_as_default_exporter = 1
nnoremap <silent> <leader>e :VimFiler<cr>
" vim-better-whitespace settings
let g:better_whitespace_filetypes_blacklist=['unite']
" set cmdheight=2
" let g:echodoc_enable_at_startup = 1
" }}}
" Appearance {{{
set t_Co=256
colorscheme molokai
" Hilight the column of the selected parentheses
func! s:matchparen_cursorcolumn_setup()
augroup matchparen_cursorcolumn
autocmd!
autocmd CursorMoved * if get(w:, "paren_hl_on", 0) | set cursorcolumn | else | set nocursorcolumn | endif
autocmd InsertEnter * set nocursorcolumn
augroup END
endf
if !&cursorcolumn
augroup matchparen_cursorcolumn_setup
autocmd!
autocmd CursorMoved * if exists("#matchparen#CursorMoved") | call <sid>matchparen_cursorcolumn_setup() | endif
\ | autocmd! matchparen_cursorcolumn_setup
augroup END
endif
if !has("gui_running")
" Remove colorscheme bg (to use terminal bg color)
au ColorScheme * hi Normal ctermbg=none
au ColorScheme * hi Folded ctermbg=none ctermfg=59
au ColorScheme * hi CursorLine ctermbg=236
else
au ColorScheme * hi Folded guifg=#7E8E91
" Hide toolbars
set guioptions-=T
set guioptions-=m
set guioptions-=L
set guioptions-=r
set guifont=DejaVu_Sans_Mono:h10
endif
" Change search highlight to green
au ColorScheme * hi Search ctermbg=118
syntax on
" }}}