-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
executable file
·1879 lines (1646 loc) · 59.4 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
" From http://blog.csdn.net/redguardtoo/article/details/1172136 by redguardtoo
" Demo: http://www.cnblogs.com/zhongcq/p/3642794.html#toc_1.17
" Originally by Amix - http://amix.dk/
" Maintainer: Amir Salihefendic <amix3k at gmail.com>
" Version: 2.0
" Last Change: 12/08/06 13:39:28
" Fixed win32 compatible by: redguardtoo <chb_sh at gmail.com>
" This vimrc file is tested on platforms like win32,linux, cygwin,mingw
" and vim7.0, vim6.4, vim6.1, vim5.8.9 by redguardtoo
"
" Tip:
" If you find anything that you can't understand than do this:
" help keyword OR helpgrep keyword
" Example:
" Go into command-line mode and type helpgrep nocompatible, ie.
" :helpgrep nocompatible
" then press <leader>c to see the results, or :botright cw
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Default shortcuts can be referred by http://blog.csdn.net/donahue_ldz/article/details/17139361
"Get out of VI's compatible mode..
"set noesckeys
set fileformat=unix
"-->vundle YCM
set nocompatible " be iMproved
filetype off " required!
" set rtp+=~/.vim/bundle/vundle/
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#rc()
" let Vundle manage Vundle
" required!
" ============ncm2=============>
"缓存
autocmd BufEnter * call ncm2#enable_for_buffer()
" 补全模式,具体详情请看下文
set completeopt=noinsert,menuone,noselect
set shortmess+=c
inoremap <c-c> <ESC>
" 延迟弹窗,这样提示更加流畅
let ncm2#popup_delay = 5
"输入几个字母开始提醒:[[最小优先级,最小长度]]
"如果是输入的是[[1,3],[7,2]],那么优先级在1-6之间,会在输入3个字符弹出,如果大于等于7,则2个字符弹出----优先级概念请参考文档中 ncm2-priority
let ncm2#complete_length = [[1, 1]]
"模糊匹配模式,详情请输入:help ncm2查看相关文档
let g:ncm2#matcher = 'substrfuzzy'
"使用tab键向下选择弹框菜单
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
"使用shift+tab键向上选择弹窗菜单,这里不设置因为笔记本比较难操作.如果向下太多我通常习惯使用Backspace键再重新操作一遍
"inoremap <expr> <S> pumvisible() ? "\<C-p>" : "\<S>"
" <============ncm2=============
if executable('pylsp')
" pip install python-lsp-server
au User lsp_setup call lsp#register_server({
\ 'name': 'pylsp',
\ 'cmd': {server_info->['pylsp']},
\ 'allowlist': ['python'],
\ })
endif
if executable('clangd')
augroup lsp_clangd
autocmd!
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'clangd',
\ 'cmd': {server_info->['clangd']},
\ 'allowlist': ['c', 'cpp'],
\ 'whitelist': ['c', 'cpp'],
\ 'semantic_highlight': {
\ 'entity.name.function.cpp':'Function',
\ 'entity.name.function.method.cpp':'Function',
\ 'entity.name.type.enum.cpp':'Identifier',
\ 'entity.name.type.class.cpp':'Identifier',
\ 'meta.disabled':'Comment'
\ }})
autocmd FileType c setlocal omnifunc=lsp#complete
autocmd FileType cpp setlocal omnifunc=lsp#complete
autocmd FileType objc setlocal omnifunc=lsp#complete
autocmd FileType objcpp setlocal omnifunc=lsp#complete
augroup end
endif
function! s:on_lsp_buffer_enabled() abort
setlocal omnifunc=lsp#complete
setlocal signcolumn=yes
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
nmap <buffer> gd <plug>(lsp-definition)
nmap <buffer> gs <plug>(lsp-document-symbol-search)
nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
nmap <buffer> gr <plug>(lsp-references)
nmap <buffer> gi <plug>(lsp-implementation)
nmap <buffer> gt <plug>(lsp-type-definition)
nmap <buffer> <leader>rn <plug>(lsp-rename)
nmap <buffer> [g <plug>(lsp-previous-diagnostic)
nmap <buffer> ]g <plug>(lsp-next-diagnostic)
nmap <buffer> K <plug>(lsp-hover)
"nnoremap <buffer> <expr><c-f> lsp#scroll(+4)
"nnoremap <buffer> <expr><c-d> lsp#scroll(-4)
let g:lsp_format_sync_timeout = 1000
autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')
" refer to doc to add more commands
endfunction
augroup lsp_install
au!
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END
call plug#begin()
Plug 'bfrg/vim-cpp-modern'
" <-- LSP start
Plug 'williamboman/mason.nvim'
Plug 'williamboman/mason-lspconfig.nvim'
Plug 'neovim/nvim-lspconfig'
Plug 'wincent/command-t'
"Plug 'mfulz/cscope.nvim'
Plug 'folke/which-key.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'ibhagwan/fzf-lua'
Plug 'nvim-tree/nvim-web-devicons'
Plug 'dhananjaylatkar/cscope_maps.nvim'
Plug 'ludovicchabant/vim-gutentags'
Plug 'nvim-lua/completion-nvim'
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
" (Optional) Multi-entry selection UI.
Plug 'junegunn/fzf'
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-path'
Plug 'ncm2/ncm2-jedi'
Plug 'nvim-lua/lsp-status.nvim'
" <-- LSP stop
Plugin 'octol/vim-cpp-enhanced-highlight'
Plugin 'bfrg/vim-cpp-modern'
Plugin 'gmarik/Vundle.vim'
Plugin 'hari-rangarajan/CCTree'
Plugin 'w0rp/ale'
"Plugin 'VundleVim/Vundle.vim'
Bundle 'tenfyzhong/tagbar-proto.vim'
Bundle 'pseewald/nerdtree-tagbar-combined'
Bundle 'uarun/vim-protobuf'
Bundle 'majutsushi/tagbar'
"Bundle 'taglist.vim'
Bundle 'winmanager'
Bundle 'gmarik/vundle'
" highlight in tmux
Bundle 'keith/tmux.vim'
Bundle 'marijnh/tern_for_vim'
Plugin 'Shougo/unite.vim'
Plugin 'devjoe/vim-codequery'
Plugin 'mileszs/ack.vim'
filetype plugin indent on " required!
" My Bundles here: /* 插件配置格式 */
"
" vim-scripts repos (vim-scripts仓库里的,按下面格式填写)
"Bundle 'lookupfile'
Bundle 'genutils'
Bundle 'xml.vim'
Bundle 'indentpython.vim'
"http://www.cnblogs.com/fstang/archive/2012/12/05/2803964.html
"snipMate用于补全很多模式
"这个插件只用了一个键,就是TAB键,比如对一个C/C++文件,输入inc,再按TAB键,就会填充为#include
"<stdio.h>,同时stdio被选中,以备修改。还有其他的,如main+TAB,
"wh+TAB,do+TAB,for+TAB,forr+TAB,if+TAB……具体可以看snippets文件夹下的那些文件,比如c.snippets
"snippets已经被UltiSnips代替
"Bundle 'snipMate'
Bundle 'a.vim'
Bundle 'fholgado/minibufexpl.vim'
"Deprecated Mark; use vim-mark instead
"Bundle 'Mark'
Bundle 'inkarkat/vim-ingo-library'
Bundle 'inkarkat/vim-mark'
Bundle 'echofunc.vim'
Bundle 'Visual-Mark'
Plugin 'yegappan/grep'
Bundle 'L9'
"Bundle 'FuzzyFinder'
"Supertab容易引起tab只是补全无法缩进的问题
"Bundle 'SuperTab'
Bundle 'ctags.vim'
Bundle 'DoxygenToolkit.vim'
"优先用下面的那个Bundle 'SirVer/ultisnips'
"Bundle 'UltiSnips'
Bundle 'ShowMarks'
Bundle 'python.vim'
Bundle 'XML-Folding'
" original repos on github (Github网站上非vim-scripts仓库的插件,按下面格式填写)
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/nerdcommenter'
Bundle 'tpope/vim-pathogen'
Bundle 'Valloric/YouCompleteMe'
Bundle 'SirVer/ultisnips'
Bundle 'honza/vim-snippets'
Bundle 'terryma/vim-multiple-cursors'
Bundle 'nvie/vim-flake8'
Bundle 'Chiel92/vim-autoformat'
Bundle 'slim-template/vim-slim'
"Bundle 'brookhong/DBGPavim'
"Bundle 'joonty/vdebug'
"For python fold recommended by
"https://realpython.com/blog/python/vim-and-python-a-match-made-in-heaven/
Bundle 'tmhedberg/SimpylFold'
"Javascript highlight
Bundle 'pangloss/vim-javascript'
Bundle 'gregsexton/MatchTag'
Plugin 'davidhalter/jedi-vim'
Bundle 'jiangmiao/auto-pairs'
"Bundle 'fishman/ctags'
"Bundle 'tpope/vim-fugitive'
"Bundle 'Lokaltog/vim-easymotion'
"Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
"Bundle 'tpope/vim-rails.git'
Plugin 'fatih/vim-go'
Plugin 'Blackrush/vim-gocode'
"Indent related
"https://www.arthurkoziel.com/setting-up-vim-for-yaml/
Plugin 'Yggdroot/indentLine'
Plugin 'pedrohdz/vim-yaml-folds'
"删除行末空格
Bundle 'bronson/vim-trailing-whitespace'
map <leader><space> :FixWhitespace<cr>
"Plugin 'dense-analysis/ale'
" non github repos (非上面两种情况的,按下面格式填写)
"Bundle 'git://git.wincent.com/command-t.git'
"当你自己写了个定制的插件,放在本地的时候
call plug#end()
let g:LanguageClient_serverCommands = {
\ 'python': ['/usr/local/python3/bin/pylsp'],
\ 'go': ['gopls'],
\ 'cpp': ['clangd', '--log-file=/tmp/clangd.log']
\ }
lua << EOF
require("mason").setup({
ui = {
icons = {
package_installed = "✓",
package_pending = "➜",
package_uninstalled = "✗"
}
}
})
require("mason-lspconfig").setup{
ensure_installed = { "pylsp", "clangd", 'gopls' },
}
require("cscope_maps").setup()
local lsp_status = require('lsp-status')
local completion = require('completion')
local configs = require('lspconfig')
configs.clangd.setup{}
configs.pylsp.setup{
on_attach = custom_attach,
settings = {
pylsp = {
plugins = {
-- formatter options
black = { enabled = true },
autopep8 = { enabled = false },
yapf = { enabled = false },
-- linter options
pylint = { enabled = true, executable = "pylint" },
pyflakes = { enabled = false },
pycodestyle = { enabled = false },
ruff = { enabled = true },
-- type checker
pylsp_mypy = { enabled = true },
-- auto-completion options
jedi_completion = { fuzzy = true },
-- import sorting
pyls_isort = { enabled = true },
},
},
},
flags = {
debounce_text_changes = 200,
},
capabilities = capabilities,
}
configs.gopls.setup{
on_attach = on_attach,
capabilities = lsp_status.capabilities,
settings = {
gopls = {
usePlaceholders = true,
codelenses = {
upgrade_dependency = true,
test = true
},
experimentalWorkspaceModule = true
}
}
}
EOF
" Run gofmt on save
autocmd BufWritePre *.go :call LanguageClient#textDocument_formatting_sync()
"https://github.com/autozimu/LanguageClient-neovim/blob/next/doc/LanguageClient.txt
"full list of Plug mappings is:
"*(lcn-menu)*
"Calls LanguageClient_contextMenu.
"*(lcn-hover)*
"Calls LanguageClient_textDocument_hover.
"*(lcn-rename)*
"Calls LanguageClient_textDocument_rename.
"*(lcn-definition)
"Calls LanguageClient_textDocument_definition.
"*(lcn-type-definition)*
"Calls LanguageClient_textDocument_typeDefinition.
"*(lcn-references)*
"Calls LanguageClient_textDocument_references.
"*(lcn-implementation)*
"Calls LanguageClient_textDocument_implementation.
"*(lcn-code-action)*
"Calls LanguageClient_textDocument_codeAction if called in normal model or
"LanguageClient_textDocument_visualCodeAction if called in visual mode.
"*(lcn-code-lens-action)*
"Calls LanguageClient_handleCodeLensAction.
"*(lcn-symbols)*
"Calls LanguageClient_textDocument_documentSymbol.
"*(lcn-highlight)*
"Calls LanguageClient_textDocument_documentHighlight.
"*(lcn-explain-error)*
"Calls LanguageClient_textDocument_explainErrorAtPoint.
"*(lcn-format)*
"Calls LanguageClient_textDocument_formatting.
"*(lcn-format-sync)*
"Calls LanguageClient_textDocument_formatting_sync.
"*(lcn-diagnostics-next)*
"Calls LanguageClient_diagnosticsNext.
"*(lcn-diagnostics-prev)*
"Calls LanguageClient_diagnosticsPrevious.
"nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
"nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nmap <C-\>g <Plug>(lcn-definition)
nmap <C-\>s <Plug>(lcn-references)
nmap <C-\>t <Plug>(lcn-symbols)
"nmap <C-\>s <Plug>(lcn-references)
" Brief help
" :BundleList - list configured bundles
" :BundleInstall(!) - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..
" python 模板在https://gist.github.com/locojay/4950253
let g:ycm_global_ycm_extra_conf = '$HOME/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py'
"if !empty(glob("./.ycm_extra_conf.py"))
"let g:ycm_global_ycm_extra_conf = './.ycm_extra_conf.py'
"endif
"<---YCM
set nocompatible
set autowrite
function! MySys()
if has("win32")
return "win32"
elseif has("unix")
return "unix"
else
return "mac"
endif
endfunction
"Set shell to be bash
if MySys() == "unix" || MguioptionsySys() == "mac"
set shell=bash
else
"I have to run win32 python without cygwin
"set shell=E:cygwiinsh
endif
"Sets how many lines of history VIM har to remember
set history=400
"Enable filetype plugin
filetype off
if has("eval") && v:version>=600
filetype plugin on
filetype indent on
endif
"Set to auto read when a file is changed from the outside
if exists("&autoread")
set autoread
endif
"Have the mouse enabled all the time:
set mouse=cv
"Set mapleader
let mapleader = ","
let g:mapleader = ","
"Fast saving
nmap <leader>w :w!<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Font
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"http://www.cnblogs.com/ifantastic/p/3524751.html
"set term=ansi
" Use color syntax highlighting.
syntax on
" Color specifications. Change them as you would like.
hi Comment term=none ctermfg=gray guifg=Gray
hi Constant term=underline ctermfg=cyan guifg=Cyan
hi Identifier term=underline ctermfg=green guifg=White
hi Statement term=bold ctermfg=white guifg=White
hi PreProc term=underline ctermfg=magenta guifg=Magenta
hi Type term=underline ctermfg=white guifg=White
hi Special term=bold ctermfg=blue guifg=Blue
hi Nontext term=bold ctermfg=red guifg=Red
hi Normal guifg=Yellow guibg=#00007F
hi Normal ctermfg=darkgreen
hi Comment cterm=none gui=none
hi Constant cterm=bold gui=none
hi Identifier cterm=none gui=none
hi Statement cterm=bold gui=none
hi PreProc cterm=bold gui=none
hi Type cterm=bold gui=none
hi Special cterm=bold gui=none
hi NonText cterm=bold gui=none
" Special highlighting for XML
hi xmlTag ctermfg=blue cterm=bold guifg=white
hi xmlTagName ctermfg=blue cterm=bold guifg=white
hi xmlEndTag ctermfg=blue cterm=bold guifg=white
" set guifont=Droid\ Sans\ Mono\ 14
"internationalization
"I only work in Win2k Chinese version
if has("multi_byte")
"set tenc=utf-8,gbk
set fencs=utf-8,gbk
set termencoding=utf-8
set encoding=utf-8
"set fileencodings=ucs-bom,utf-8,chinese
"set fileencoding=gb18030
set fileencoding=utf-8
"set fileencodings=utf-8,gb18030,utf-16,big5
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
endif
"if you use vim in tty,
"'uxterm -cjk' or putty with option 'Treat CJK ambiguous characters as wide' on
if exists("&ambiwidth")
set ambiwidth=double
endif
if has("gui_running")
"set guioptions-=m
set guioptions-=T
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R
if MySys()=="win32"
"start gvim maximized
if has("autocmd")
au GUIEnter * simalt ~x
endif
endif
"let psc_style='cool'
"sudo cp ~/.vim/color/desert_my.vim /usr/share/vim/vim73/colors/
"colorscheme darkblue
colorscheme desert
else
"set background=dark
"colorscheme darkblue
colorscheme desert
endif
"Some nice mapping to switch syntax (useful if one mixes different languages in one file)
map <leader>1 :set syntax=cheetah<cr>
map <leader>2 :set syntax=xhtml<cr>
map <leader>3 :set syntax=python<cr>
map <leader>4 :set ft=javascript<cr>
map <leader>$ :syntax sync fromstart<cr>
"Highlight current
if has("gui_running")
if exists("&cursorline")
set cursorline
endif
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Fileformat
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Favorite filetype
"Use Unix as the standard file type
set ffs=unix,dos,mac
set ff=unix
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM userinterface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Set 7 lines to the curors - when moving vertical..
"Me: Cursor is 7 lines from the bottom line
set so=7
"Turn on WiLd menu
"Me: :command will be prompted
set wildmenu
"Always show current position
set ruler
"The commandbar is 2 high
set cmdheight=1
"Show line number
set nu
"Do not re-draw, when running macros.. lazyredraw
set lz
"A buffer becomes hidden when it is abandoned
"ME: Then diffierent buffers can be switched
set hid
"Set backspace
"indent: 如果用了:set indent,:set ai 等自动缩进,想用退格键将字段缩进的删掉,必须设置这个选项。否则不响应。
"eol:如果插入模式下在行开头,想通过退格键合并两行,需要设置eol。
"start:要想删除此次插入前的输入,需设置这个
set backspace=eol,start,indent
"Bbackspace and cursor keys can jump between lines
set whichwrap+=<,>,h,l
"Ignore case when searching
"set ignorecase
set incsearch
"Set magic on
"据说很复杂
set magic
"No sound on errors.
set noerrorbells
set novisualbell
set t_vb=
"show matching bracet
set showmatch
"How many tenths of a second to blink
set mat=4
"Highlight search thing
set hlsearch
""""""""""""""""""""""""""""""
" => Statusline
""""""""""""""""""""""""""""""
"Format the statusline
" Nice statusbar
set laststatus=1
set statusline=
set statusline+=%2*%-3.3n%0*/ " buffer number
set statusline+=%f/ " file name
set statusline+=%h%1*%m%r%w%0* " flag
set statusline+=[
if v:version >= 600
set statusline+=%{strlen(&ft)?&ft:'none'}, " filetype
set statusline+=%{&encoding}, " encoding
endif
set statusline+=%{&fileformat}] " file format
if filereadable(expand("$VIM/vimfiles/plugin/vimbuddy.vim"))
set statusline+=/ %{VimBuddy()} " vim buddy
endif
set statusline+=%= " right align
set statusline+=%2*0x%-8B\ " current char
set statusline+=%-14.(%l,%c%V%)\ %<%P " offset
" special statusbar for special window
if has("autocmd")
au FileType qf
\ if &buftype == "quickfix" |
\ setlocal statusline=%2*%-3.3n%0* |
\ setlocal statusline+=\ \[Compiler\ Messages\] |
\ setlocal statusline+=%=%2*\ %<%P |
\ endif
fun! FixMiniBufExplorerTitle()
if "-MiniBufExplorer-" == bufname("%")
setlocal statusline=%2*%-3.3n%0*
setlocal statusline+=\[Buffers\]
setlocal statusline+=%=%2*\ %<%P
endif
endfun
"if v:version>=600
"au BufWinEnter *
"\ let oldwinnr=winnr() |
"\ windo call FixMiniBufExplorerTitle() |
"\ exec oldwinnr . " wincmd w"
"endif
endif
" Nice window title
if has('title') && (has('gui_running') || &title)
set titlestring=
set titlestring+=%f/ " file name
set titlestring+=%h%m%r%w " flag
" program name and cwd
set titlestring+=\ -\ %{v:progname}
set titlestring+=\ -\ %{substitute(getcwd(),\ $HOME,\ '~',\ '')}
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around and tab
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Smart way to move btw. window
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
"Actually, the tab does not switch buffers, but my arrow
"Bclose function ca be found in "Buffer related" section
map <leader>bd :close<cr>
"map <down> <leader>bd
"Use the arrows to something usefull
map <right> :bn<cr>
map <left> :bp<cr>
"Tab configuration
map <leader>tn :tabnew %<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
if v:version>=700
set switchbuf=usetab
endif
if exists("&showtabline")
set stal=2
endif
"Moving fast to front, back and 2 sides ;)
"MOre details:
inoremap <M-$> <esc>$a
inoremap <M-0> <esc>0i
"The following 2 is for MAC
inoremap <D-$> <esc>$a
inoremap <D-0> <esc>0i
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General Autocommand
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Switch to current dir
map <leader>cd :cd %:p:h<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Parenthesis/bracket expanding
" 选中的部分加括号,$1自动加小括号
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
vnoremap $1 <esc>`>a)<esc>`<i(<esc>
")
vnoremap $2 <esc>`>a]<esc>`<i[<esc>
vnoremap $3 <esc>`>a}<esc>`<i{<esc>
vnoremap $$ <esc>`>a"<esc>`<i"<esc>
vnoremap $q <esc>`>a'<esc>`<i'<esc>
vnoremap $w <esc>`>a"<esc>`<i"<esc>
"imap <c-l> <esc>la
"imap <c-h> <esc>ha
"Map auto complete of (, ", ', [
"http://www.vim.org/tips/tip.php?tip_id=153
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General Abbrev
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Comment for C like language
if has("autocmd")
au BufNewFile,BufRead *.js,*.htc,*.c,*.tmpl,*.css ino $c /**<cr> **/<esc>O
endif
"My information
ia xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
"iab xname Amir Salihefendic
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings etc.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Remap VIM 0
"map 0 ^
"Move a line of text using control
"nmap <M-j> mz:m+<cr>`z
"nmap <M-k> mz:m-2<cr>`z
"vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
"vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
if MySys() == "mac"
nmap <D-j> <M-j>
nmap <D-k> <M-k>
vmap <D-j> <M-j>
vmap <D-k> <M-k>
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Command-line config
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
func! Cwd()
let cwd = getcwd()
return "e " . cwd
endfunc
func! DeleteTillSlash()
let g:cmd = getcmdline()
if MySys() == "unix" || MySys() == "mac"
let g:cmd_edited = substitute(g:cmd, "(.*[/]).*", "", "")
else
let g:cmd_edited = substitute(g:cmd, "(.*[/]).*", "", "")
endif
if g:cmd == g:cmd_edited
if MySys() == "unix" || MySys() == "mac"
let g:cmd_edited = substitute(g:cmd, "(.*[/]).*/", "", "")
else
let g:cmd_edited = substitute(g:cmd, "(.*[/]).*[/]", "", "")
endif
endif
return g:cmd_edited
endfunc
func! CurrentFileDir(cmd)
return a:cmd . " " . expand("%:p:h") . "/"
endfunc
"cno $q <C->eDeleteTillSlash()<cr>
"cno $c e <C->eCurrentFileDir("e")<cr>
"cno $tc <C->eCurrentFileDir("tabnew")<cr>
cno $th tabnew ~/
cno $td tabnew ~/Desktop/
"Bash like
cno <C-A> <Home>
cno <C-E> <End>
cno <C-K> <C-U>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Buffer realted
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Fast open a buffer by search for a name
"map <c-q> :sb
"Open a dummy buffer for paste
map <leader>q :e ~/buffer<cr>
""Restore cursor to file position in previous editing session
"set viminfo='10,"100,:20,%,n~/.viminfo
" Buffer - reverse everything ... :)
"map <F9> ggVGg?
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files and backup
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Turn backup off
set nobackup
set nowb
"set noswapfile
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Folding
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Enable folding, I find it very useful
if exists("&foldenable")
set nofen
endif
if exists("&foldlevel")
set fdl=0
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text option
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" python script
set expandtab
"Sonic code style 0 and {} is introduced.
set shiftwidth=4
set softtabstop=4
set tabstop=4
set backspace=2
set smarttab
set lbr
"set tw=500
""""""""""""""""""""""""""""""
" => Indent
""""""""""""""""""""""""""""""
"Auto indent
set ai
"Smart indet
set si
"C-style indenting
set cindent
"Wrap line
set wrap
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spell checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>sn ]
map <leader>sp [
map <leader>sa zg
map <leader>s? z=
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin configuration
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""
" => Yank Ring
""""""""""""""""""""""""""""""
map <leader>y :YRShow<cr>
""""""""""""""""""""""""""""""
" => File explorer
""""""""""""""""""""""""""""""
"Split vertically
let g:explVertical=1
"Window size
let g:explWinSize=35
let g:explSplitLeft=1
let g:explSplitBelow=1
"Hide some file
let g:explHideFiles='^.,.*.class$,.*.swp$,.*.pyc$,.*.swo$,.DS_Store$'
"Hide the help thing..
let g:explDetailedHelp=0
""""""""""""""""""""""""""""""
" => Minibuffer
""""""""""""""""""""""""""""""
let g:miniBufExplModSelTarget = 1
let g:miniBufExplorerMoreThanOne = 0
let g:miniBufExplUseSingleClick = 1
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplSplit = 1
"let g:miniBufExplSplitBelow=1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchWindows = 1
"解决FileExplorer窗口变小问题
let g:miniBufExplForceSyntaxEnable = 1
set noequalalways
"let g:miniBufExplorerMoreThanOne=2
"WindowZ
"I prefer WM
"map <c-w><c-t> :WMToggle<cr>
""""""""""""""""""""""""""""""
" winManager setting
" 来自 进阶教程
""""""""""""""""""""""""""""""
let g:NERDTree_title="[NERD Tree]"
function! NERDTree_Start()
exec 'NERDTree'
endfunction
function! NERDTree_IsValid()
return 1
endfunction
let g:Tagbar_title = "[Tagbar]"
function! Tagbar_Start()
exe 'q'
exe 'TagbarOpen'
endfunction
function! Tagbar_IsValid()
return 1
endfunction
let g:winManagerWindowLayout = "NERDTree|Tagbar"
let g:winManagerWidth = 22
let g:defaultExplorer = 0
nmap <C-W><C-F> :FirstExplorerWindow<cr>
nmap <C-W><C-B> :BottomExplorerWindow<cr>
"nmap wm :WMToggle<cr>
nmap wm :ToggleNERDTreeAndTagbar<cr>
let g:bufExplorerSortBy = "name"
""""""""""""""""""""""""""""""
" => Tag list (ctags) - not used
""""""""""""""""""""""""""""""
"下载ctags, ctags-5.8 ./configure --prefix=/usr/local/ctags
if MySys() == "windows" "设定windows系统中ctags程序的位置
let Tlist_Ctags_Cmd = 'ctags'
elseif MySys() == "linux" "设定linux系统中ctags程序的位置
let Tlist_Ctags_Cmd="/usr/local/bin/ctags"
endif
let Tlist_Ctags_Cmd="/usr/local/bin/ctags"
let Tlist_Show_One_File=1 "不同时显示多个文件的tag,只显示当前文件的
let Tlist_Exit_OnlyWindow=1 "如果taglist窗口是最后一个窗口,则退出vim
let Tlist_Sort_Type = "name"
let Tlist_Show_Menu = 1
map <F3> :Tlist<cr>
""""""""""""""""""""""""""""""
" => LaTeX Suite thing
""""""""""""""""""""""""""""""
"set grepprg=grep -r -s -n
let g:Tex_DefaultTargetFormat="pdf"
let g:Tex_ViewRule_pdf='xpdf'
if has("autocmd")
"Binding
au BufRead *.tex map <silent><leader><space> :w!<cr> :silent! call Tex_RunLaTeX()<cr>
"Auto complete some things ;)
au BufRead *.tex ino <buffer> $i indent
au BufRead *.tex ino <buffer> $* cdot
au BufRead *.tex ino <buffer> $i item
au BufRead *.tex ino <buffer> $m [<cr>]<esc>O
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Filetype generic
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Todo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"au BufNewFile,BufRead *.todo so ~/vim_local/syntax/amido.vim
""""""""""""""""""""""""""""""
" => VIM
""""""""""""""""""""""""""""""
if has("autocmd") && v:version>600
au BufRead,BufNew *.vim map <buffer> <leader><space> :w!<cr>:source %<cr>