summaryrefslogtreecommitdiff
path: root/.vimrc
blob: ebe65fc1ccec221d300d467f618409754042fe02 (plain)
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
if has("win32")
	source $VIMRUNTIME/vimrc_example.vim
	source $VIMRUNTIME/mswin.vim
	behave mswin
	set path=.,C:/MinGW/include,C:/MinGW/bin
endif

if version >= 500
	syntax on
	color elflord
	set background=dark
endif

set backspace=indent,eol,start
set ai
set nocompatible  " not compatible with original vi
set incsearch
set hlsearch
set number
set expandtab
set title
set showmatch
set showmode
set ts=4
set sw=4

"NERDtree & Buffer Explorer if exists
let NERDTreeWinSize=60
map <F12> :NERDTreeToggle<CR>
map <S-F12> \bs


""""""""""""""""""""""""""""""""""""""""""""""""""""
"
"       C, C++  Develpment Setting
"
""""""""""""""""""""""""""""""""""""""""""""""""""""
highlight ExtraOver ctermbg=red ctermfg=white guibg=#59292
aug Basic
	au BufRead * match ExtraOver /\s\+\%#\@<!$/
aug END
aug developer
	au!
	au BufNewFile,BufRead,BufEnter *.cpp,*.hpp set omnifunc=omni#cpp#complete#Main
	au FileType c,cpp,h set cindent
	au FileType c,cpp,h,edc autocmd BufEnter * silent! lcd %:p:h
	au filetype c,cpp,h map <S-k> :exec(":!man 3 ".expand("<cword>"))<CR>

	" Save previous cursor position
	set viewoptions=cursor
	au BufWinLeave *.c,*.cpp,*.h,*.edc mkview
	au BufWinEnter *.c,*.cpp,*.h,*.edc silent loadview

	"Show space errors for c, cpp file type
	let c_space_errors = 1

	" Show extra white space & Over length (80)
	au BufRead *.c,*.cpp,*.h match ExtraOver /\s\+\%#\@<!$\|\%81v.*/

	" Remove extra white space before save
	au bufwritepre *.c,*.cpp,*.h,*.edc :%s/\s\+$\| \+\ze\t//e
	map <S-F9> :%s/\s\+$\| \+\ze\t//e

	"indent for e17 ref: http://trac.enlightenment.org/e/wiki/ecoding
	map <F9> :set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2p{2(0w1st0<CR>

	" <F2> ---- debugging program ----
	if has("unix")       | au filetype c,cpp map <F2> :!gdb <CR>
	elseif has ("win32") | au filetype c,cpp map <F2> :!insight<CR>
	endif

	" <F3> <S-F3> ---- find complie error----
	au filetype c,cpp,h,edc map <F3>   :copen<CR>
	if &term == 'xterm'
		au filetype c,cpp,h,edc set <S-F3>=O1;2R
		au filetype c,cpp,h,edc set <S-F4>=O1;2S
	endif

	au filetype c,cpp,h,edc map <C-n> :cn<CR>
	au filetype c,cpp,h,edc map <C-p> :cp<CR>

	" <F4> ---- build (make) ----
	if has("unix")      | au filetype c,cpp,edc set mp=make "gcc\ %\ -o\ %<
	elseif has("win32") | au filetype c,cpp,edc set mp=make "gcc\ %\ -o\ %<.exe
	endif
	au filetype c,cpp,h map <F4> :make -j4<CR>

	" <S-F4> ---- excute binary ------
	if has("unix")       | au filetype c,cpp map <S-F4>   :!./%<<CR>
	elseif has ("win32") | au filetype c,cpp map <S-F4>   :!%<.exe<CR>
	endif

	"<F5> <S-F5> <C-W><C-\> ---- ctags ----
	au filetype c,cpp,h,edc set tags+=./tags;/tags,/home/bluezery/.vim/tags/tags
	au filetype c,cpp,h,edc map <S-F5> :!ctags --c-kinds=+p --sort=foldcase -R<CR>:ctags.sh<CR>:!echo "enjoy ctags"<CR>
	au filetype c,cpp,h,edc map <F5> :ts
	au filetype c,cpp,h,edc map <C-W><C-\> :vsp<CR>:exec("tag ".expand("<cword>"))<CR>

	"<C-\><C-]>  ----- gtags (gnu global) ------
"	au filetype c,cpp,h,edc map <C-\><C-]> :GtagsCursor<CR>

	" <F6> <S-F6> make cscope db file & read db file
	if has("unix")
		au filetype c,cpp,h,edc map <S-F6> :!rm -rf cscope.files<CR>:!find . -name '*.c' -o -name '*.cpp' -o -name '*.h' -o -name '*.h.in' -o -name '*.s' -o -name '*.s' -o -name '*.edc' > cscope.files<CR>:!cscope -b -q -k<CR>:cs reset<CR>:cs add cscope.out<CR>:cs add /home/bluezery/.vim/tags/cscope.out<CR>:!echo "enjoy cscope"<CR>
	elseif has("win32") | au filetype c,cpp,h,edc map <S-F6> :!dir /b /s *.c *.h *.edc > cscope.out<CR>:!cscope -b -q -k<CR>:cs reset<CR>:cs add cscope.out<CR>:!echo "enjoy cscope"<CR>
	endif
	au filetype c,cpp,h,edc set csto=0
	au filetype c,cpp,h,edc set cst
	au filetype c,cpp,h,edc set csverb

	" Disable cscope temporarily )conflict with ctags
	"if filereadable("/home/bluezery/.vim/tags/cscope.out")
		"au filetype c,cpp,h,edc cs kill -1
		"au filetype c,cpp,h,edc cs add /home/bluezery/.vim/tags/cscope.out
	"endif
	"
	au filetype c,cpp,h,edc map <F6> :!cscope<CR>
	au filetype c,cpp,h,edc map <C-F6> :exec("cs find g ".expand("<cword>")) <CR>
	au filetype c,cpp,h,edc map <C-\> :exec("cs find c ".expand("<cword>"))<CR>

	"" Tag List setting
	nmap <F7> :TlistToggle<CR>
	let Tlist_WinWidth = 50

	"" Source Exploere setting
	" // The switch of the Source Explorer
	nmap <F8> :SrcExplToggle<CR>:set hlsearch<CR>

	" // Set the height of Source Explorer window
	let g:SrcExpl_winHeight = 20

	" // Set 100 ms for refreshing the Source Explorer
	let g:SrcExpl_refreshTime = 100

	" // Set "Enter" key to jump into the exact definition context
	" let g:SrcExpl_jumpKey = "<ENTER>"

	" // Set "Space" key for back from the definition context
	let g:SrcExpl_gobackKey = "<SPACE>"

	" // In order to Avoid conflicts, the Source Explorer should know what plugins
	" // are using buffers. And you need add their bufname into the list below
	" // according to the command ":buffers!"
	let g:SrcExpl_pluginList = [
		\ "__Tag_List__",
		\ "_NERD_tree_",
		\ "Source_Explorer"
		\ ]

	" // Enable/Disable the local definition searching, and note that this is not
	" // guaranteed to work, the Source Explorer doesn't check the syntax for now.
	" // It only searches for a match with the keyword according to command 'gd'
	let g:SrcExpl_searchLocalDef = 1
	" // Do not let the Source Explorer update the tags file when opening
	let g:SrcExpl_isUpdateTags = 0
	" // Use 'Exuberant Ctags' with '--sort=foldcase -R .' or '-L cscope.files' to
	" //  create/update a tags file
	let g:SrcExpl_updateTagsCmd = "ctags --sort=foldcase -R ."

	" // Set "<F12>" key for updating the tags file artificially
	"let g:SrcExpl_updateTagsKey = "<F12>"
aug END
""""""""""""""""""""""""""""""""""""""""""""""""""""

"set diffexpr=MyDiff()
"function MyDiff()
"  let opt = '-a --binary '
"  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
"  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
"  let arg1 = v:fname_in
"  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
"  let arg2 = v:fname_new
"  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
"  let arg3 = v:fname_out
"  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
"  let eq = ''
"  if $VIMRUNTIME =~ ' '
"    if &sh =~ '\<cmd'
"      let cmd = '""' . $VIMRUNTIME . '\diff"'
"      let eq = '"'
"    else
"      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
"    endif
"  else
"    let cmd = $VIMRUNTIME . '\diff'
"  endif
"  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
"endfunction


""""""""""""""""""""""""""""""""""""""""""
"            Vundles configuration
""""""""""""""""""""""""""""""""""""""""""
filetype off                   " required!

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" let Vundle manage Vundle
" install guide: https://github.com/gmarik/vundle
" required!
Bundle 'gmarik/vundle'

Bundle 'gtags-multiwindow-browsing'
" My Bundles here:
Bundle 'taglist.vim'
Bundle 'bufexplorer.zip'
Bundle 'The-NERD-tree'
Bundle 'Source-Explorer-srcexpl.vim'

" original repos on github
Bundle 'tpope/vim-fugitive'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
Bundle 'tpope/vim-rails.git'
" vim-scripts repos
Bundle 'L9'
Bundle 'FuzzyFinder'
" non github repos
Bundle 'git://git.wincent.com/command-t.git'
Bundle 'CCTree'
" ...

filetype plugin indent on     " required!
"
" 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..