forked from t1ngyu/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvimrc
More file actions
264 lines (225 loc) · 7.46 KB
/
vimrc
File metadata and controls
264 lines (225 loc) · 7.46 KB
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
"
" Lonzo's vimrc
" refer to websit https://vimawesome.com/ for more vim plugins
"
let mapleader=","
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
""""""""""""""""""""""""""""""""""""""""""""
" => AirLine
"""""""""""""""""""""""""""""""""""""""""""
let g:airline_theme = 'edge'
Plugin 'vim-airline/vim-airline'
""""""""""""""""""""""""""""""""""""""""""""
" => Cscope
""""""""""""""""""""""""""""""""""""""""""""
if has("cscope")
"set csprg=/usr/local/bin/cscope
" -> cscope settings <-
" csto=0: search tag file first
" csto=1: search cscope database first
set csto=0
set cst
" cspc: how may components of file path to display
set cspc=4
set nocsverb
" set cscopequickfix=s-,c-,d-,i-,t-,e-
" -> database -<
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
set cscopeverbose
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
set cscopeverbose
else
" auto search database
let cscope_file=findfile("cscope.out", ".;")
let cscope_pre=matchstr(cscope_file, ".*/")
if !empty(cscope_file) && filereadable(cscope_file)
exe "cs add" cscope_file cscope_pre
endif
set cscopeverbose
endif
" -> key map for cscope -<
nmap <leader>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <leader>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <leader>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <leader>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <leader>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <leader>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <leader>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <leader>d :cs find d <C-R>=expand("<cword>")<CR><CR>
nmap <leader>a :cs find a <C-R>=expand("<cword>")<CR><CR>
nmap <C-n> :cnext<CR>
nmap <C-p> :cprev<CR>
" [create database]
" 下表中列出了cscope的常用选项:
" -R: 在生成索引文件时,搜索子目录树中的代码
" -b: 只生成索引文件,不进入cscope的界面
" -q: 生成cscope.in.out和cscope.po.out文件,加快cscope的索引速度
" -k: 在生成索引文件时,不搜索/usr/include目录
" -i: 如果保存文件列表的文件名不是cscope.files时,需要加此选项告诉cscope到哪儿
" 去找源文件列表。可以使用”–“,表示由标准输入获得文件列表。
" -Idir: 在-I选项指出的目录中查找头文件
" -u: 扫描所有文件,重新生成交叉索引文件
" -C: 在搜索时忽略大小写
" -Ppath: 在以相对路径表示的文件前加上的path,这样,你不用切换到你数据库文件所
" 在的目录也可以使用它了。
" sample: csope -Rbqk
"
" [cs find]
" 0 or s: Find this C symbol
" 1 or g: Find this definition
" 2 or d: Find functions called by this function
" 3 or c: Find functions calling this function
" 4 or t: Find this text string
" 6 or e: Find this egrep pattern
" 7 or f: Find this file
" 8 or i: Find files #including this file
endif
" Cscope End
""""""""""""""""""""""""""""""""""""""""""""
" => NERDtree
""""""""""""""""""""""""""""""""""""""""""""
Plugin 'scrooloose/nerdtree'
map <F4> :NERDTreeToggle<cr>
let NERDTreeWinPose='left'
let NERDTreeHighlightCursorline=1
"let NERDTreeWinSize=30
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
autocmd vimenter *.c,*.h,*.cpp,*.cc,*.java NERDTree | wincmd w
" Plugin 'jistr/vim-nerdtree-tabs'
""""""""""""""""""""""""""""""""""""""""""""
" => Tagbar
""""""""""""""""""""""""""""""""""""""""""""
Plugin 'majutsushi/tagbar'
nmap <F12> :TagbarToggle<CR>
autocmd FileType python,c,cpp,java TagbarOpen
""""""""""""""""""""""""""""""""""""""""""""
" => grep
""""""""""""""""""""""""""""""""""""""""""""
Plugin 'grep.vim'
nnoremap <silent> <F3> :Rgrep<CR>
""""""""""""""""""""""""""""""""""""""""""""
" => Opengrok plugin
""""""""""""""""""""""""""""""""""""""""""""
"if filereadable(".vim.custom")
" so .vim.custom
"endif
"Plugin 'jdevera/vim-opengrok-search'
""""""""""""""""""""""""""""""""""""""""""""
" => Mark
""""""""""""""""""""""""""""""""""""""""""""
" After install these two plugin, needs to manually do git checkout the
" stable branch in directory vim/bundle/vim-mark and vim-ingo-library
Plugin 'inkarkat/vim-ingo-library'
Plugin 'inkarkat/vim-mark'
" <Leader>m Mark and unmark works under cursor, If already on a mark: Clear
" the mark
" <Leader>n Clear the mark under the cursor.If not on a mark: Disable all marks
" <Leader>/ <Leader>? Jump next/previous
" :Mark Clear all marks
" :MarkClear Clear all marks.
" For more helps refers to README of https://github.com/inkarkat/vim-mark
""""""""""""""""""""""""""""""""""""""""""""
" => YouCompleteMe
""""""""""""""""""""""""""""""""""""""""""""
" Plugin 'Valloric/YouCompleteMe'
""""""""""""""""""""""""""""""""""""""""""""
" => Color scheme and Syntax
""""""""""""""""""""""""""""""""""""""""""""
" Plugin 'justinmk/vim-syntax-extra'
Plugin 'sheerun/vim-polyglot'
Plugin 'sainnhe/edge'
""""""""""""""""""""""""""""""""""""""""""""
" => Leaderf
""""""""""""""""""""""""""""""""""""""""""""
Plugin 'yggdroot/leaderf'
let g:Lf_ShortcutF = '<leader>z'
let g:Lf_WorkingDirectoryMode = 'AF'
let g:Lf_RootMarkers = ['.git', '.svn', '.hg', '.project', '.root']
let g:Lf_PreviewInPopup = 1
nmap <leader>x :LeaderfLine<cr>
" Vundle END
call vundle#end()
"
" 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
"""""""""""""""""""""""""""""
" General
"""""""""""""""""""""""""""""
filetype plugin indent on
set backspace=indent,eol,start
set showmatch
set ruler
set number
" set cursorline
" set cursorcolumn
set hlsearch
set incsearch
set virtualedit=onemore
set tabstop=8
set shiftwidth=8
set softtabstop=8
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,ucs-bom,cp936
set termencoding=utf-8
set fileformat=unix
set scrolloff=7
set autoindent
set cindent
set smartindent
set mouse=a
set laststatus=2
" Set how many lines of history VIM has to remember
set history=100
"""""""""""""""""""""""""""
" color and syntax
"""""""""""""""""""""""""""
syntax enable
set background=dark
if has('termguicolors')
set termguicolors
" Current theme depends on plugin sainnhe/edge
" The configuration options should be placed before `colorscheme edge`.
let g:edge_style = 'aura'
let g:edge_enable_italic = 1
let g:edge_disable_italic_comment = 1
colorscheme edge
else
set t_Co=256
colorscheme desert
endif
set colorcolumn=100
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
" jump to the last position when open a file
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" When .vimrc is edit, reload it
autocmd! bufwritepost .vimrc source ~/.vimrc
" Highlight item
hi Search term=standout cterm=bold ctermfg=7 ctermbg=2
""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
""""""""""""""""""""""""""""""""""""""""""""
set nobackup
set nowb
set noswapfile
runtime macros/matchit.vim
""""""""""""""""""""""""""""""""""""""""""""
" => Short key map
""""""""""""""""""""""""""""""""""""""""""""
nmap <leader>w :w!<cr>
nmap <leader>q :qa<cr>
nnoremap <F2> :set invpaste paste?<cr>