This repository has been archived by the owner on Feb 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
313 lines (273 loc) · 8.13 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
scriptencoding utf-8
call plug#begin()
" github
Plug 'tpope/vim-sensible'
Plug 'joshdick/onedark.vim'
Plug 'ervandew/supertab'
Plug 'godlygeek/tabular'
Plug 'rking/ag.vim'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'scrooloose/nerdtree'
Plug 'kien/ctrlp.vim'
Plug 'sjl/gundo.vim'
Plug 'jlanzarotta/bufexplorer'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'bling/vim-airline'
" snipmate
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'tomtom/tlib_vim'
Plug 'garbas/vim-snipmate'
" vim-scripts
Plug 'vim-scripts/bufkill.vim'
call plug#end()
" {{{ useful options
set cinoptions=:0,l1,g0,t0,(0
set confirm
set dict+=/usr/share/dict/words
set expandtab
set gdefault
set hidden
set hlsearch
set ignorecase smartcase
set list
set modeline
set nocursorline
set nofoldenable
set nowrap
set number
set pastetoggle=<Leader>+
set path+=.;,./**
set scrolloff=5
set shiftwidth=4 tabstop=4
set showbreak=…
set showcmd
set showmatch
set spelllang=en_us
set switchbuf=useopen,usetab
set timeoutlen=500
set virtualedit=block
set visualbell
set whichwrap+=[,]
set wildignore=*.swp,*.bak,*.pyc,*.class,*.o,*.obj
set wildmode=list:longest
set autochdir
" VIM 7.3 specific options
if version >= 703
if !has('nvim')
set cryptmethod=blowfish
endif
" persistent undo
set undodir=~/.vim/undodir
set undofile
endif
au BufRead,BufNewFile * let b:args=''
let python_highlight_all=1
" airline
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
" gundo
let g:gundo_right = 1
" taglist
let Tlist_Use_Right_Window = 1
let Tlist_WinWidth = 50
" snipmate
let g:snips_author = 'Dror Levin'
" netrw
let g:netrw_browse_split = 3
let g:netrw_list_hide = '\(^\|\s\s\)\zs\.\S\+'
" BufExplorer
let g:bufExplorerSortBy = 'name'
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
let OmniCpp_MayCompleteDot = 1 " autocomplete after .
let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
let OmniCpp_MayCompleteScope = 0 " autocomplete after ::
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
" gnupg
let g:GPGPreferSign = 1
" }}}
" {{{ functions
func! GentooCompare(i1, i2)
let s1 = substitute(a:i1, '^[-+~]', '', '')
let s2 = substitute(a:i2, '^[-+~]', '', '')
return l:s1 == l:s2 ? 0 : l:s1 > l:s2 ? 1 : -1
endfunc
let b:updatetime_users = 0
au BufRead,BufNewFile * let b:updatetime_users = 0
func! Taglist_Toggle()
TlistToggle
if exists('#taglist')
au! taglist
augroup! taglist
let b:updatetime_users -= 1
if b:updatetime_users <= 0
setl updatetime=4000
endif
else
let b:updatetime_users += 1
setl updatetime=500
augroup taglist
au!
au CursorHold * TlistHighlightTag
augroup end
endif
endfunc
nnoremap <silent> <Leader>/ :if Auto_Highlight_Toggle() \| setl hls \| endif<CR>
func! Auto_Highlight_Toggle()
let @/=''
if exists('#auto_highlight')
au! auto_highlight
augroup! auto_highlight
let b:updatetime_users -= 1
if b:updatetime_users <= 0
setl updatetime=4000
endif
return 0
else
let b:updatetime_users += 1
setl updatetime=500
augroup auto_highlight
au!
au CursorHold * let @/='\<'.expand('<cword>').'\>'
augroup end
return 1
endif
endfunc
command! DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis
command! Q q
" }}}
" {{{ mappings
inoremap <M-Left> <C-o>b
inoremap <M-Right> <C-o>w
inoremap <M-C-Left> <C-o>B
inoremap <M-C-Right> <C-o>W
inoremap <C-Del> <C-o>dw
inoremap <C-BS> <Esc>dbxa
" move when soft wrapping and horizontally
nnoremap <C-h> zH
nnoremap <C-j> gj
nnoremap <C-k> gk
nnoremap <C-l> zL
vnoremap <C-h> zH
vnoremap <C-j> gj
vnoremap <C-k> gk
vnoremap <C-l> zL
" easily move through windows
nnoremap <M-Right> <C-w>l
nnoremap <M-Left> <C-w>h
nnoremap <M-Up> <C-w>k
nnoremap <M-Down> <C-w>j
" edit in working directory
noremap <Leader>ew :e <C-r>=substitute(expand("%:p:h"), ' ', '\\\ ', 'g')<CR>/
noremap <Leader>es :sp <C-r>=substitute(expand("%:p:h"), ' ', '\\\ ', 'g')<CR>/
noremap <Leader>ev :vsp <C-r>=substitute(expand("%:p:h"), ' ', '\\\ ', 'g')<CR>/
noremap <Leader>et :tabe <C-r>=substitute(expand("%:p:h"), ' ', '\\\ ', 'g')<CR>/
nmap <silent> <Leader>r :source $MYVIMRC<CR>
nnoremap <silent> <Tab> :bnext<CR>
nnoremap <silent> <S-Tab> :bprevious<CR>
noremap <C-Left> :tabprevious<CR>
noremap <C-Right> :tabnext<CR>
noremap <C-n> :tabnew<CR>
noremap <BS> O<Esc>
noremap <CR> o<Esc>
noremap Y y$
nnoremap <silent> - :let @/=''<CR>
nnoremap <silent> _ :setl spell!<CR>
vnoremap < <gv
vnoremap > >gv
nnoremap <silent> <Leader>- :setl wrap! linebreak! list!<CR>
inoremap <C-y> <C-y><C-o>:pclose<CR>
inoremap <C-e> <C-e><C-o>:pclose<CR>
nnoremap <Space> za
nnoremap <silent> <Leader><Space> :setl foldenable!<CR>
noremap N Nzz
noremap n nzz
" remarkably, Nul is acatually C-Space
imap <Nul> <C-x><C-o>
imap <C-Space> <C-x><C-o>
" ctags
map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
map <M-]> :vsp<CR>:exec("tag ".expand("<cword>"))<CR>
"nnoremap <Leader>! :setl nolist<CR>:ConqueTerm bash -l<CR>
"nnoremap <Leader>@ :setl nolist<CR>:ConqueTerm ipython<CR>
vnoremap <F2> s<Esc>:execute 'normal a' . join(sort(split(getreg('"')), 'GentooCompare'), ' ')<CR>gqq
nnoremap <silent> <S-F2> :%s/<C-v><Esc>.\{-}m//ge<CR>:%s/<C-v><C-h>.//ge<CR>''
nnoremap <F3> :cprev<CR>
nnoremap <F4> :cnext<CR>
nnoremap <S-F3> [c
nnoremap <S-F4> ]c
nnoremap <F5> :Gstatus<CR>
nnoremap <F6> :GundoToggle<CR>
nnoremap <Leader>t :NERDTreeToggle<CR>
nnoremap <F7> :NERDTreeToggle<CR>
nnoremap <F8> :call Taglist_Toggle()<CR>
noremap <Leader>q :quit<CR>
noremap <F10> <Esc>:quit<CR>
noremap <S-F10> <Esc>:quitall!<CR>
noremap <Leader>d :BD<CR>
noremap <M-F10> <Esc>:BD<CR>
noremap <Leader>w :update<CR>
noremap <F11> <Esc>:update<CR>
noremap <S-F11> <Esc>:exit<CR>
noremap <M-F11> <Esc>:wall<CR>
imap <F10> <Esc><F10>
imap <S-F10> <Esc><S-F10>
imap <M-F10> <Esc><M-F10>
imap <F11> <Esc><F11>
imap <S-F11> <Esc><S-F11>
imap <M-F11> <Esc><M-F11>
"}}}
" {{{ set per filetype options
au BufRead,BufNewFile *.txt setlocal wrapmargin=2 textwidth=78 spell
au FileType * exec 'setlocal dict='.substitute($VIMRUNTIME, ' ', '\\\ ', 'g').'/syntax/'.&filetype.'.vim,'.&dict
au FileType mail setlocal spell
au FileType rst setlocal noexpandtab wrapmargin=2 textwidth=78 formatoptions+=a spell
au FileType ebuild nnoremap <F6> :silent !repoman manifest<CR><C-l>
au FileType changelog setlocal formatoptions+=a spell
au FileType python setlocal foldmethod=indent formatoptions=wcrq2l include=^\\s*\\(from\\\|import\\)
au FileType vim setlocal foldmethod=marker
au FileType c,cpp setlocal foldmethod=syntax tags+=~/.vim/tags/glib,~/.vim/tags/dbus
au FileType c,cpp nnoremap <F5> :exec '!./%:r ' . b:args<CR>
au FileType c noremap <C-F12> :!ctags -R --sort=foldcase --c-kinds=+pl --fields=+S .<CR>
au FileType cpp noremap <C-F12> :!ctags -R --sort=foldcase --c++-kinds=+pl --fields=+iaS --extra=+q .<CR>
au FileType cpp set tags+=~/.vim/tags/cpp,~/.vim/tags/boost,~/.vim/tags/qt4,~/.vim/tags/kde
au FileType java compiler javac
au FileType java nnoremap <F5> :exec '!java %:r ' . b:args<CR>
au FileType java nnoremap <F6> :make %<CR>
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
" }}}
" {{{ colors
"highlight link WhitespaceErrors Error
"au BufRead,BufNewFile * match WhitespaceErrors /\s\+$/
set t_8f=[38;2;%lu;%lu;%lum
set t_8b=[48;2;%lu;%lu;%lum
if has('termguicolors')
set termguicolors
endif
colorscheme onedark
" }}}
if has('cscope')
set cscopetag
if filereadable('cscope.out')
" add any database in current directory
cs add cscope.out
elseif $CSCOPE_DB != ''
" else add database pointed to by environment
cs add $CSCOPE_DB
endif
nmap <C-\>s :cs find s <C-R>=expand('<cword>')<CR><CR>
nmap <C-\>g :cs find g <C-R>=expand('<cword>')<CR><CR>
nmap <C-\>c :cs find c <C-R>=expand('<cword>')<CR><CR>
nmap <C-\>t :cs find t <C-R>=expand('<cword>')<CR><CR>
nmap <C-\>e :cs find e <C-R>=expand('<cword>')<CR><CR>
nmap <C-\>f :cs find f <C-R>=expand('<cfile>')<CR><CR>
nmap <C-\>i :cs find i ^<C-R>=expand('<cfile>')<CR>$<CR>
nmap <C-\>d :cs find d <C-R>=expand('<cword>')<CR><CR>
endif