-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
193 lines (170 loc) · 5.88 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
"========================================================
" Let Vundle manage plugins
"========================================================
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim/
"========================================================
" Normal setting
"========================================================
" always show status bar
set ls=2
" incremental search
set incsearch
" highlight search results
set hlsearch
" set indent
set smartindent
set expandtab
set shiftwidth=2
set backspace=2
set tabstop=2
set splitright
set splitbelow
set backspace=2
set clipboard=unnamed
" syntax highlight on
syntax on
" disable backups and .swp files
set nobackup
set nowritebackup
set noswapfile
" show line number
set nu
" set leader key
let mapleader=','
let g:mapleader=','
" set encoding
set encoding=utf-8
"========================================================
" Auto insert header
"========================================================
autocmd BufNewFile *.c exec ":call AddHeader()"
autocmd BufNewFile *.cc exec ":call AddHeader()"
autocmd BufNewFile *.h exec ":call AddHeader()"
map <F9> :call AddHeader()<cr>'s
function AddHeader()
call append(0, "//*********************************************************************************")
call append(1, "//")
call append(2, "// ".fnamemodify(getcwd(), ':t')." ".expand("%:t"))
call append(3, "//")
call append(4, "// Created by Pingfeng on ".strftime("%m/%d/%y").".")
call append(5, "//")
call append(6, "// Description: ")
call append(7, "//")
call append(8, "//*********************************************************************************")
echohl WarningMsg | echo "Succeeded in adding copyright." | echohl None
endfunction
"========================================================
" Plugins initialization
"========================================================
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" NERDTREE
Plugin 'scrooloose/nerdtree'
" TAGBAR
Plugin 'majutsushi/tagbar'
" YCM
" Plugin 'Valloric/YouCompleteMe'
" add codefmt
Plugin 'google/vim-maktaba'
Plugin 'google/vim-codefmt'
Plugin 'google/vim-glaive'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" -------------------------------------------------------
" NERDTree setting
" -------------------------------------------------------
" toggle nerdtree display
map <F3> :NERDTreeToggle<CR>
" open nerdtree with the current file selected
nmap ,t :NERDTreeFind<CR>
" don't show these file types
let NERDTreeIgnore=['\.pyc$', '\.pyo$', '.git', 'tags', 'cscope*']
" -------------------------------------------------------
" Tagbar setting
" -------------------------------------------------------
" toggle tagbar display
map <F4> :TagbarToggle<CR>
" autofocus on tagbar open
let g:tagbar_autofocus=1
" -------------------------------------------------------
" Cscope setting
" -------------------------------------------------------
function! LoadCscope()
let db=findfile("cscope.out", ".;")
if (!empty(db))
let path=strpart(db, 0, match(db, "/cscope.out$"))
set nocscopeverbose " suppress 'duplicate connection' error
exe "cs add " . db . " " . path
set cscopeverbose
endif
endfunction
au BufEnter /* call LoadCscope()
set cscopequickfix=s-,c-,d-,i-,t-,e-
" -------------------------------------------------------
" codefmt setting
" -------------------------------------------------------
call glaive#Install()
Glaive codefmt plugin[mappings]
Glaive codefmt google_java_executable="java -jar /Users/11152336/Tools/vim/google-java-format-1.15.0-all-deps.jar"
" set keymap , '<C-_>' meaning 'CTRL + SHIFT + -"
nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR>
" -------------------------------------------------------
" YCM setting
" -------------------------------------------------------
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py '
let g:ycm_filetype_whitelist={
\ "c":1,
\ "cpp":1,
\ "h":1,
\ "sh":1,
\ "zsh":1,
\ }
set completeopt=menu,menuone,noinsert,noselect
let g:ycm_semantic_triggers={
\ 'c,h': ['->', '.'],
\ 'cpp,hpp,cuda,objcpp': ['->', '.', '::'],
\ }
let g:ycm_confirm_extra_conf=0
let g:ycm_use_clangd=0
" diagnostic
let g:ycm_show_diagnostics_ui=0
let g:ycm_enable_diagnostic_signs=0
let g:ycm_enable_diagnostic_highlighting=0
" trigger
let g:ycm_min_num_of_chars_for_completion=2
let g:ycm_min_num_identifier_candidate_chars=2
let g:ycm_auto_trigger=1
" UI
let g:ycm_add_preview_to_completeopt=0
let g:ycm_max_num_candidates=50
let g:ycm_autoclose_preview_window_after_completion=1
" Others
let g:ycm_use_ultisnips_completer=1
let g:ycm_collect_identifiers_from_tags_files=0
let g:ycm_collect_identifiers_from_comments_and_strings=1
let g:ycm_complete_in_strings=0
let g:ycm_seed_identifiers_with_syntax=0
let g:ycm_cache_omnifunc=0
let g:ycm_disable_for_files_larger_than_kb=1000