-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_mac.sh
299 lines (239 loc) · 7.33 KB
/
install_mac.sh
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
set -xe
echo "bash install.sh"
echo "not with sudo"
# Set up http proxy if needed.
#export https_proxy=http://xx.xx.xx.xx:8080
#export http_proxy=http://xx.xx.xx.xx:8080
function install_vim()
{
# 1. Upgrade vim to 8.1.
git clone https://github.com/vim/vim.git |true
cd vim
./configure --with-features=huge --enable-gui=gtk2 --enable-cscope
make -j32
make install
cd ..
rm -rf vim
}
function install_with_sudo()
{
# Ubuntu
apt-get install libncurses-dev -y
apt install -y ctags
apt install cscope -y
apt install -y make
apt install -y cmake
apt install -y curl
}
function install_basic()
{
#add-apt-repository ppa:jonathonf/vim -y |true
#apt update -y |true
# pre-request
#brew install ctags
#brew install make
#brew install cmake
#brew install cscope
# 1. install tools with sudo
#install_with_sudo
# 2. clang
#apt install clang -y |true
## 2.1 Install pathogen
# Install vim
#install_vim
# ~/.vim/bundle是pathogen默认runtimepath,把所有的plugin放到该目录即可
curl -LSso autoload/pathogen.vim https://tpo.pe/pathogen.vim | true
mkdir bundle |true
cp -rf ale gundo.vim neocomplete.vim powerline vim-gocode vim-markdown vim-sensible nerdtree tagbar vim-go ./bundle/ |true
if [ ! -d ~/.vim ];then
mkdir -p ~/.vim
fi
cp -rf ./autoload ~/.vim/ |true
cp -rf ./bundle ~/.vim/ |true
cp -rf ./pack ~/.vim/ |true
cp -rf ./plugin ~/.vim/ |true
cp -rf ./syntax ~/.vim/ |true
#cp -rf ./view ~/.vim/ |true
cp -rf ./pyformat.py ~/.vim/ |true
cp -rf ./doc ~/.vim/ |true
# 3. Setup .vimrc
cat > ~/.vimrc <<EOF
execute pathogen#infect()
syntax on
filetype plugin indent on
" cscope related
set nocscopeverbose
if has('mouse')
set mouse=a
endif
set hlsearch
colorscheme desert
set smartindent
set expandtab
set shiftwidth=2
set tabstop=2
set autoindent
syntax on
set hlsearch
set showmatch
let Tlist_Auto_Open = 0
let Tlist_Auto_Update = 0
set cscopetag
set textwidth=80
set colorcolumn=80
set nocompatible
set t_Co=256
set wildmenu
set wildmode=longest:list,full
set completeopt=longest,menu,preview
set backspace=indent,eol,start
set history=200
set laststatus=2
set showcmd
set incsearch
set splitright
set splitbelow
function! GenTags()
let curdir=getcwd()
while !filereadable("./tags")
cd ..
if getcwd() == "/"
break
endif
endwhile
!rm cscope.out tags.lst tags |true
!touch tags.lst
!find | grep "\.c$" >> tags.lst
!find | grep "\.cc$" >> tags.lst
!find | grep "\.cpp$" >> tags.lst
!find | grep "\.hpp$" >> tags.lst
!find | grep "\.h$" >> tags.lst
!find | grep "\.cu$" >> tags.lst
!find | grep "\.cuh$" >> tags.lst
!find | grep "\.py$" >> tags.lst
!find | grep "\.pl$" >> tags.lst
!find | grep "\.cl$" >> tags.lst
!cscope -i -b tags.lst
!ctags -R --langmap=C++:+.cl,C:.c,Python:.py:Asm:+.S.s,Sh:.sh,Perl:+.pl *
execute ":cd " . curdir
endfunction
nmap <F10> :call GenTags()<CR>
autocmd FileType c,cpp,cc,h setlocal textwidth=80 formatoptions+=t
au FileType python set expandtab shiftwidth=4 tabstop=4
" OpenCL format.
autocmd BufNewFile,BufRead *.cl set filetype=opencl
autocmd FileType opencl source /search/speech/luxingjing/.vim/plugin/opencl.vim
autocmd BufNewFile,BufRead *.cc set filetype=cpp
autocmd BufNewFile,BufRead *.cpp set filetype=cpp
"NerdTree
nnoremap <silent> <F3> :NERDTree <CR>
let NERDTreeWinPos="right"
"TagbarToggle
nnoremap <silent> <F2> :TagbarToggle<CR>
let TagbarOpenAutoClose = 0
let tagbar_autoclose = 0
let tagbar_autoopen = 1
let tagbar_left = 1
let tagbar_width=32
"ale
let g:ale_completion_enabled = 1
let g:ale_linters_explicit = 0
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
"gcc
let g:ale_c_gcc_options = '-Wall -O2 -std=c99'
let g:ale_cpp_gcc_options = '-Wall -O2 -std=c++11'
let g:ale_c_cppcheck_options = ''
let g:ale_cpp_cppcheck_options = ''
"clang
let g:ale_cpp_clang_executable = 'clang++'
let g:ale_cpp_clang_options = '-std=c++11 -Wall'
let g:ale_cpp_cppcheck_executable = 'cppcheck'
let g:ale_cpp_cppcheck_options = ''
"nvcc
let g:ale_cuda_nvcc_options = '-std=c++11 -ccbin g++ -m64 -O3 -std=c++11 -lcublas -gencode arch=compute_70,code=sm_70 -gencode arch=compute_70,code=compute_70'
let g:ale_lint_on_text_changed = 'never'
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_enter = 0
nmap <silent> <C-j> <Plug>(ale_previous_wrap)
nmap <silent> <C-k> <Plug>(ale_next_wrap)
let g:ale_linters = {
\ 'c++': ['cppcheck', 'clang'],
\ 'cpp': ['cppcheck', 'clang'],
\ 'cc': ['cppcheck', 'clang'],
\ 'c': ['clang'],
\ 'cuda': ['nvcc'],
\ 'python': ['pylint'],
\}
EOF
}
function install_go()
{
# 4. Install go
#sudo yum -y install go
wget https://dl.google.com/go/go1.11.2.linux-amd64.tar.gz
tar xzf go1.11.2.linux-amd64.tar.gz
sudo cp -rf go /usr/local/
mkdir -p ~/software/go_workspace
cat >> ~/.bashrc <<EOF
export GOPATH=~/software/go_workspace
export GOROOT=/usr/local/go
export PATH=\$PATH:\$GOPATH/bin:\$GOROOT/bin
EOF
source ~/.bashrc
# 4.1 配置vim-go,会自动从网上下载相应包
curl -fLo autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | true
go get -u github.com/jstemmer/gotags
go get -u github.com/mdempsky/gocode
# pushd ~/.vim/bundle
# vim t
# :Helptags
# :GoInstallBinaries
cat >> ~/.vimrc <<EOF
"golang
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
EOF
# Install other stuffs.
# Generate help docs
#vim t
#:Helptags # 自动生成所有plugin的文档
pushd ~/.vim/bundle
echo "vim t"
echo ":GoInstallBinaries"
comm
}
if [ $# == 0 ];then
echo $#
install_basic
elif [ $1 == 0 ];then
install_basic
elif [ $1 == 1 ];then
install_go
fi