-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
executable file
·1331 lines (1215 loc) · 50.1 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
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
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
" _____ ______ __ __ ______ __ __
" /\ __-. /\ __ \ /\ '-./ \ /\ __ \ /\ '-.\ \
" \ \ \/\ \ \ \ __ \ \ \ \-./\ \ \ \ \/\ \ \ \ \-. \
" \ \____- \ \_\ \_\ \ \_\ \ \_\ \ \_____\ \ \_\\'\_\
" \/____/ \/_/\/_/ \/_/ \/_/ \/_____/ \/_/ \/_/
"
" Author: Damon Ma
" Repo: https://github.com/blurm/myconfigs
let loadPlug = 1
let loadSysSetting = 1
let loadKeyMapping = 1
let loadFold = 1
let loadFunc = 1
let loadNvim = 1
let loadDenite = 1
let loadAirline = 1
let loadStartify = 1
let loadVimfiler = 1
let loadSpaceVim = 1
let loadProfile = 1
let loadDeoplete = 1
" Plugin definations ------------------------------------------------------- {{{
" Need to install vim-plug first
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Specify a directory for plugins (for Neovim: ~/.local/share/nvim/plugged)
call plug#begin('~/.vim/plugged')
if loadPlug == 1
" Autocomplete & Snips
Plug 'artur-shaik/vim-javacomplete2', {'for': 'java'} " autocomplete for Java
"autocmd FileType java setlocal omnifunc=javacomplete#Complete
if has("nvim")
"Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
"Plug 'zchee/deoplete-jedi', {'for': 'python'} " autocomplete for Python
" autocomplete for Javascript. Need add .tern-project to take effect
"Plug 'carlitux/deoplete-ternjs', { 'for': ['javascript', 'javascript.jsx'], 'commit': '9eaedeab499e2d0a34fba72afa1ff65d34752cbf' }
else
"Plug 'Valloric/YouCompleteMe', { 'do': 'python3 install.py --all' }
Plug 'amerlyq/vim-focus-autocmd' " Add focus event support for vim
endif
"Plug 'othree/jspc.vim', { 'for': ['javascript', 'javascript.jsx'] }
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
" Navigation & Searching
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'jistr/vim-nerdtree-tabs'
Plug 'Shougo/denite.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'Shougo/neomru.vim' " file_mru for Denite
Plug 'Shougo/unite.vim'
" Syntax & hightlight & format
"Plug 'Shutnik/jshint2.vim' " Javascript
Plug 'python-rope/ropevim', {'for': 'python'} " Python
"Plug 'pangloss/vim-javascript'
Plug 'kchmck/vim-coffee-script', {'for': 'coffee'}
" Utils
Plug 'jiangmiao/auto-pairs'
Plug 'scrooloose/nerdcommenter'
Plug 'majutsushi/tagbar'
Plug 'sjl/gundo.vim' " Visualize your Vim undo tree.
Plug 'Yggdroot/indentLine'
Plug 'xolox/vim-misc' "vim-session need to use
Plug 'xolox/vim-session'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'easymotion/vim-easymotion'
Plug 'godlygeek/tabular' " For text filtering and alignment
" Git Related
Plug 'tpope/vim-fugitive'
"Plug 'Xuyuanp/nerdtree-git-plugin'
"Plug 'airblade/vim-gitgutter'
let g:gitgutter_enabled = 0
" Color scheme & layout. Warning: devicons must be loaded last
"Plug 'altercation/vim-colors-solarized'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'ryanoasis/vim-devicons'
"" to be test
Plug 'morhetz/gruvbox'
Plug 'mhinz/vim-startify'
Plug 'tpope/vim-unimpaired'
Plug 'junegunn/gv.vim', { 'for': 'gv' } " A git commit browser
Plug 'terryma/vim-multiple-cursors'
Plug 'w0rp/ale' "Asynchronous syntax checker
Plug 'elzr/vim-json', { 'for': 'json' } " JSON formatter
Plug 'Chiel92/vim-autoformat' " Format framework
Plug 't9md/vim-choosewin'
Plug 'PotatoesMaster/i3-vim-syntax', {'for': 'i3'} " Highlighting for i3wm config
Plug 'dhruvasagar/vim-table-mode'
Plug 'thinca/vim-quickrun'
Plug 'rrethy/vim-hexokinase', { 'do': 'make hexokinase' }
let g:Hexokinase_highlighters = [ 'backgroundfull' ]
"Plug 'ap/vim-css-color'
"Displays function signatures from completions in the command line
"Plug 'Shougo/echodoc.vim'
"let g:echodoc_enable_at_startup = 1
"Plug 'junegunn/goyo.vim', { 'on': 'Goyo' } " Distraction free writing in vim
Plug 'tpope/vim-scriptease'
Plug 'plasticboy/vim-markdown', {'for': 'markdown'}
Plug 'mzlogin/vim-markdown-toc', {'for': 'markdown'} " Generate table of content
Plug 'tenfyzhong/tagbar-markdown.vim', {'for': 'markdown'}
Plug 'dyng/ctrlsf.vim'
Plug 'Yggdroot/LeaderF',{'do':'./install.sh'}
" yajs slow the input down when you type comment
"Plug 'othree/yajs.vim' " javascript syntax hightlight
"Plug 'othree/javascript-libraries-syntax.vim'
Plug 'hail2u/vim-css3-syntax', {'for': 'css'}
Plug 'vim-scripts/BufOnly.vim'
Plug 'MattesGroeger/vim-bookmarks' " bookmark and annotate code
Plug 'hecal3/vim-leader-guide' " vim keymap displaying
Plug 'junegunn/fzf.vim'
"Plug 'Shougo/vimfiler.vim'
"Plug 'ternjs/tern_for_vim', { 'do': 'npm install', 'for': ['javascript', 'javascript.jsx'] }
" Useless Plugins
"Plug 'neomake/neomake'
"Plug 'vim-airline/vim-airline'
"Plug 'vim-airline/vim-airline-themes'
"Plug 'itchyny/vim-cursorword' " Underlines the word under the cursor
"ap/vim-css-colorPlug 'ctrlpvim/ctrlp.vim' " replace kien/ctrlp.vim. this
"works better with devicons
"Plug 'scrooloose/syntastic' " Syntax check framework
" making a column of increasing or decreasing numbers, dates, or daynames.
"Plug 'vim-scripts/VisIncr'
"Plug 'klen/python-mode'
"Plug 'ConradIrwin/vim-bracketed-paste'
"Plug 'Raimondi/delimitMate'
"Plug 'ervandew/supertab'
" Collection of awesome color schemes for Vim
"Plug 'rafi/awesome-vim-colorschemes'
"Plug 'MattesGroeger/vim-bookmarks'
"Plug 'Shougo/junkfile.vim' " Create temporary file for testing or memo
endif
call plug#end()
" Need asign this first before being used
let mapleader=","
" }}}
" Plugin Settings ----------------------------------------------------------{{{
" vim-bookmark {
let g:bookmark_no_default_key_mappings = 1
"let g:bookmark_save_per_working_dir = 1
let g:bookmark_auto_save = 1
nmap <Leader>bt <Plug>BookmarkToggle
nmap <Leader>ba <Plug>BookmarkAnnotate
nmap <Leader>bs <Plug>BookmarkShowAll
nmap <Leader>bc <Plug>BookmarkClear
"nmap <Leader>j <Plug>BookmarkNext
"nmap <Leader>k <Plug>BookmarkPrev
"nmap <Leader>x <Plug>BookmarkClearAll
" }
" others {
nnoremap <leader>cf :CtrlSF<SPACE>
nnoremap <leader>bo :BufOnly<CR>
map <SPACE> <plug>NERDCommenterToggle
" }
" LeaderF {
let g:Lf_ShortcutF = '<leader>l'
let g:Lf_WindowPosition = 'popup'
let g:Lf_PreviewInPopup = 1
let g:Lf_ShowHidden = 1
"let g:Lf_UseVersionControlTool = 0
"let g:Lf_UseCache = 0
"let g:Lf_PythonVersion=2
nnoremap <leader>ll :LeaderfSelf<CR>
nnoremap <leader>c :LeaderfHistoryCmd<CR>
nnoremap <leader>ls :LeaderfHistorySearch<CR>
nnoremap <leader>lf :LeaderfFunction<CR>
nnoremap <leader>lh :LeaderfHelp<CR>
nnoremap <leader>lb :LeaderfBuffer<CR>
nnoremap <leader>lr :LeaderfMru<CR>
let g:Lf_PopupPalette = {
\ 'dark': {
\ 'Lf_hl_cursorline': {
\ 'gui': 'NONE',
\ 'font': 'NONE',
\ 'guifg': '#fabd2f',
\ 'guibg': 'NONE',
\ 'cterm': 'NONE',
\ 'ctermfg': 'NONE',
\ 'ctermbg': '236'
\ },
\ }
\ }
"let g:Lf_ExternalCommand = 'rg "%s" --files --no-ignore --hidden --follow --glob !{.git/,.gvfs,.cache/dconf,.config/chromium,.config/pulse,.config/google-chrome}'
"let g:Lf_UseVersionControlTool = 0
"let g:Lf_WildIgnore = {
"\ 'dir': ['.svn','.git','.hg'],
"\ 'file': ['.gitignore']
"\}
"let g:Lf_CommandMap = {'<C-C>': ['<Esc>', '<C-C>']}
" }
" Goyo {
nnoremap <leader>gy :Goyo<CR>
" }
" junkfile {
nnoremap <leader>jf :JunkfileOpen<CR>
" }
" vim-choosewin {
nmap - <Plug>(choosewin)
"let g:choosewin_overlay_enable = 1
" }
"vim-Plug {
nnoremap <leader>pi :PlugInstall<CR>
nnoremap <leader>pc :PlugClean<CR>
" }
" vim- 2qq::ququickrun {
nnoremap <leader>qr :QuickRun<CR>
" }
" ale {
let g:ale_linters = {
\ 'sh' : ['shellcheck'],
\ 'vim' : ['vint'],
\ 'html' : ['tidy'],
\ 'python' : ['flake8'],
\ 'markdown' : ['mdl'],
\ 'javascript' : ['eslint'],
\}
autocmd User ALELint highlight ALEErrorSign guifg=#fb4934 guibg=#3c3836 gui=bold
autocmd User ALELint highlight ALEWarningSign guifg=#fe8019 guibg=#3c3836 gui=bold
autocmd User ALELint highlight ALEStyleErrorSign guifg=#AF7AC5 guibg=#3c3836 gui=bold
autocmd User ALELint highlight ALEStyleWarningSign guifg=#F9E79F guibg=#3c3836 gui=bold
"highlight ALEErrorSign guifg=#fb4934 guibg=#3c3836
"highlight ALEWarningSign guifg=#fe8019 guibg=#3c3836
"hi! ALEWarningSign ctermbg=003 ctermfg=Black guibg=#504945 guifg=#fabd2f gui=bold
"hi! ALEErrorSign ctermbg=003 ctermfg=Black guibg=#504945 guifg=#fb4934 gui=bold
let g:ale_enabled = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'never'
let g:ale_lint_on_enter = 0
let g:ale_set_highlights = 1
"let g:ale_set_quickfix = 1 " Push info into quicklist instead of loclist
"let g:ale_open_list = 1 " Open loclist or quickfix when ale is triggered
"let g:ale_sign_column_always = 0
let g:ale_echo_msg_format = '[#%linter%#] %s [%severity%]'
"let g:ale_statusline_format = ['E•%d', 'W•%d', 'OK']
"let g:ale_sign_error = ''
"let g:ale_sign_warning = ''
let g:ale_sign_error = '•'
let g:ale_sign_warning = '•'
let g:ale_echo_msg_error_str = '✖ Error'
let g:ale_echo_msg_warning_str = '⚠ Warning'
" For a more fancy ale statusline
"function! ALEGetError()
"let l:res = ale#statusline#Status()
"if l:res ==# 'OK'
"return ''
"else
"let l:e_w = split(l:res)
"if len(l:e_w) == 2 || match(l:e_w, 'E') > -1
"return ' •' . matchstr(l:e_w[0], '\d\+') .' '
"endif
"endif
"endfunction
"function! ALEGetWarning()
"let l:res = ale#statusline#Status()
"if l:res ==# 'OK'
"return ''
"else
"let l:e_w = split(l:res)
"if len(l:e_w) == 2
"return ' •' . matchstr(l:e_w[1], '\d\+')
"elseif match(l:e_w, 'W') > -1
"return ' •' . matchstr(l:e_w[0], '\d\+')
"endif
"endif
"endfunction
" }
" autoformat {
noremap <F6> :Autoformat<CR>
let g:formatters_python = ['yapf']
let g:formatter_yapf_style = 'pep8'
"let g:formatters_javascript = ['eslint']
"let g:formatdef_eslint = '"SRC=eslint-temp-${RANDOM}.js; cat - >$SRC; eslint --fix $SRC >/dev/null 2>&1; cat $SRC | perl -pe \"chomp if eof\"; rm -f $SRC"'
let g:autoformat_verbosemode=1
let g:session_default_to_last = 1
" }
" deoplete {
"if has("nvim") && loadDeoplete == 1
"let g:deoplete#enable_at_startup = 1
"let g:deoplete#enable_ignore_case = 1
"let g:deoplete#enable_smart_case = 1
""let g:deoplete#omni#functions = {}
""let g:deoplete#omni#functions.javascript = [
""\ 'tern#Complete',
""\ 'jspc#omni'
""\]
"if exists('g:deoplete#enable_at_startup')
"let g:deoplete#enable_at_startup = 1
"call deoplete#custom#set('buffer', 'mark', 'ℬ')
"call deoplete#custom#set('ternjs', 'mark', '')
"call deoplete#custom#set('omni', 'mark', '⌾')
"call deoplete#custom#set('file', 'mark', 'file')
"call deoplete#custom#set('jedi', 'mark', '')
"call deoplete#custom#set('javacomplete2', 'mark', '')
"call deoplete#custom#set('typescript', 'mark', '')
"call deoplete#custom#set('ultisnips', 'mark', '')
"endif
"" Set bin if you have many instalations
"let g:deoplete#sources#ternjs#tern_bin = '/usr/bin/tern'
""let g:deoplete#enable_profile = 1
""call deoplete#enable_logging('DEBUG', 'deoplete.log')
""call deoplete#custom#source('tern', 'debug_enabled', 1)
"" Use tern_for_vim.
"let g:tern_show_argument_hints='on_move'
"let g:tern#command = ["tern"]
"let g:tern#arguments = ["--persistent"]
"endif
" }
" vim-session {
nnoremap <Leader>os :OpenSession<CR>
let g:session_autosave = "yes"
let g:session_autoload = "no"
"let g:session_default_to_last = 1
" }
" IndentLine {
let g:indentLine_color_term = 239
let g:indentLine_char = '¦'
" this is for vim-json plugin
autocmd InsertEnter *.json setlocal concealcursor=
autocmd InsertLeave *.json setlocal concealcursor=inc
" }
" NerdTree {
nnoremap <silent> <leader>n :NERDTreeToggle<CR>
" Run NERDTreeTabs on console vim startup
let g:nerdtree_tabs_open_on_console_startup=0
" enable line numbers
let NERDTreeShowLineNumbers=1
" make sure relative line numbers are used
autocmd FileType nerdtree setlocal relativenumber
" }
" YouCompleteMe {
"let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
"let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
"let g:SuperTabDefaultCompletionType = '<C-n>'
" }
" UltiSnips {
" Trigger configuration. Do not use <tab> if you use
" https://github.com/Valloric/YouCompleteMe.
nnoremap <leader>u :UltiSnipsEdit<cr>
let g:UltiSnipsExpandTrigger = '<tab>'
let g:UltiSnipsJumpForwardTrigger = '<tab>'
let g:UltiSnipsJumpBackwardTrigger = '<S-tab>'
let g:UltiSnipsEnableSnipMate = 1
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
" When type UltisnipsEdit, the file will be saved into this dir
"If only one directory is specified in this variable and this directory is
"specified by absolute path, UltiSnips will not look for snippets in
"&runtimepath
let g:UltiSnipsSnippetsDir="~/.vim/MySnips"
" Where UltiSnips find the snip files, the value should be runtimepath
let g:UltiSnipsSnippetDirectories = ['UltiSnips', 'MySnips']
autocmd FileType javascript :UltiSnipsAddFiletypes html<cr>
autocmd FileType html :UltiSnipsAddFiletypes javascript<cr>
" }
" CtrlP {
let g:ctrlp_map = '<Leader>o'
" }
" Eclim {
" Import the class under the cursor with <leader>i
nnoremap <silent> <leader>ji :JavaImportOrganize<cr>
" Search for the javadocs of the element under the cursor with <leader>d
nnoremap <silent> <leader>jd :JavaDocSearch -x declarations<cr>
" Search element under the cursor
autocmd FileType java
\ nnoremap <silent> <buffer> <leader>jr :Java %<cr>
nnoremap <silent> <leader>js :JavaSearchContext<cr>
"nnoremap <silent> <leader>r :Java %<cr>
" }
" Easymotion {
"map <SPACE><SPACE> <Plug>(easymotion-f)
"map <leader>f <Plug>(easymotion-F)
map f <Plug>(easymotion-f)
map F <Plug>(easymotion-F)
map t <Plug>(easymotion-t)
map T <Plug>(easymotion-T)
map fj <Plug>(easymotion-j)
map fk <Plug>(easymotion-k)
let g:EasyMotion_smartcase = 1
"let g:EasyMotion_do_mapping = 1
" 1 will match 1 and !; ! matches !
let g:EasyMotion_use_smartsign_us = 1 " US layout
" }
" tern for vim {
" document.getele
"let tern_show_signature_in_pum = 1
"let tern_show_argument_hints = 'on_hold'
"autocmd FileType javascript nnoremap <leader>d :TernDef<CR>
"autocmd FileType javascript setlocal omnifunc=tern#Complete
" Close preview window when autocomplete finished
"autocmd CompleteDone * pclose
" Don't open preview window at all
autocmd BufEnter * set completeopt-=preview
" }
" Syntastic {
"nnoremap <silent> <Leader>c :SyntasticCheck<CR>
"nnoremap <silent> <Leader>ct :SyntasticToggleMode<CR>
"let g:syntastic_javascript_checkers = ['jshint']
"let g:syntastic_python_checkers = ['flake8']
"let g:syntastic_python_flake8_args='--ignore=E126,E127'
"let g:syntastic_javascript_closurecompiler_path = '~/.vim/closure-compiler.jar'
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*
"let g:syntastic_always_populate_loc_list = 1
"let g:syntastic_auto_loc_list = 1
"let g:syntastic_check_on_open = 1
"let g:syntastic_error_symbol = '•'
"let g:syntastic_warning_symbol = '•'
" }
" ropevim {
" ----------------------------------------------------------------------------
" ropevim_for_vim
" ----------------------------------------------------------------------------
"let ropevim_local_prefix='<Leader>t'
"
let ropevim_vim_completion=1
let ropevim_extended_complete=1
let ropevim_codeassist_maxfixes=1
let ropevim_goto_def_newwin="tabnew"
let ropevim_autoimport_modules = ["os.*","traceback", "xml.etree"]
"imap <c-space> <C-R>=RopeCodeAssistInsertMode()<CR>
autocmd FileType python
\ noremap <silent> <buffer> <C-]> :RopeGotoDefinition<CR>
" }
" Gundo {
"nnoremap <F5> :GundoToggle<CR>
" }
" Tagbar {
nnoremap <F8> :TagbarToggle<CR>
"let g:tagbar_type_markdown = {
"\ 'ctagstype' : 'markdown',
"\ 'kinds' : [
"\ 'h:Heading_L1',
"\ 'i:Heading_L2',
"\ 'k:Heading_L3'
"\ ]
"\ }
"let g:tagbar_type_javascript = {
"\ 'ctagstype': 'javascript',
"\ 'kinds': [
"\ 'c:classes',
"\ 'n:modules',
"\ 'f:functions',
"\ 'v:variables',
"\ 'v:varlambdas',
"\ 'm:members',
"\ 'i:interfaces',
"\ 'e:enums',
"\ ],
"\ 'sort':0,
"\'deffile':expand('<sfile>:p:h:h') . '/.ctags'
"\ }
" }
" devicons & nerdtree syntax highlight {
" loading the plugin
let g:WebDevIconsOS = 'Darwin'
let g:webdevicons_enable = 1
let g:webdevicons_enable_ctrlp = 1
let g:webdevicons_enable_unite = 1
let g:webdevicons_enable_denite = 0
let g:webdevicons_enable_vimfiler = 0
" 去掉图标后面灰色的背景
autocmd FileType nerdtree setlocal nolist
let g:NERDTreeFileExtensionHighlightFullName = 1
let g:NERDTreeExactMatchHighlightFullName = 1
let g:NERDTreePatternMatchHighlightFullName = 1
" enables folder icon highlighting using exact match
let g:NERDTreeHighlightFolders = 1
let g:NERDTreeHighlightFoldersFullName = 1 " highlights the folder name
" Show the folder icons
let g:WebDevIconsUnicodeDecorateFolderNodes = 0
" }
" markdown {
let g:table_mode_corner="|"
" }
" }}}
if loadSysSetting == 1
" System Settings ---------------------------------------------------------{{{
" The default leader is '\', but many people prefer ',' as it's in a
" standard location
let mapleader=","
" General ---------------------------------------------------{{{
syntax enable
syntax on
set mouse=a " Automatically enable mouse usage
set mousehide " Hide the mouse cursor while typing
scriptencoding utf-8
set encoding=utf8
set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter')
set viewoptions=folds,options,cursor,unix,slash " Better Unix / Windows compatibility
set virtualedit=onemore " Allow for cursor beyond last character
set history=5000 " Store a ton of history (default is 20)
"set spell " Spell checking on
set hidden " Allow buffer switching without saving
set iskeyword-=. " '.' is an end of word designator
set iskeyword-=# " '#' is an end of word designator
set iskeyword-=- " '-' is an end of word designator
set autoread " Set to auto read when a file is changed from the outside
set fileencodings=utf-8,gbk,cp936,latin-1
filetype on
set updatetime=250
" }}}
" Vim UI ---------------------------------------------------{{{
set number " Line numbers on
set background=dark
set colorcolumn=80 " 80个字符的限制
"let g:solarized_termcolors=256
"let g:solarized_termtrans=1
"let g:solarized_contrast="normal"
"let g:solarized_visibility="normal"
" 256 colors setting for nvim
set termguicolors
set t_Co=256
"let &t_8f = "[38;2;%lu;%lu;%lum"
"let &t_8b = "[48;2;%lu;%lu;%lum"
let g:gruvbox_italic=1
" soft, medium, hard
let g:gruvbox_contrast_dark='medium'
silent! colorscheme gruvbox
set tabpagemax=15 " Only show 15 tabs
set showmode " Display the current mode
"if !has("nvim")
set cursorline " Highlight current line
hi CursorLine term=bold cterm=bold guibg=#3C3836
"endif
if has('cmdline_info')
set ruler " Show the ruler
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " A ruler on steroids
set showcmd " Show partial commands in status line and
" Selected characters/lines in visual mode
endif
set backspace=indent,eol,start " Backspace for dummies
set showmatch " Show matching brackets/parenthesis
set incsearch " Find as you type search
set hlsearch " Highlight search terms
set winminheight=0 " Windows can be 0 line high
set ignorecase " Case insensitive search
set smartcase " case sensitive when uc present
set wildignorecase " Case insensitive when type command
set wildmenu " Show list instead of just completing
set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all.
set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
set scrolljump=5 " Lines to scroll when cursor leaves screen
set scrolloff=3 " Minimum lines to keep above and below cursor
set nofoldenable "启动vim时关闭代码折叠
set list
set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
set cmdheight=2
set hid
" This option will delay cursor line scroll
"set lazyredraw
set magic
set mat=2
" No annoying sound on errors
set noerrorbells
set novisualbell
set tm=500
" 相对行号: 行号变成相对,可以用 nj/nk 进行跳转
"if !has('nvim')
"set relativenumber number
"autocmd FocusLost * :set norelativenumber number
"autocmd FocusGained * :set relativenumber
"" 插入模式下用绝对行号, 普通模式下用相对
"autocmd InsertEnter * :set norelativenumber number
"autocmd InsertLeave * :set relativenumber
"function! NumberToggle()
"if(&relativenumber == 1)
"set norelativenumber number
"else
"set relativenumber
"endif
"endfunc
"nnoremap <F2> :call NumberToggle()<CR>
"endif
" Turn off highlight until next search
nnoremap <F4> :noh<CR>
" Remember cursor position between vim sessions
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
" center buffer around cursor when opening files
autocmd BufRead * normal zz
" }}}
" Formatting ---------------------------------------------------{{{
set wrap " Wrap long lines
set autoindent " Indent at the same level of the previous line
set shiftwidth=4 " Use indents of 4 spaces
set expandtab " Tabs are spaces, not tabs
set tabstop=4 " An indentation every four columns
set softtabstop=4 " Let backspace delete indent
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
set splitright " Puts new vsplit windows to the right of the current
set splitbelow " Puts new split windows to the bottom of the current
"set linespace=5 " 字符间插入的像素行数目,only work for gvim
" set fillchar
"hi VertSplit ctermbg=NONE guibg=NONE
hi VertSplit guibg=#282828 guifg=#181A1F
set fillchars+=vert:│
"set fillchars=vert:\ ,stl:\ ,stlnc:\ " 在被分割的窗口间显示空白,便于阅读
"set matchpairs+=<:> " Match, to be used with %
set pastetoggle=<F12> " pastetoggle (sane indentation on pastes)
"set comments=sl:/*,mb:*,elx:*/ " auto format comment blocks
" Remove trailing whitespaces and ^M chars
" To disable the stripping of whitespace, add the following to your
" .vimrc.before.local file:
autocmd FileType vim,c,cpp,java,go,php,javascript,puppet,python,rust,twig,xml,yml,perl,sql autocmd BufWritePre <buffer> call StripTrailingWhitespace()
autocmd FileType haskell,puppet,ruby,yml setlocal expandtab shiftwidth=2 softtabstop=2
autocmd FileType haskell setlocal commentstring=--\ %s
autocmd FileType java set tags=~/dev/jdk1.8.0_40/src/.tags
" }}}
" Files Backup Undo ----------------------------------------------{{{
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile
let g:vim_json_syntax_conceal = 1
"let $BASH_ENV = "/home/damon/.config/nvim/vim_bash"
" }}}
" }}}
endif
if loadKeyMapping == 1
" Key Mappings -------------------------------------------------------------{{{
" Key (re)mappings {
"Exit insert mode
nnoremap <leader>ms :messages<CR>
" No need for ex mode
nnoremap Q <nop>
"nnoremap q: <nop>
nnoremap <SPACE><SPACE> i<SPACE><ESC>
" Navigate between display lines
noremap <silent> k gk
noremap <silent> j gj
" 跳转到行首和行位的非空字符
noremap H ^
noremap L g_
noremap J 5j
noremap K 5k
noremap <Leader>j J
" go to Previous buffer
noremap gb <C-^>
nnoremap ' ;
nnoremap ; :
nnoremap p p=`]
" Copy & paste to system clipboard
vmap <Leader>y "+y
nmap <Leader>y :echo("good")<CR>
nmap <Leader>yy "+yy
vmap <Leader>p "+p
nmap <Leader>p "+p
nmap <Leader>dd "+dd
vmap <Leader>d "+d
" Insert a new line without entering insert mode
"nnoremap <silent><C-j> :set paste<CR>m`o<Esc>``:set nopaste<CR>
"nnoremap <silent><C-k> :set paste<CR>m`O<Esc>``:set nopaste<CR>
nnoremap <silent><C-j> :set paste<CR>o<Esc>:set nopaste<CR>
nnoremap <silent><C-k> :set paste<CR>O<Esc>:set nopaste<CR>
"set timeout timeoutlen=300 ttimeoutlen=100
" <S-CR> doesn't work. Known issue
"nmap <S-CR> O<ESC>j
" Switch between buffers. Since CtrlP use <c-p>, it's not available.
" Also,<C-S-n> is occupied by system.
" Aborted. <C-n> was occupied by vim-multi-cursors
"nnoremap <C-n> :bnext<CR>
"nnoremap <C-p> :bprevious<CR>
" Close stuffs
" Close buffer
nnoremap <leader>xb :bp<cr>:bd #<cr>
" Close window
nnoremap <leader>xw :q<cr>
nnoremap <leader>w :wall<cr>
nnoremap <leader>s :%s/
" Select all
nnoremap <C-a> ggVG
" Scroll up half page
nnoremap <C-s> <C-u>
" Command line mode 命令行模式增强 ---------------{{{
"cnoremap <C-h> <backspace>
cnoremap <C-n> <Down>
cnoremap <C-p> <Up>
cnoremap <C-d> <Del>
" to begin of command line
cnoremap <C-a> <Home>
"cnoremap <C-e> <End>
" to begin of command line
if !has('nvim')
execute "set <M-b>=\eb"
execute "set <M-f>=\ef"
endif
cnoremap <M-b> <S-Left>
" one word right
cnoremap <M-f> <S-Right>
" Previous cmd based on input
cnoremap <C-k> <Up>
" Next cmd based on input
cnoremap <C-j> <Down>
" Cursor left
cnoremap <C-b> <Left>
" cursor right
cnoremap <C-f> <Right>
" }}}
" Adjust current window's size
nmap <Down> <C-W>6-
nmap <Up> <C-W>6+
nmap <Left> <C-W>10>
nmap <Right> <C-W>10<
" Auto save current buffer when leave insert mode
function! Autosave()
if !empty(&filetype) && &filetype !=# 'ctrlsf'
call StripTrailingWhitespace()
update
endif
endfunction
autocmd InsertLeave * call Autosave()
" Shortcut for opening .vimrc
nmap <leader>v :e $MYVIMRC<CR>
nnoremap <leader>sv :source $MYVIMRC<CR>
" }}}
endif
if loadFold == 1
" Fold 代码折叠 ------------------------------------------------------------{{{
" 启用标记折叠。所有文本将按照特定标记(默认为{{{和}}})自动折叠。
" 开启本选项在有代码折叠的脚本里,高亮行会产生延迟,需要:set nofoldenable
autocmd FileType vim setlocal foldmethod=marker
" foldlevel 0 代表全部折叠都生效,1:部分生效,99:不折叠
autocmd FileType vim setlocal foldlevel=0
autocmd FileType python setlocal foldmethod=indent
autocmd FileType css,scss setlocal foldmethod=marker
autocmd FileType css,scss setlocal foldmarker={,}
autocmd FileType javascript,typescript,json set foldmethod=syntax
" }}}
endif
if loadFunc == 1
" Functions ----------------------------------------------------------------{{{
" function {
function! StripTrailingWhitespace()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" do the business:
%s/\s\+$//e
" clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
"##### auto fcitx ###########
let g:input_toggle = 1
function! Fcitx2en()
let s:input_status = system("fcitx-remote")
if s:input_status == 2
let g:input_toggle = 1
let l:a = system("fcitx-remote -c")
endif
endfunction
"function! Fcitx2zh()
"let s:input_status = system("fcitx-remote")
"if s:input_status != 2 && g:input_toggle == 1
"let l:a = system("fcitx-remote -o")
"let g:input_toggle = 0
"endif
"endfunction
set ttimeoutlen=150
"退出插入模式
" FocusGained doesn't work for vim, only for nvim and gvim Need extra plugin
autocmd InsertLeave,FocusGained * call Fcitx2en()
"进入插入模式
"autocmd InsertEnter * call Fcitx2zh()
"##### auto fcitx end ######
" }
" }}}
endif
if loadNvim == 1
" neovim settings ----------------------------------------------------------{{{
if has("nvim")
"set inccommand=split
let g:python_host_prog = '/usr/bin/python2'
let g:python3_host_prog = '/usr/bin/python3'
" terminal 'normal mode'
tmap kj <c-\><c-n><esc><cr>
endif
" }}}
endif
if loadDenite == 1
" Denite --------------------------------------------------------------------{{{
let s:menus = {}
" statusline=0 is nesessary if you want to custom statusline
call denite#custom#option('_', {
\ 'prompt': '❯',
\ 'winheight': 55,
\ 'reversed': 1,
\ 'highlight_matched_char': 'Underlined',
\ 'highlight_mode_normal': 'CursorLine',
\ 'updatetime': 1,
\ 'auto_resize': 1,
\ 'statusline' : 0,
\})
"call denite#custom#option('TSDocumentSymbol', {
"\ 'prompt': ' @' ,
"\ 'reversed': 0,
"\})
"
"call denite#custom#var('file_rec', 'command',
"\ ['rg', '--files', '--glob', '!.git', ''])
" 添加-u选项,因为rg会检索所有文件夹下的gitignore和ignore文件,包括父文件夹的
" -u表示忽略这两个文件的设置
" --hidden : Search hidden directories and files. (Hidden directories and files are skipped by default.)
" --files : Print each file that would be searched (but don't search).
call denite#custom#var('file_rec',
\ 'command',['rg', '--hidden', '--files', '--glob',
\ '!{.git/,.gvfs,.cache/dconf,.config/chromium,.config/pulse,.config/google-chrome}',
\ '--no-ignore'
\])
call denite#custom#source('file_rec', 'sorters', ['sorter_sublime'])
call denite#custom#var('grep', 'command', ['rg'])
call denite#custom#source('grep', 'matchers', ['matcher_regexp'])
call denite#custom#filter('matcher_ignore_globs', 'ignore_globs',
\ [ '.git/', '.gvfs/', '.ropeproject/', '__pycache__/',
\ 'venv/', 'images/', '*.min.*', 'img/', 'fonts/'])
" --no-heading : Don't group matches by each file. Then file names will be shown for every line matched.
" --vimgrep : Show results with every match on its own line, including line numbers and column numbers.
" With this option, a line with more than one match will be printed more than once.
call denite#custom#var('grep', 'default_opts', ['--vimgrep', '--hidden', '--no-heading', '--no-ignore'])
call denite#custom#var('grep', 'recursive_opts', [])
call denite#custom#var('grep', 'pattern_opt', ['--regexp'])
call denite#custom#var('grep', 'separator', ['--'])
call denite#custom#var('grep', 'final_opts', [])
nnoremap <silent> <leader>df :Denite file_rec<CR>
nnoremap <silent> <leader>dg :Denite grep<CR>
nnoremap <silent> <leader>dl :Denite line<CR>
nnoremap <silent> <leader>dr :Denite file_mru<CR>
nnoremap <silent> <leader>dh :Denite help<CR>
"nnoremap <silent> <Leader>i :Denite menu:ionic <CR>
call denite#custom#map('insert','<C-j>','<denite:move_to_next_line>','noremap')
call denite#custom#map('insert','<C-k>','<denite:move_to_previous_line>','noremap')
call denite#custom#filter('matcher_ignore_globs', 'ignore_globs',
\ [ '.git/', '.ropeproject/', '__pycache__/',
\ 'venv/', 'images/', '*.min.*', 'img/', 'fonts/'])
call denite#custom#var('menu', 'menus', s:menus)
"}}}
endif
if loadAirline == 1
" Airline -----------------------------------------------------------------{{{
" When complete option was triggered, a scratch window will display.
" When work with airline, a new buffer named [no nam] will be created
" displaying same content with scratch window. This will lead to a
" flickering when cycling complete options
"let g:airline_theme='violet'
"let g:airline_theme='badwolf'
"let g:airline#extensions#tabline#show_tab_nr = 1
let g:damonvim_airline_enable = 1
if g:damonvim_airline_enable == 0
set completeopt-=preview
let g:airline_powerline_fonts=1
let g:airline#extensions#tabline#tab_nr_type= 2
let g:airline#extensions#tabline#show_tab_type = 1
let g:airline#extensions#tabline#buffers_label = 'BUFFERS'
let g:airline#extensions#tabline#tabs_label = 'TABS'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_idx_mode = 1
let g:airline#extensions#tabline#buffer_idx_format = {
\ '0': '0 ',
\ '1': '➊ ',
\ '2': '➋ ',
\ '3': '➌ ',
\ '4': '➍ ',
\ '5': '➎ ',
\ '6': '➏ ',
\ '7': '➐ ',
\ '8': '➑ ',
\ '9': '➒ ',
\}
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>4 <Plug>AirlineSelectTab4
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9
let g:airline_section_c='win[%{tabpagewinnr(tabpagenr())}]'
endif
nnoremap <silent> <SPACE>1 :1wincmd w<CR>
nnoremap <silent> <SPACE>2 :2wincmd w<CR>
nnoremap <silent> <SPACE>3 :3wincmd w<CR>
nnoremap <silent> <SPACE>4 :4wincmd w<CR>
nnoremap <silent> <SPACE>5 :5wincmd w<CR>
nnoremap <silent> <SPACE>6 :6wincmd w<CR>
nnoremap <silent> <SPACE>7 :7wincmd w<CR>
nnoremap <silent> <SPACE>8 :8wincmd w<CR>
nnoremap <silent> <SPACE>9 :9wincmd w<CR>
"function! s:bubble_num(num, type) abort
"let list = []
"call add(list,['➊', '➋', '➌', '➍', '➎', '➏', '➐', '➑', '➒', '➓'])
"call add(list,['➀', '➁', '➂', '➃', '➄', '➅', '➆', '➇', '➈', '➉'])
"call add(list,['⓵', '⓶', '⓷', '⓸', '⓹', '⓺', '⓻', '⓼', '⓽', '⓾'])
"let n = ''
"try
"let n = list[a:type][a:num-1]
"catch
"endtry
"return n
"endfunction