-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
371 lines (287 loc) · 10 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
"
" .vimrc: https://github.com/nekipelov/dotfiles
" authro: Alex Nekipelov ([email protected])
"
" Plugin settings
let g:NERDCustomDelimiters = {'cpp': { 'left': '//', 'leftAlt': 'REM ' }}
" vundle
set nocompatible
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 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
"Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Avoid a name conflict with L9
"Plugin 'user/L9', {'name': 'newL9'}
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'Valloric/YouCompleteMe'
Plugin 'https://github.com/vim-scripts/OmniCppComplete'
Plugin 'bling/vim-bufferline'
Plugin 'scrooloose/syntastic'
"Plugin 'Acpp'
Plugin 'cpp.vim'
Plugin 'https://github.com/scrooloose/nerdcommenter.git'
"Plugin 'https://github.com/sjbach/lusty.git'
Plugin 'https://github.com/tpope/vim-endwise.git'
Plugin 'https://github.com/thinca/vim-localrc.git'
Plugin 'https://github.com/xaizek/vim-inccomplete'
Plugin 'https://github.com/vim-scripts/BufOnly.vim.git'
Plugin 'https://github.com/jeetsukumaran/vim-buffergator.git'
Plugin 'https://github.com/scrooloose/nerdtree.git'
Plugin 'https://github.com/Xuyuanp/nerdtree-git-plugin.git'
Plugin 'https://github.com/ntpeters/vim-better-whitespace.git'
Plugin 'https://github.com/bkad/CamelCaseMotion.git'
Plugin 'https://github.com/othree/eregex.vim.git'
Plugin 'https://github.com/ConradIrwin/vim-bracketed-paste.git'
Plugin 'https://github.com/majutsushi/tagbar.git'
Plugin 'https://github.com/rking/ag.vim.git'
Plugin 'https://github.com/kien/ctrlp.vim.git'
Plugin 'https://github.com/junegunn/fzf'
Plugin 'https://github.com/tpope/vim-unimpaired.git'
Plugin 'https://github.com/easymotion/vim-easymotion.git'
Plugin 'rust-lang/rust.vim'
" colors
Plugin 'damage220/solas.vim'
Plugin 'nanotech/jellybeans.vim'
Plugin 'mhartington/oceanic-next'
Plugin 'https://github.com/jonathanfilip/vim-lucius.git'
Plugin 'https://github.com/altercation/vim-colors-solarized.git'
" TODO
" http://vimawesome.com/
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
filetype plugin on
" make
map <F9> :wa<CR>:make!<CR>
imap <F9> <Esc>:wa<CR>:make!<CR>
"Vim-incomplete
let g:inccomplete_showdirs = 1
let g:inccomplete_addclosebracket = ""
" String to put at the start of lines that have been wrapped
set showbreak=+
filetype plugin on
filetype indent on
" <F2> saves current buffer
nmap <F2> :w<CR>
imap <F2> <C-O>:w<CR>
" Undo in insert mode.
imap <c-z> <c-o>u
" Type (in the insert-mode) 4+4<C-B> and you will get the result.
" Note: '<C-A>' won't work under screen because C-A C-A is a default
" Keybinding of screen *g*
" '*' == sum|'+' == product
" '-' == difference|'/' == quotient
" '%' == remainder|'^' == scale(a^b) = min(scale(a)*b
inoremap <C-B> <C-O>yiW<End>=<C-R>=<C-R>0<CR>
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
set softtabstop=4
" line height
set colorcolumn=100
"highlight ColorColumn ctermbg=darkgray
" relative line numbers
set relativenumber
" print current line number
set number
"highlight CursorLineNr ctermfg=grey ctermbg=grey
" higlight current line
"set cursorline
hi CursorLine cterm=NONE ctermbg=darkgray ctermfg=white guibg=darkgray guifg=white
hi CursorColumn cterm=NONE ctermbg=darkgray ctermfg=white guibg=darkgray guifg=white
set background=dark
colorscheme solarized
"colorscheme lucius
"LuciusDarkHighContrast
"LuciusLightHighContrast
" search vimrc in current directory
set exrc
set secure
" switch to buffers without save
set hidden
" include path
set path+=.,"/usr/include/"
if isdirectory('/usr/include/c++/4.9')
set path+=/usr/include/c++/4.9
elseif isdirectory('/usr/include/c++/4.8')
set path+=/usr/include/c++/4.8
elseif isdirectory('/usr/include/c++/4.7')
set path+=/usr/include/c++/4.7
elseif isdirectory('/usr/include/c++/4.6')
set path+=/usr/include/c++/4.6
endif
" extra spaces
highlight ExtraWhitespace ctermbg=gray guibg=gray
match ExtraWhitespace /\s\+$/
" vim-airline
let g:airline#extensions#tabline#enabled = 1
"let g:airline_enable_fugitive=1
let g:airline_enable_syntastic=1
let g:airline_enable_bufferline=1
"let g:airline_theme='dark'
let g:airline_powerline_fonts = 1
let g:airline_theme='solarized'
set laststatus=2
" plugins
" switch between header and implementation (.cpp/.h).
so ~/.vim/plugins/a.vim
map <F4> :A<CR>
" NerdComment
nmap <C-.> :call NERDComment('n', 'toggle')<CR>
xmap <C-.> :call NERDComment('x', 'toggle')<CR>
" NerdTree
nmap <Leader>n :NERDTreeToggle<CR>
xmap <Leader>n :NERDTreeToggle<CR>
let g:NERDTreeDirArrows = 1
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
" Replace word under cursor
nnoremap <Leader>s :%s/\<<C-r><C-w>\>//gc<Left><Left><Left>
" git grep word under cursor
"nnoremap <Leader>f :Ggrep -w <C-r><C-w>
" Higlight word under cursor
autocmd CursorMoved * exe printf('match Search /\V\<%s\>/', escape(expand('<cword>'), '/\'))
" replace current word to yanked text
nnoremap S "_diwP
" autogenerate tags
"au BufWritePost *.c,*.cpp,*.h silent! !ctags -R &
" tag files
set tags+=~/.vim/stl_tags;
" build tags of your own project with Ctrl-F12
map <F12> :!ctags -f tags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q -I _GLIBCXX_NOEXCEPT .<CR>
set nocp
filetype plugin on
syntax on
set filetype=cpp
" higlight search
set hlsearch
set incsearch
" switch tab by alt+num
for c in range(1, 9)
exec "set <A-".c.">=\e".c
exec "map \e".c." <A-".c.">"
let n = c - '0'
exec "map <M-". n ."> ". n ."gt"
endfor
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 2
"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 = 1 " autocomplete after ::
" also necessary for fixing LIBSTDC++ releated stuff
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD", "boost"]
" automatically open and close the popup menu / preview window
"au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
"autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
"autocmd InsertLeave * if pumvisible() == 0|pclose|endif
"set completeopt=menuone,menu,longest,preview
set completeopt-=preview
"tmp!
autocmd FileType cpp set omnifunc=cppcomplete#CompleteCPP
au BufNewFile,BufRead,BufEnter *.cpp,*.hpp set omnifunc=omni#cpp#complete#Main
" YouCompleteMe
let g:ycm_confirm_extra_conf = 0
let g:syntastic_always_populate_loc_list = 1
ret g:ycm_collect_identifiers_from_tags_files = 1
"CamelCaseMotion
"map m <Plug>CamelCaseMotion_w
"map ? <Plug>CamelCaseMotion_b
" Vim Better Whitespace
highlight ExtraWhitespace ctermbg=red
" eregex plugin
nnoremap <leader>/ :call eregex#toggle()<CR>
let g:eregex_default_enable = 0
" ag plugin
" start searching from your project root
"let g:ag_working_path_mode="r"
" CtrlP plugin
let g:ctrlp_map = '<Leader>p'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_extensions = ['tag', 'buffertag', 'dir']
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$',
\ 'file': '\.o$' }
" CommandT plugin
nmap <silent> <Leader>t <Plug>(CommandT)
nmap <silent> <Leader>b <Plug>(CommandTBuffer)
nmap <silent> <Leader>j <Plug>(CommandTJump)
" don't sort by name
let g:tagbar_sort = 0
nmap <F8> :TagbarToggle<CR>
"""" NerdCommenter
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
""" EasyMotion
" Turn on case insensitive feature
let g:EasyMotion_smartcase = 1
" z{char}{char} to move to {char}{char}
nmap z <Plug>(easymotion-overwin-f2)
" higlight <..> pair for C++ templates
au FileType cpp set matchpairs+=<:>
" :W sudo saves the file
" (useful for handling the permission-denied error)
command W w !sudo tee % > /dev/null
" Minimal number of screen lines to keep above and below the cursor
set scrolloff=10
" Ignore files
set wildignore=*.o,*~,*.pyc
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*
" Persistent undo
if has('persistent_undo')
set undofile " Save undo's after file closes
set undodir=$HOME/.vim/undo " where to save undo histories
set undolevels=1000 " How many undos
set undoreload=10000 " number of lines to save for undo
endif
" Visual shifting (does not exit Visual mode)
vnoremap < <gv
vnoremap > >gv
" allow the . to execute once for each line of a visual selection
vnoremap . :normal .<CR>
" next/prev error
nmap <C-n> :cn<CR>
nmap <C-p> :cp<CR>
" wild menu
set wildmenu
let g:charset_is_cp1251 = 0
function! ToggleCharset()
if g:charset_is_cp1251
let g:charset_is_cp1251 = 0
e ++enc=utf-8
else
let g:charset_is_cp1251 = 1
e ++enc=cp1251
endif
endfunction
nmap <F3> :call ToggleCharset()<CR>
let g:fugitive_git_grep_options='-n --no-color --recurse-submodules'
set backspace=indent,eol,start