forked from houqp/vimrc-houqp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathallrc.vim
executable file
·600 lines (504 loc) · 14.5 KB
/
allrc.vim
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
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
""""""""""""""""""""""""""""""
" Setting for vundle
""""""""""""""""""""""""""""""
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
set rtp+=~/.vim/bundles/vim-dokuwiki/
let g:dokuwiki_enable_key_mappings = 1
set rtp+=~/.vim/bundles/mytemplates/
" replaced with autload_cscope.vim
"set rtp+=~/.vim/bundles/cscope-related/
set rtp+=~/.vim/bundles/linux-kernel.vim/
set rtp+=~/.vim/bundles/notify.vim/
call vundle#rc()
Bundle 'gmarik/vundle'
" --- languages ---
Bundle 'c.vim'
Bundle 'echofunc.vim'
Bundle 'moin.vim'
Bundle 'sukima/xmledit'
Bundle 'git://vim-latex.git.sourceforge.net/gitroot/vim-latex/vim-latex'
Bundle 'maxima.vim'
Bundle 'Puppet-Syntax-Highlighting'
Bundle 'bufexplorer.zip'
Bundle 'octave.vim--'
Bundle 'scilab.vim'
Bundle 'johnbintz/vim-puppet'
Bundle 'xolox/vim-lua-ftplugin'
" deps for vim-lua-ftplugin
Bundle 'xolox/vim-misc'
Bundle 'saltstack/salt-vim'
Bundle 'derekwyatt/vim-scala'
"Bundle 'houqp/vim-dokuwiki'
"Bundle 'xolox/vim-lua-inspect'
" --- web dev ---
"Bundle 'lilydjwg/colorizer'
Bundle 'othree/html5.vim'
Bundle 'hail2u/vim-css3-syntax'
Bundle 'mattn/emmet-vim'
"Bundle 'nono/jquery.vim'
Bundle 'tpope/vim-haml'
Bundle 'groenewege/vim-less'
Bundle 'othree/javascript-libraries-syntax.vim'
Bundle 'kchmck/vim-coffee-script'
" --- dev tools ---
Bundle 'SirVer/ultisnips'
Bundle 'tpope/vim-fugitive'
" > better alternative for taglist
Bundle 'majutsushi/tagbar'
Bundle 'po.vim'
Bundle 'scrooloose/nerdcommenter'
Bundle 'VOoM'
" > show TODO, FIXME etc.
Bundle 'superjudge/tasklist-pathogen'
" > for fast search inside codes
Bundle 'mileszs/ack.vim'
Bundle 'matchit.zip'
Bundle 'Rip-Rip/clang_complete'
Bundle 'tomtom/tcomment_vim'
Bundle 'editorconfig/editorconfig-vim'
Bundle 'autoload_cscope.vim'
" --- misc ---
Bundle 'L9'
" > better alternative for FuzzyFinder
Bundle 'kien/ctrlp.vim'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'scrooloose/vim-statline'
Bundle 'AutoComplPop'
" > toggle quickfix and location list
Bundle 'milkypostman/vim-togglelist'
" > pairs of bracket mappings
Bundle 'tpope/vim-unimpaired'
Bundle 'tpope/vim-repeat'
"Bundle 'tpope/vim-surround'
Bundle 'Lokaltog/vim-powerline'
Bundle 'bronson/vim-trailing-whitespace'
Bundle 'airblade/vim-gitgutter'
"Bundle 'vim-scripts/YankRing.vim'
" for vimfiler
Bundle 'Shougo/unite.vim'
Bundle 'Shougo/vimfiler.vim'
" --- themes ---
"Bundle 'chriskempson/vim-tomorrow-theme'
"Bundle 'daylerees/colour-schemes', { 'rtp': 'vim-themes/' }
"Bundle 'nanotech/jellybeans.vim'
filetype plugin indent on
"Set mapleader
let mapleader = ","
syntax enable
""""""""""""""""""""""""""""""
" Tab and indent
""""""""""""""""""""""""""""""
" expand tab to spaces
set noexpandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
"show tab
set list
"set listchars=tab:▸\
" start with : and fill the remaining with spaces
set listchars=tab:\:\ "we have a space here
set autoindent
set cindent
set nu
" set scroll offset
set so=7
" highlight current line
set cursorline
" highlight current column
"set cursorcolumn
" highlight colorcolumn 80
set colorcolumn=80
" 搜索时忽略大小写,但在有一个或以上大写字母时仍保持对大小写敏感
set ignorecase smartcase
" 允许在有未保存的修改时切换缓冲区,此时的修改由 vim 负责保存
set hidden
"set the number of changes that are remembered
set undolevels=200
set modifiable
set write
"set foldenable
"set foldmethod=syntax
set foldcolumn=1
"highlight Folded ctermbg=black
"highlight Folded ctermfg=darkmagenta
"highlight Folded guibg=white
let loaded_csExplorer = 1 "not load the color preview plugin
" find tags file recursively from current directory to root directory
set tags=tags;
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" For special file type
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd FileType python setlocal expandtab shiftwidth=4 softtabstop=4
autocmd FileType haml setlocal expandtab shiftwidth=2 softtabstop=2
autocmd FileType dokuwiki setlocal expandtab shiftwidth=2 softtabstop=2
au BufRead,BufNewFile *.md set ft=markdown
au BufRead,BufNewFile *.py set ft=python
"autocmd FileType markdown Voom markdown
"autocmd FileType asciidoc Voom asciidoc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" For search
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set hlsearch
set incsearch "search every word you type
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>
map <silent> <leader><cr> :noh<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Auto motion for vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"工作目录随文件变
"autocmd BufEnter * cd %:p:h
set autochdir
" Set to auto read when a file is changed from the outside
set autoread
" reload vimrc when it is changed
autocmd! BufWritePost .vimrc,.gvimrc,allrc.vim
\ if has("gui_running") |
\ source $MYGVIMRC |
\ else |
\ source $MYVIMRC |
\ endif
" auto disable input method
autocmd! InsertLeave * set imdisable
autocmd! InsertEnter * set noimdisable
" 让 Tohtml 产生有 CSS 语法的 html
" syntax/2html.vim,可以用:runtime! syntax/2html.vim
let html_use_css=1
filetype plugin on
""""""""""""""""""""""""""""""
" Omni
""""""""""""""""""""""""""""""
imap <C-L> <C-x><C-o>
set completeopt=longest,menu
let g:AutoComplPop_IgnoreCaseOption=1
set ignorecase
"""""""""""""""""""""""""""""""
" CtrlP
"""""""""""""""""""""""""""""""
"let g:ctrlp_map = '<leader>f'
nmap <leader>f :CtrlPMixed<cr>
nmap <leader>bf :CtrlPBuffer<cr>
nmap <leader>r :CtrlPMRU<cr>
" default search by filename
let g:ctrlp_by_filename = 1
" avoid opening file in following window
let g:ctrlp_reuse_window = 'netrw\|help\|quickfix'
" don't manage working directory
let g:ctrlp_working_path_mode = 0
" exclude files from file search
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(exe|so|dll|o|a|swp|dep)$|tags',
\ }
" exclude files from MRU
let g:ctrlp_mruf_exclude = '/tmp/.*\|/temp/.*|.*\.swp$|.*\.o$'
"let g:ctrlp_user_command = 'find %s -type f'
" open file in current window
let g:ctrlp_open_new_file = 'r'
" follow links in searching
let g:ctrlp_follow_symlinks = 1
" switch mappings between ToggleType and PtrCur
let g:ctrlp_prompt_mappings = {
\ 'ToggleType(1)': ['<c-l>', '<c-up>'],
\ 'ToggleType(-1)': ['<c-h>', '<c-down>'],
\ 'PrtCurLeft()': ['<c-b>', '<left>', '<c-^>'],
\ 'PrtCurRight()': ['<c-f>', '<right>'],
\ }
"""""""""""""""""""""""""""""""
" TagBar
""""""""""""""""""""""""""""""
let g:tagbar_left = 1
"let g:tagbar_iconchars = ['+', '-']
let g:tagbar_iconchars = [' ▶', ' ▼']
let g:tagbar_autoshowtag = 1
let g:tagbar_width = 30
map <Leader>tl :TagbarToggle<CR>
let g:tagbar_type_tex = {
\ 'ctagstype' : 'latex',
\ 'kinds' : [
\ 's:sections',
\ 'g:graphics',
\ 'l:labels',
\ 'r:refs',
\ 'p:pagerefs'
\ ],
\ 'sort' : 0,
\ }
let g:tagbar_type_md = {
\ 'ctagstype' : 'markdown',
\ 'kinds' : [
\ 'h:Heading_L1',
\ 'i:Heading_L2',
\ 'k:Heading_L3'
\ ]
\ }
let g:tagbar_type_asciidoc = {
\ 'ctagstype' : 'asciidoc',
\ 'kinds' : [
\ 'h:Heading_L1',
\ 'i:Heading_L2',
\ 'k:Heading_L3'
\ ]
\ }
let g:tagbar_type_php = {
\ 'ctagstype' : 'php',
\ 'kinds' : [
\ 'd:Constants:0',
\ 'v:Variables:0',
\ 'f:Functions:0',
\ 'i:Interfaces:0',
\ 'c:Classes:0',
\ 'p:Properties:0',
\ 'm:Methods:0'
\ ],
\ 'sro' : '::',
\ 'kind2scope' : {
\ 'c' : 'class',
\ 'm' : 'method',
\ 'f' : 'function',
\ 'i' : 'interface'
\ },
\ 'scope2kind' : {
\ 'class' : 'c',
\ 'method' : 'm',
\ 'function' : 'f',
\ 'interface' : 'i'
\ }
\ }
let g:tagbar_type_javascript = {
\ 'ctagstype' : 'JavaScript',
\ 'kinds' : [
\ 'o:objects',
\ 'f:functions',
\ 'a:arrays',
\ 's:strings'
\ ]
\ }
""""""""""""""""""""""""""""""
" Vim-LaTex
""""""""""""""""""""""""""""""
" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse Latex-Suite. Set your grep
" program to always generate a file-name.
set grepprg=grep\ -nH\ $*
" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'
""""""""""""""""""""""""""""""
" Use vim in man page
""""""""""""""""""""""""""""""
let $PAGER=''
""""""""""""""""""""""""""""""
" Showmarks setting
""""""""""""""""""""""""""""""
" Enable ShowMarks
let showmarks_enable = 1
" Show which marks
let showmarks_include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
" Ignore help, quickfix, non-modifiable buffers
let showmarks_ignore_type = "hqm"
" Hilight lower & upper marks
let showmarks_hlline_lower = 1
let showmarks_hlline_upper = 1
""""""""""""""""""""""""""""""
" Some other mappings
""""""""""""""""""""""""""""""
" switch between two windows
nmap <leader><TAB> :wincmd p<cr>
"nmap CTRL-F1 :!cts<cr>
"F5 for compling
nmap <M-F5> :make<cr>
"jumpping between the errors
nmap <M-F7> :cn<cr>
nmap <M-F8> :cp<cr>
"Pressing ,ss will toggle and untoggle spell checking
map <leader>ss :call ToggleSpellCheck()<cr>
"toggle hex mode
map <leader>h :call ToggleHexMode()<cr>
"Fast saving
nmap <leader>w :w!<cr>
imap <C-s> <esc>:w<cr>a
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
""""""""""""""""""""""""""""""""
" Command mode related mappings
""""""""""""""""""""""""""""""""
"Bash like keys for the command line
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-K> <C-U>
cnoremap <C-P> <Up>
cnoremap <C-N> <Down>
cnoremap <C-F> <Right>
cnoremap <C-B> <left>
"""""""""""""""""""""""""""""""""""""
" Abbreviations for spelling correct
"""""""""""""""""""""""""""""""""""""
function! ToggleSpellCheck()
setlocal spell!
"@TODO: save old value
"s:old_balloonexpr = balloonexpr
set balloonexpr=SpellBalloon()
set ballooneval!
endfunction
function! SpellBalloon()
let lines = spellsuggest( spellbadword(v:beval_text)[0], 5, 0 )
return join( lines, has("balloon_multiline") ? "\n" : "" )
endfunction
iab szie size
iab SZIE SIZE
""""""""""""""""""""""""""""""
" Statusline
""""""""""""""""""""""""""""""
set encoding=utf-8 " Necessary to show unicode glyphs
" Always show the statusline
"set laststatus=2
" Format the statusline
"set statusline=\ [CWD:\%r%{CurDir()}%h]\ %{HasPaste()}%f%m%r%h%w\
"\[TYPE=%Y]\ \ Line:\ %l/%L:%c\ [ASCII=\%03.3b,\ HEX=\%02.2B]
function! CurDir()
let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
return curdir
endfunction
function! HasPaste()
if &paste
return 'PASTE MODE '
else
return ''
endif
endfunction
""""""""""""""""""""""""""""""
" Toggle hex mode
""""""""""""""""""""""""""""""
let s:hexMode = "N"
function! ToggleHexMode()
if s:hexMode == "Y"
%!xxd -r
let s:hexMode = "N"
else
%!xxd
let s:hexMode = "Y"
endif
endfunction
""""""""""""""""""""""""""""""
" Place holder
""""""""""""""""""""""""""""""
"mark place holder
match Todo /<+.\++>/
"nnoremap <c-j> /<+.\{-1,}+><cr>c/+>/e<cr>
"inoremap <c-j> <ESC>/<+.\{-1,}+><cr>c/+>/e<cr>
nnoremap <c-j> /<+.\{-1,}><cr>c/+>/e<cr>
inoremap <c-j> <ESC>/<+.\{-1,}><cr>c/+>/e<cr>
""""""""""""""""""""""""""""""
" Session management
""""""""""""""""""""""""""""""
set sessionoptions-=blank,help
set sessionoptions+=resize,winpos
if !exists("g:session_dir")
let g:session_dir = ""
endif
" session is only enabled for gvim with no arguments
" if g:session_dir != "", then session_mode is set
" Session.vim not found, set session_mode
autocmd! GUIEnter *
\ if argc() == 0 |
\ if filereadable("Session.vim") |
\ let g:session_dir = CurDir() |
\ source Session.vim |
\ source $MYGVIMRC |
\ else |
\ let g:session_dir = "?" |
\ endif
autocmd! VimLeave * call SaveSession()
nmap <leader>ms :call SaveSession()<cr>
function! SaveSession()
if g:session_dir != ""
" session_mode is set
if g:session_dir != "?"
" already loaded from a session, save to the original Session.vim
execute 'mksession! ' . g:session_dir . '/Session.vim'
else
" session_mode is set, create a new Session.vim
mksession! Session.vim
let g:session_dir = CurDir()
endif
endif
endfunction
""""""""""""""""""""""""""""""
" Font size helper function
" From: http://vim.wikia.com/wiki/Change_font_size_quickly
""""""""""""""""""""""""""""""
let s:pattern = '^\(.* \)\([1-9][0-9]*\)$'
let s:minfontsize = 6
let s:maxfontsize = 16
function! AdjustFontSize(amount)
if has("gui_gtk2") && has("gui_running")
let fontname = substitute(&guifont, s:pattern, '\1', '')
let cursize = substitute(&guifont, s:pattern, '\2', '')
let newsize = cursize + a:amount
if (newsize >= s:minfontsize) && (newsize <= s:maxfontsize)
let newfont = fontname . newsize
let &guifont = newfont
endif
else
echoerr "You need to run the GTK2 version of Vim to use this function."
endif
endfunction
function! LargerFont()
call AdjustFontSize(1)
endfunction
command! LargerFont call LargerFont()
function! SmallerFont()
call AdjustFontSize(-1)
endfunction
command! SmallerFont call SmallerFont()
""""""""""""""""""""""""""""""
" JavaScript libraries plugin
""""""""""""""""""""""""""""""
let g:used_javascript_libs = 'angularjs'
""""""""""""""""""""""""""""""
" GitGutter
""""""""""""""""""""""""""""""
" turn off by default
let g:gitgutter_enabled = 0
" gitgutter display toggle
nmap <leader>gd :GitGutterToggle<CR>
" for jumpping between hunks
nmap <silent> ]h :<C-U>execute v:count1 . "GitGutterNextHunk"<CR>
nmap <silent> [h :<C-U>execute v:count1 . "GitGutterPrevHunk"<CR>
""""""""""""""""""""""""""""""
" Vimfiler
""""""""""""""""""""""""""""""
"call vimfiler#set_execute_file('vim', 'vim')
"call vimfiler#set_execute_file('txt', 'notepad')
" Edit file by tabedit.
"let g:vimfiler_edit_action = 'tabopen'
let g:vimfiler_as_default_explorer = 1
let g:vimfiler_ignore_pattern = '^\(' .
\ '.*\.\(o\|a\|so\|swp\|swo\)' .
\ '\|' .
\ 'tags' .
\ '\|' .
\ '\.git' .
\ '\|' .
\ '\.svn' .
\ '\|' .
\ 'cscope\.\(files\|in\.out\|out\|po\.out\)' .
\ '\)$'
" Enable file operation commands.
"let g:vimfiler_safe_mode_by_default = 0
" Like Textmate icons.
"let g:vimfiler_tree_leaf_icon = ' '
"let g:vimfiler_tree_opened_icon = '▾'
"let g:vimfiler_tree_closed_icon = '▸'
"let g:vimfiler_file_icon = '-'
"let g:vimfiler_marked_file_icon = '*'
""""""""""""""""""""""""""""""
" ack.vim
""""""""""""""""""""""""""""""
" use silver searcher for ack.vim
let g:ackprg = 'ag --nogroup --nocolor --colum'