-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_vimrc
294 lines (254 loc) · 8.21 KB
/
my_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
" check if vundle is installed
let vundle_readme=expand('~/.vim/bundle/Vundle.vim/README.md')
if !filereadable(vundle_readme)
if !executable("git")
let Msg="Install the git in order to install Vundle!"
echohl WarningMsg | echo Msg | echohl None
echo ""
echo "Press any key to exit..."
let c = getchar()
:quit
endif
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
" put the escaping \ at the beginning of the line
" see :help line-continuation
silent !git clone
\ https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
endif
set shell=bash
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()
" PluginList
Plugin 'VundleVim/Vundle.vim' " let Vundle manage Vundle, required
Plugin 'scrooloose/nerdtree'
Plugin 'Xuyuanp/nerdtree-git-plugin'
Plugin 'taglist.vim'
Plugin 'Rip-Rip/clang_complete'
Plugin 'tomtom/tcomment_vim'
Plugin 'mhinz/vim-startify'
Plugin 'scrooloose/syntastic'
Plugin 'wincent/command-t'
" ColorScheme
Plugin 'ScrollColors'
Plugin 'jnurmine/Zenburn'
Plugin '256-grayvim'
" Plugin 'altercation/vim-colors-solarized'
" Plugin 'chriskempson/base16-vim'
" Plugin 'freya'
" Plugin 'tomasr/molokai'
" Plugin 'Colour-Sampler-Pack'
" Plugin 'mimicpak'
" ColorScheme
" Syntax Highlight
Plugin 'brgmnn/vim-opencl'
Plugin 'neovimhaskell/haskell-vim'
Plugin 'derekwyatt/vim-scala'
" Syntax Highlight
" Other plugins
" eagletmt/ghcmod-vim requires vimproc.vim
" Plugin 'Shougo/vimproc.vim'
" Plugin 'eagletmt/ghcmod-vim'
" let g:ghcmod_ghc_options = ['-XDataKinds']
"
" Plugin 'godlygeek/tabular'
" Plugin 'plasticboy/vim-markdown'
" Other plugins
" Option for every plugin
" NERDTree
" <F5> The NERD Tree
let NERDTreeWinPos='left'
let NERDTreeWinSize=40
let NERDTreeChDirMode=1
map <F5> :NERDTreeToggle<CR>
autocmd bufenter * call s:CloseVimIfOnlyNERDTreeLeft()
function! s:CloseVimIfOnlyNERDTreeLeft()
if winnr("$") == 1
\ && exists("b:NERDTreeType")
\ && b:NERDTreeType == "primary"
quit
endif
endfunction
" NERDTree
" Taglist
" <F3> Taglist
let Tlist_Auto_Open = 0
let Tlist_Auto_Update = 1
let Tlist_Exit_OnlyWindow = 1
let Tlist_Compact_Format = 1
let Tlist_GainFocus_On_ToggleOpen = 1
map <silent> <F3> :TlistToggle<CR>
" Taglist
" clang_complete
" g:clang_use_library: Default 1
let g:clang_complete_copen=1
let g:clang_hl_errors=1
" g:clang_periodic_quickfix: Do g:ClangUpdateQuickFix() periodically
let g:clang_periodic_quickfix=0
let g:clang_snippets=1
" g:clang_snippets_engine: Default is clang_complete
let g:clang_user_options='-std=c++11'
nnoremap <Leader>q :call g:ClangUpdateQuickFix()<CR>
" clang_complete
" syntastic
" :SyntasticInfo for giving some useful information
let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_cpp_compiler_options = '-std=c++11'
let g:syntastic_c_compiler = 'clang'
let g:syntastic_c_clang_check_args = '-std=c11'
let g:syntastic_python_python_exe = 'python3'
let g:syntastic_python_checkers = ['python3-flake8']
let g:syntastic_check_on_wq = 1
" syntastic
" command-t
if !has('ruby')
let Msg="The Ruby interface ruby doesn't support. The command-t is disable."
echohl WarningMsg | echo Msg | echohl None
else
" check if ruby works
silent execute 'ruby puts "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"'
if !filereadable(expand('~/.vim/bundle/command-t/ruby/command-t/ext.so'))
let Msg="See *command-t-compile* to compile command-t"
echohl WarningMsg | echo Msg | echohl None
echo ""
echo "Press any key to continue..."
let c = getchar()
endif
endif
" command-t
" Keep Plugin commands between vundle#begin/end.
" All of your Plugins must be added before the following line
call vundle#end()
filetype plugin indent on " required
"
" 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
syntax on
" See Also: http://vim.wikia.com/wiki/Working_with_Unicode
" **VIM set encoding and fileencoding utf-8** @ Stackoverflow
if has("multi_byte")
if &termencoding == ""
let &termencoding = &encoding
endif
set encoding=utf-8
setglobal fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,big5,gbk,latin1
endif
" General Settings
set t_Co=256
set bg=dark
silent! colorscheme desert "256-grayvim
set colorcolumn=80
" http://vim.wikia.com/wiki/Remove_unwanted_spaces
" <F2>: Remove unwanted spaces
:nnoremap <silent> <F2> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
" expandtab: insert space characters whenever the tab key is pressed
set expandtab
" the # of space characters that will be inserted when the tab key is pressed
set tabstop=4
" A tab produces a 4-space indentation
"
" Number of spaces that a <Tab> counts for while performing editing
" operations, like inserting a <Tab> or using <BS>.
set softtabstop=4
" shiftwidth: change the number of space characters inserted for indentation
set shiftwidth=4
set fdm=syntax
set ai
set nu
set hlsearch
set sessionoptions-=curdir
set sessionoptions+=sesdir
set showcmd
set autoread
set ruler
set wildmenu
set showmatch
set completeopt=menu,longest
au BufNewFile,BufFilePre,BufRead *.tex setlocal spell spelllang=en_us
au BufNewFile,BufFilePre,BufRead *.md set filetype=markdown
autocmd Filetype gitcommit setlocal spell textwidth=72
" tabline & statusline
" See also: http://vim.wikia.com/wiki/Show_tab_number_in_your_tab_line
" https://github.com/mkitt/tabline.vim
set tabline=%!MyTabLine()
function! Tabline()
let s = ''
for i in range(tabpagenr('$'))
let tab = i + 1
let winnr = tabpagewinnr(tab)
let buflist = tabpagebuflist(tab)
let bufnr = buflist[winnr - 1]
let bufname = bufname(bufnr)
let bufmodified = getbufvar(bufnr, "&mod")
let s .= '%' . tab . 'T'
let s .= (tab == tabpagenr() ? '%#TabLineSel#' : '%#TabLine#')
let s .= ' ' . tab .':'
let s .= (bufname != '' ? ' '. fnamemodify(bufname, ':t') . ' ' : '[No Name] ')
if bufmodified
let s .= '[+] '
endif
endfor
let s .= '%#TabLineFill#'
return s
endfunction
set tabline=%!Tabline()
set laststatus=2
set statusline=[%n]\ %<%F\ \ \ [%M%R%H%W%Y][%{&ff}]\ \ %=\ line:%l/%L\ col:%c\ \ \ %p%%
" tabline & statusline
" ctags
" ;~ suffix directs vim to do an upward search from the directory containing
" tags up to the stop directory, in this case ~.
" See also: http://goo.gl/m4GSF3, http://goo.gl/dV7kqj
" set tags=./tags,tags
"
" the dot concatenates the two strings
" for a in split(glob('/home/phi/vim-ctags/*'), '\n')
" exe 'set tags+=' . a
" endfor
" ctags
" auto reload .vimrc
augroup reload_vimrc " {
autocmd!
autocmd BufWritePost $MYVIMRC source $MYVIMRC
augroup END " }
" The following are taken from llvm/utils/vim
"
"===== LLVM coding guidelines conformance for VIM =====
" $Revision: 176235 $
" LLVM Makefiles can have names such as Makefile.rules or TEST.nightly.Makefile,
" so it's important to categorize them as such.
augroup filetype
au! BufRead,BufNewFile *Makefile* set filetype=make
augroup END
" In Makefiles, don't expand tabs to spaces, since we need the actual tabs
autocmd FileType make set noexpandtab
" Enable syntax highlighting for LLVM files. To use, copy
" utils/vim/llvm.vim to ~/.vim/syntax .
augroup filetype
au! BufRead,BufNewFile *.ll set filetype=llvm
augroup END
" Enable syntax highlighting for tablegen files. To use, copy
" utils/vim/tablegen.vim to ~/.vim/syntax .
augroup filetype
au! BufRead,BufNewFile *.td set filetype=tablegen
augroup END
" Enable syntax highlighting for reStructuredText files. To use, copy
" rest.vim (http://www.vim.org/scripts/script.php?script_id=973)
" to ~/.vim/syntax .
augroup filetype
au! BufRead,BufNewFile *.rst set filetype=rest
augroup END
"===== End LLVM coding guidelines conformance for VIM =====