-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
491 lines (441 loc) · 12.8 KB
/
vimrc
File metadata and controls
491 lines (441 loc) · 12.8 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
481
482
483
484
485
486
487
488
489
490
491
" vim: fdm=marker
" my custom vimrc - should work for all systems
" {{{ vundle
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
Plugin 'gmarik/vundle'
" }}}
" {{{ vundle packages
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-dispatch'
Plugin 'tpope/vim-speeddating'
Plugin 'szw/vim-g'
Bundle 'Valloric/YouCompleteMe'
Bundle 'bling/vim-airline'
Plugin 'Mizuchi/STL-Syntax'
Bundle 'josephcc/vim-lfg-highlight'
Bundle 'a.vim'
Bundle 'taglist.vim'
Bundle 'majutsushi/tagbar'
Bundle 'altercation/vim-colors-solarized'
Bundle 'chrisbra/csv.vim'
Plugin 'bronson/vim-trailing-whitespace'
Plugin 'airblade/vim-gitgutter'
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
Plugin 'ggreer/the_silver_searcher'
Plugin 'rking/ag.vim'
Plugin 'scrooloose/syntastic'
" }}}
let g:agprg="/home/petran/.vim/bundle/the_silver_searcher/ag"
" something in taglist causes eclim to start for non-java, either
" of the lines below fixes that
let g:EclimTaglistEnabled = 0
" let g:taglisttoo_disabled = 1
filetype plugin indent on
" {{{ remove arrow keys
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
" }}}
" {{{ OS recognition
if has("win32") || has("win16")
let osys="mswin"
behave mswin
elseif has("unix")
let osys="Linux"
elseif has("macunix")
let osys="Darwin"
else
" for unknown reasons uname -s appends a newline at the end of the
" string. therefore, the two previous cases are necessary
let osys=system('uname -s')
endif
" }}}
" terminal
if (&term =~ "xterm") && (&termencoding == "")
set termencoding=utf-8
endif
" {{{ jump to last edited position
" see :help last-position-jump
if has("autocmd")
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g'\"" |
\ exe "normal zz" |
\ endif
endif
" }}}
" hybrid line numbering
" only works in > 7.4
if v:version >= 704
set relativenumber
set number
endif
if &term =~ "xterm"
" xterm titles
if has('title')
set title
endif
if exists('&t_SI')
let &t_SI = "\<Esc>]12;lightgoldenrod\x7"
let &t_SI = "\<Esc>]12;grey80\x7"
endif
endif
" {{{ general settings
set nocompatible
set viminfo='1000,f1,:1000,/1000
set history=500
set backspace=indent,eol,start
set nobackup
set showcmd
set showmatch
set hlsearch
set incsearch
set maxmempattern=2000000
" auto cd into the directory of the file
set autochdir
" no error noises
set noerrorbells
set visualbell t_vb=
" scrolling
set scrolloff=3
set sidescrolloff=2
if has("autocmd")
autocmd GUIEnter * set visualbell t_vb=
endif
" show full tags for auto completion
set showfulltag
set lazyredraw
set whichwrap+=<,>,[,]
" tab completion
set wildmenu
" ignore these for completion
set wildignore+=*.o,*~,*.lo,*.exe,*.com,*.pdf,*.ps,*.dvi
set suffixes+=.in,.a
if has("syntax")
syntax on
endif
set virtualedit=block,onemore
" Toolbar & scrollbars off
if has('gui')
set guioptions-=T
set guioptions-=r
set guioptions-=R
endif
" indenting
set shiftwidth=4
set autoindent
set smartindent
" tab to ws conversion
set softtabstop=4
set expandtab
set tw=120
" }}}
" case sensitivity for cpp files
if has("autocmd")
autocmd BufEnter *
\ if &filetype == "cpp" |
\ set noignorecase noinfercase |
\ else |
\ set ignorecase infercase |
\ endif
else
set ignorecase
set infercase
endif
" highlight column 80 for cpp files
" set file subtype to doxygen
if has("autocmd")
autocmd BufRead,BufNewFile *.h,*.cpp set colorcolumn=80
autocmd BufRead,BufNewFile *.h,*.cpp set filetype=cpp.doxygen
autocmd BufRead,BufNewFile *.h,*.cpp nnoremap <F5> :make<CR>
endif
" {{{ fonts
if has("win32")
" set guifont=Lucida\ Console
set guifont=Anonymous_Pro:h11
"set guifont=Monaco:h10
else
set guifont=Source\ Code\ Pro\ for\ Powerline\ Medium\ 12
"set guifont=DejaVu\ Sans\ Mono\ 12
endif
" }}}
" {{{ colorscheme
if has("eval")
fun! LoadColorScheme(schemes)
let l:schemes = a:schemes . ":"
while l:schemes != ""
let l:scheme = strpart(l:schemes, 0, stridx(l:schemes, ":"))
let l:schemes = strpart(l:schemes, stridx(l:schemes, ":") + 1)
try
exec "colorscheme" l:scheme
break
catch
endtry
endwhile
endfun
if has('gui')
call LoadColorScheme("solarized:inkpot:night:rainbow_night:darkblue:elflord")
else
if has("autocmd")
autocmd VimEnter *
\ if &t_Co == 88 || &t_Co == 256 |
\ call LoadColorScheme("inkpot:darkblue:elflord") |
\ else |
\ call LoadColorScheme("darkblue:elflord") |
\ endif
else
if &t_Co == 88 || &t_Co == 256
call LoadColorScheme("inkpot:darkblue:elflord")
else
call LoadColorScheme("darkblue:elflord")
endif
endif
endif
endif
" }}}
" folds
if has("folding")
set foldenable
set foldmethod=indent
set foldlevelstart=99
endif
set popt+=syntax:y
" filetype
if has("eval")
filetype on
filetype plugin on
filetype indent on
endif
" secure modelines
if filereadable(expand("$VIM/vimfiles/plugin/securemodelines.vim"))
set nomodeline
let g:secure_modelines_verbose = 0
let g:secure_modelines_modelines = 15
endif
" ultisnips ===========================================================
let g:UltiSnipsExpandTrigger="<c-tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
let g:UltiSnipsEditSplit="vertical"
" tagbar.vim
" TODO add conditional
nmap <F8> :TagbarToggle<CR>
" title bar ===========================================================
if has('title') && (has('gui_running') || &title)
set titlestring=
" file name
set titlestring+=%f
" flags
set titlestring+=%h%m%r%w
" program name
set titlestring+=\ -\ %{v:progname}
" working dir
set titlestring+=\ -\ %{substitute(getcwd(),\ $HOME,\ '~',\ '')}
endif
if v:version >= 700
try
setlocal numberwidth=3
catch
endtry
endif
if has("gui_running") && v:version >= 700
set cursorline
end
" include $HOME in cdpath
if has("file_in_path")
let &cdpath=",".expand("$HOME").','.expand("$HOME").'/src'
endif
" for include paths
set path+=src/
let &inc.=' ["<]'
" show tabs and trailing whitespace
if (&termencoding == "utf-8") || has("gui_running")
if v:version >= 700
if has("gui_running")
set list listchars=tab:»·,trail:·,extends:¿,nbsp:¿
else
" xterm + terminus hates these
set list listchars=tab:»·,trail:·,extends:>,nbsp:_
endif
else
set list listchars=tab:»·,trail:·,extends:¿
endif
else
if v:version >= 700
set list listchars=tab:>-,trail:.,extends:>,nbsp:_
else
set list listchars=tab:>-,trail:.,extends:>
endif
endif
set fillchars=fold:-
" winmanager.vim settings
if filereadable(expand("$VIM/vimfiles/plugin/winmanager.vim"))
let g:winManagerWindowLayout = 'FileExplorer,TagsExplorer'
endif
""""""""""""""""""""""""""""""""""""""""""""
" spelling for latex files
"
""""""""""""""""""""""""""""""""""""""""""""
if has("autocmd")
autocmd BufEnter *
\ if &filetype == "latex" |
\ set spell |
\ else |
\ set nospell |
\ endif
endif
" {{{ vim-latex settings
if filereadable(expand("$VIM/vimfiles/ftplugin/tex_latexSuite.vim")) || filereadable(expand("$VIM/addons/ftplugin/tex_latexSuite.vim"))
let g:Tex_DefaultTargetFormat = 'pdf'
" auto reload logfiles for vim-latex
if has("autocmd")
autocmd BufRead *.log set ar
endif
" various IMAPS for vim-latex
if has("autocmd")
" beamer frame
autocmd BufNewFile,BufRead *.tex call IMAP('BFA', "\\begin{frame}{<++>}\<CR><++>\<CR>\\end{frame}<++>", 'tex')
" beamer frame with automatic stops, idk if this works
autocmd BufNewFile,BufRead *.tex call IMAP('BFS', "\\begin{frame}[<+->]{<++>}\<CR><++>\<CR>\\end{frame}<++>", 'tex')
" block
autocmd BufNewFile,BufRead *.tex call IMAP('BBA', "\\begin{block}{<++>}\<CR><++>\<CR>\\end{block}<++>", 'tex')
" covington example
autocmd BufNewFile,BufRead *.tex call IMAP('EXE', "\\begin{example}\<CR><++>\<CR>\\end{example}<++>", 'tex')
" covington examples
autocmd BufNewFile,BufRead *.tex call IMAP('EXS', "\\begin{examples}\<CR>\\item <++>\<CR>\\end{examples}<++>", 'tex')
endif
" don't check spelling in comments
let g:tex_comment_nospell = 1
if osys == "Darwin"
let g:Tex_ViewRule_ps = 'Preview'
let g:Tex_ViewRule_pdf = 'Skim'
let g:Tex_ViewRule_dvi = 'TeXniscope'
" g:Tex_TreatMacViewerAsUNIX
" let g:Tex_CompileRule_pdf = 'vimlatex.sh pdflatex -interaction=nonstopmode $*'
" let g:Tex_CompileRule_ps = 'vimlatex.sh dvips -Ppdf -o $*.ps $*.dvi'
" let g:Tex_CompileRule_dvi = 'vimlatex.sh latex -interaction=nonstopmode $*'
elseif osys == "Linux"
" this is needed to prevent vim from setting the filetype to plaintex
let g:tex_flavor='latex'
if filereadable("/usr/bin/okular")
" if has("gui_kde")
let g:Tex_ViewRule_ps = 'okular'
let g:Tex_ViewRule_pdf = 'okular'
let g:Tex_ViewRule_dvi = 'okular'
" elseif has("gui_gtk")
elseif filereadable("/usr/bin/evince")
let g:Tex_ViewRule_ps = 'evince'
let g:Tex_ViewRule_pdf = 'evince'
endif
set grepprg=grep\ -nH\ $*
elseif osys == "mswin"
" sumatraPDF does auto reload while acroread just locks
" the file so it cannot be changed
let g:Tex_ViewRule_pdf = 'SumatraPDF'
" TODO ps/dvi?
set shellslash
" TODO
endif
endif
" }}}
" {{{ vim-airline
" always show status bar
set laststatus=2
" show buffers in airline
let g:airline#extensions#tabline#enabled = 1
" powerline fonts
let g:airline_powerline_fonts = 1
" powerline symbols
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"
" }}}
" completion
set dictionary=/usr/share/dict/words
" turn off existing hlsearch
if has("autocmd")
autocmd BufEnter * nohls
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" this stuff is unix specific, atm
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" docx converter
" TODO doesn't work
if has("autocmd")
if filereadable("/usr/local/bin/docx2txt.pl")
autocmd BufReadPre *.docx set ro
autocmd BufReadPost *.docx %!docx2txt.pl
endif
endif
" assume out of source build if CMakeLists.txt is
" present in the current directory
" TODO needs to descend farther than just one directory
"if has("autocmd")
"autocmd BufNewFile,BufRead *
"\ if filereadable("./CMakeLists.txt") |
"\ let builddir=findfile('build', ';') |
"\ let buildcmd='make -C ' . builddir |
"\ let &makeprg=buildcmd |
"\ endif
"endif
" OOS builds for git projects
fun! g:BuildOOS()
let toplevelpath = FindTopLevelProjectDir()
let builddir = toplevelpath . "/build/"
:execute 'make -C ' . builddir
endfun
fun! FindTopLevelProjectDir()
let isittopdir = finddir('.git')
if isittopdir ==? ".git"
return getcwd()
endif
let gitdir = finddir('.git', ';')
let gitdirsplit = split(gitdir, '/')
let toplevelpath = '/' . join(gitdirsplit[:-3], '/')
return toplevelpath
endfun
nnoremap <F4> :call g:BuildOOS()<CR>
" ctags related stuff
" look up til root for tags files
set tags=./tags;/
" open definition in new tab
map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
" open definition in vert split
map <C-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
" cscope
set csto=0
set cst
set nocsverb
if filereadable("cscope.out")
cs add cscope.out
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
" buffer mappings because it annoys me to have to type <ESC>:bp<CR>
" \l list buffers
" \b \f \g back/forward/last
" \1 \2 \3 buffer 1/2/3
" TODO \b takes way more time than \f, idk why
nnoremap <Leader>l :ls<CR>
nnoremap <Leader>b :bp<CR>
nnoremap <Leader>f :bn<CR>
nnoremap <Leader>g :e#<CR>
nnoremap <Leader>1 :1b<CR>
nnoremap <Leader>2 :2b<CR>
nnoremap <Leader>3 :3b<CR>
nnoremap <Leader>4 :4b<CR>
nnoremap <Leader>5 :5b<CR>
nnoremap <Leader>6 :6b<CR>
nnoremap <Leader>7 :7b<CR>
nnoremap <Leader>8 :8b<CR>
nnoremap <Leader>9 :9b<CR>
nnoremap <Leader>0 :10b<CR>
"-----------------------------------------------------------------------
" vim: set shiftwidth=4 softtabstop=4 expandtab tw=120 :