forked from kingofctrl/vim.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
474 lines (360 loc) · 12.6 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
" .vimrc of Bo Liu
" {{{
" https://github.com/hmybmny/vimrc
set nocompatible
" }}}
" VIM-PLUG BLOCK
" {{{
silent! if plug#begin('~/.vim/plugged')
" Colors
Plug 'altercation/vim-colors-solarized'
Plug 'tomasr/molokai'
Plug 'colepeters/spacemacs-theme.vim'
Plug 'sheerun/vim-polyglot'
" Editing
Plug 'SirVer/ultisnips'
Plug 'sjl/gundo.vim'
Plug 'matze/vim-move'
Plug 'jiangmiao/auto-pairs'
Plug 'kana/vim-operator-user'
Plug 'gcmt/wildfire.vim'
Plug 'lilydjwg/fcitx.vim'
Plug 'scrooloose/nerdcommenter'
Plug 'derekwyatt/vim-protodef', { 'for': ['c', 'cpp', 'objc'] }
Plug 'suan/vim-instant-markdown', { 'for': 'markdown' }
" Navigation
Plug 'majutsushi/tagbar', { 'on': 'TagbarToggle' }
Plug 'derekwyatt/vim-fswitch', { 'for': ['c', 'cpp', 'objc'] }
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fugitive'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'dyng/ctrlsf.vim'
Plug 'fholgado/minibufexpl.vim'
" View
Plug 'Yggdroot/indentLine'
Plug 'airblade/vim-gitgutter'
" Linting
Plug 'w0rp/ale'
"cd ~
"mkdir ycm_build
"cd ycm_build/
"cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=~/Downloads/clang+llvm-3.9.1-x86_64-linux-gnu-ubuntu-16.04 . ~/.vim/plugged/YouCompleteMe/third_party/ycmd/cpp
"cmake --build . --target ycm_core
"Plug 'Valloric/YouCompleteMe'
function! BuildYCM(info)
if a:info.status == 'installed' || a:info.force
!./install.py --clang-completer
endif
endfunction
Plug 'Valloric/YouCompleteMe', { 'do': function('BuildYCM') }
call plug#end()
endif
" }}}
" BASIC SETTINGS
" {{{
let mapleader = ';'
set encoding=utf-8
" Allow backspacing over everything in insert mode
set backspace=indent,eol,start
" Store lots of :cmdline history
set history=500
" Show line numbers
set nu
set nowrap
" Autoindent when starting new line
set autoindent
set smartindent
set lazyredraw
" Ignore case when searching
set ignorecase
" Don't ignore case when search has capital letter
set smartcase
" Enable highlighted case-insensitive incremential search
set incsearch
" Enble search highlighting
set hlsearch
" Always show window statuses
set laststatus=2
" Statusline style
set statusline=
set statusline+=%7*\[%n] "buffernr
set statusline+=%1*\ %<%F\ "File+path
set statusline+=%2*\ %y\ "FileType
set statusline+=%3*\ %{''.(&fenc!=''?&fenc:&enc).''} "Encoding
set statusline+=%3*\ %{(&bomb?\",BOM\":\"\")}\ "Encoding2
set statusline+=%4*\ %{&ff}\ "FileFormat (dos/unix..)
set statusline+=%8*\ %=\ row:%l/%L\ (%p%%)\ "Rownumber/total (%)
set statusline+=%9*\ col:%c\ "Colnr
set statusline+=%0*\ \ %m%r%w\ %P\ \ "Modified? Readonly? Top/bot.
" Show the size of block one selected in visual mode
set showcmd
" Hide buffers
set hidden
set visualbell
" Indent using four spaces
set expandtab smarttab
set tabstop=2
set shiftwidth=2
set softtabstop=2
set gcr=a:block-blinkon0
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R
set guioptions-=m
set guioptions-=T
function! ToggleFullscreen()
call system("wmctrl -ir " . v:windowid . " -b toggle,fullscreen")
endf
map <silent> <F11> :call ToggleFullscreen()<CR>
imap <silent> <F11> <esc>:call ToggleFullscreen()<CR>
" autocmd VimEnter * call ToggleFullscreen()
" Show the line and column number of the cursor position
set ruler
" Highlight line under cursor
set cursorline
set cursorcolumn
" }}}
" MAPPINGS
" {{{
" ----------------------------------------------------------------------------
" Basic mappings
" ----------------------------------------------------------------------------
" Profile
iabbrev @@ [email protected]
iabbrev @b hmybmny.com
" Edit myvimrc
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
nnoremap <leader>sv :source $MYVIMRC<cr>
" Edit
nnoremap <leader>" viw<esc>a"<esc>hbi"<esc>lel
" Save
inoremap <C-s> <C-O>:w<cr>
nnoremap <C-s> :w<cr>
nnoremap <leader>w :w<cr>
" Copy
vnoremap <Leader>y "+y
nmap <Leader>p "+p
" Quit
nnoremap <Leader>q :q<cr>
nnoremap <Leader>Q :qa!<cr>
" Movement in insert mode
inoremap <C-h> <C-o>h
inoremap <C-j> <C-o>j
inoremap <C-k> <C-o>k
inoremap <C-l> <C-o>a
inoremap <C-^> <C-o><C-^>
" ----------------------------------------------------------------------------
" Quickfix
" ----------------------------------------------------------------------------
nnoremap ]q :cnext<cr>zz
nnoremap [q :cprev<cr>zz
" ----------------------------------------------------------------------------
" <tab> / <s-tab> | Circular windows navigation
" ----------------------------------------------------------------------------
nnoremap <tab> <c-w>w
nnoremap <S-tab> <c-w>W
nnoremap <Leader>hw <C-W>h
nnoremap <Leader>jw <C-W>j
nnoremap <Leader>kw <C-W>k
nnoremap <Leader>lw <C-W>l
" ----------------------------------------------------------------------------
" :CopyRTF
" ----------------------------------------------------------------------------
function! s:colors(...)
return filter(map(filter(split(globpath(&rtp, 'colors/*.vim'), "\n"),
\ 'v:val !~ "^/usr/"'),
\ 'fnamemodify(v:val, ":t:r")'),
\ '!a:0 || stridx(v:val, a:1) >= 0')
endfunction
" ----------------------------------------------------------------------------
" <F8> | Color scheme selector
" ----------------------------------------------------------------------------
"
set background=dark
let g:molokai_original = 1
colorschem molokai
function! s:rotate_colors()
if !exists('s:colors')
let s:colors = s:colors()
endif
let name = remove(s:colors, 0)
call add(s:colors, name)
set background=dark
execute 'colorscheme' name
redraw
echo name
endfunction
nnoremap <silent> <F8> :call <SID>rotate_colors()<cr>
inoremap <silent> <F8> <esc>:call <SID>rotate_colors()<cr>
" }}}
" PLUGINS
" {{{
" ----------------------------------------------------------------------------
" ultisnips
" ----------------------------------------------------------------------------
let g:UltiSnipsSnippetDirectories=["mysnippets"]
let g:UltiSnipsExpandTrigger="<leader><tab>"
let g:UltiSnipsJumpForwardTrigger="<leader><tab>"
let g:UltiSnipsJumpBackwardTrigger="<leader><s-tab>"
" ----------------------------------------------------------------------------
" vim-multiple-cursors
" ----------------------------------------------------------------------------
let g:multi_cursor_next_key='<S-n>'
let g:multi_cursor_skip_key='<S-k>'
" ----------------------------------------------------------------------------
" vim-move
" ----------------------------------------------------------------------------
let g:move_key_modifier = 'C'
" ----------------------------------------------------------------------------
" auto-pairs
" ----------------------------------------------------------------------------
" ----------------------------------------------------------------------------
" vim-operator-user
" ----------------------------------------------------------------------------
" ----------------------------------------------------------------------------
" wildfire.vim
" ----------------------------------------------------------------------------
map <SPACE> <Plug>(wildfire-fuel)
vmap <C-SPACE> <Plug>(wildfire-water)
" ----------------------------------------------------------------------------
" indentLine
" ----------------------------------------------------------------------------
let g:indentLine_char = '│'
" ----------------------------------------------------------------------------
" tarbar
" ----------------------------------------------------------------------------
inoremap <F2> <esc>:TagbarToggle<cr>
nnoremap <F2> :TagbarToggle<cr>
let tagbar_left=1
let tagbar_width=32
let g:tagbar_sort = 0
let g:tagbar_compact=1
let g:tagbar_type_cpp = {
\ 'ctagstype' : 'c++',
\ 'kinds' : [
\ 'c:classes:0:1',
\ 'd:macros:0:1',
\ 'e:enumerators:0:0',
\ 'f:functions:0:1',
\ 'g:enumeration:0:1',
\ 'l:local:0:1',
\ 'm:members:0:1',
\ 'n:namespaces:0:1',
\ 'p:functions_prototypes:0:1',
\ 's:structs:0:1',
\ 't:typedefs:0:1',
\ 'u:unions:0:1',
\ 'v:global:0:1',
\ 'x:external:0:1'
\ ],
\ 'sro' : '::',
\ 'kind2scope' : {
\ 'g' : 'enum',
\ 'n' : 'namespace',
\ 'c' : 'class',
\ 's' : 'struct',
\ 'u' : 'union'
\ },
\ 'scope2kind' : {
\ 'enum' : 'g',
\ 'namespace' : 'n',
\ 'class' : 'c',
\ 'struct' : 's',
\ 'union' : 'u'
\ }
\ }
" ----------------------------------------------------------------------------
" vim-fswitch
" ----------------------------------------------------------------------------
nmap <silent> <Leader>fs :FSHere<cr>
" ----------------------------------------------------------------------------
" vim-protodef
" ----------------------------------------------------------------------------
let g:protodefprotogetter='~/.vim/plugged/vim-protodef/pullproto.pl'
let g:disable_protodef_sorting=1
" ----------------------------------------------------------------------------
" nerdcommenter
" ----------------------------------------------------------------------------
" ----------------------------------------------------------------------------
" nerdtree
" ----------------------------------------------------------------------------
inoremap <F3> <esc>:NERDTreeToggle<CR>
nnoremap <F3> :NERDTreeToggle<CR>
let NERDTreeWinSize=22
let NERDTreeWinPos="right"
let NERDTreeShowHidden=0
let NERDTreeMinimalUI=1
let NERDTreeAutoDeleteBuffer=1
" ----------------------------------------------------------------------------
" vim-instant-markdown
" ----------------------------------------------------------------------------
autocmd BufNewFile,BufReadPost *.md set filetype=markdown
let g:instant_markdown_slow = 1
let g:instant_markdown_autostart = 0
nnoremap <Leader>md :InstantMarkdownPreview<CR>
" ----------------------------------------------------------------------------
" vim-fugitive
" ----------------------------------------------------------------------------
" ----------------------------------------------------------------------------
" vim-gitgutter
" ----------------------------------------------------------------------------
set updatetime=250
set signcolumn=yes
" ----------------------------------------------------------------------------
" ale
" ----------------------------------------------------------------------------
" ----------------------------------------------------------------------------
" minibufexpl
" ----------------------------------------------------------------------------
inoremap <F4> <esc>:MBEToggle<cr>
nnoremap <F4> :MBEToggle<cr>
nnoremap ]b :bnext<cr>
nnoremap [b :bprev<cr>
" ----------------------------------------------------------------------------
" gundo.vim
" ----------------------------------------------------------------------------
nnoremap <Leader>ud :GundoToggle<CR>
set sessionoptions="blank,globals,localoptions,tabpages,sesdir,folds,help,options,resize,winpos,winsize"
if !strlen(finddir('~/.vim/undofiles'))
echo "undofiles[~/.vim/undofiles] not found. Now it's being created. Press ENTER or type command to continue."
!mkdir -p ~/.vim/undofiles
endif
if v:version >= 703
set undodir=~/.vim/undofiles
set undofile
set colorcolumn=+1
endif
" ----------------------------------------------------------------------------
" ctrlsf.vim
" ----------------------------------------------------------------------------
nnoremap <c-f> :CtrlSF<CR>
" ----------------------------------------------------------------------------
" ctrlp.vim
" ----------------------------------------------------------------------------
" Disable output, vcs, archive, rails, temp and backup files
set wildignore+=*.o,*.out,*.obj,.git,*.pyc,*.class
set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz
set wildignore+=*.swp,*~,._*
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
let g:ctrlp_map = '<s-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn|vendor/bundle/*\|vendor/cache/*\|public\|spec)$',
\ 'file': '\v\.(exe|so|dll|swp|log|jpg|png|json)$',
\ }
" ----------------------------------------------------------------------------
" YouCompleteMe
" ----------------------------------------------------------------------------
set completeopt-=preview
nnoremap <leader>jc :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>jd :YcmCompleter GoToDefinition<CR>
inoremap <leader>; <C-x><C-o>
let g:ycm_complete_in_comments=1
let g:ycm_confirm_extra_conf=0
let g:ycm_collect_identifiers_from_tags_files=0
let g:ycm_min_num_of_chars_for_completion=1
let g:ycm_cache_omnifunc=0
let g:ycm_seed_identifiers_with_syntax=1
" }}}