Skip to content

Commit e8d9f8b

Browse files
committed
change ycm to clangd
1 parent abfb520 commit e8d9f8b

File tree

4 files changed

+28
-31
lines changed

4 files changed

+28
-31
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
### setup
1616
#### ubuntu
1717
```bash
18-
./init.sh --with_php --with_vim_c --with_vim_ycm --with_vim_go --with_java \
18+
./init.sh --with_php --with_c --with_vim_go --with_java \
1919
--with_lua --with_leetcode --with_man --with_dict --with_bash
2020
```
2121
#### mac and centos

helper/option.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
OPT_PHP=
2-
OPT_VIM_C=
3-
OPT_VIM_YCM=
2+
OPT_C=
43
OPT_VIM_GO=
54
OPT_JAVA=
65
OPT_LUA=
@@ -15,8 +14,7 @@ for option
1514
do
1615
case "$option" in
1716
--with_php) OPT_PHP=yes ;;
18-
--with_vim_c) OPT_VIM_C=yes ;;
19-
--with_vim_ycm) OPT_VIM_YCM=yes ;;
17+
--with_c) OPT_C=yes ;;
2018
--with_vim_go) OPT_VIM_GO=yes ;;
2119
--with_java) OPT_JAVA=yes ;;
2220
--with_lua) OPT_LUA=yes ;;

tools/dep/ubuntu_init.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,27 @@ if [ "Y$OPT_DICT" == "Yyes" ];then
2424
fi
2525
fi
2626

27-
if [ "Y$OPT_VIM_C" == "Yyes" ];then
27+
#install clangd8 url:https://apt.llvm.org/
28+
if [ "Y$OPT_C" == "Yyes" ];then
29+
! ( grep -F "llvm-toolchain-" /etc/apt/sources.list ) && \
30+
cat >> /etc/apt/sources.list <<END
31+
# clangd
32+
# i386 not available
33+
deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic main
34+
deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic main
35+
# 7
36+
deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-7 main
37+
deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-7 main
38+
# 8
39+
deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main
40+
deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main
41+
END
42+
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - &&\
43+
apt update && apt install -y clang-tools-8 &&\
44+
sudo update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-8 100
45+
fi
46+
47+
if [ "Y$OPT_C" == "Yyes" ];then
2848
apt-get install -y \
2949
valgrind clang-format cscope gdb
3050
fi

tools/neovim/ubuntu_init.sh

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,14 @@
11
#!/bin/bash
2-
3-
function ycm_ins(){
4-
! (grep -F 'YouCompleteMe' ~/.config/nvim/init.vim &>/dev/null ) && \
5-
sed -i "/plug#begin/aPlug 'Valloric/YouCompleteMe'" ~/.config/nvim/init.vim
6-
7-
if [ ! -f ~/.config/nvim/ycm.cpp.py ] ; then
8-
wget https://raw.githubusercontent.com/zhouzheng12/newycm_extra_conf.py/master/ycm.c.py
9-
wget https://raw.githubusercontent.com/zhouzheng12/newycm_extra_conf.py/master/ycm.cpp.py
10-
mkdir -p ~/.config/nvim
11-
cp ycm.c.py ~/.config/nvim/ycm.c.py
12-
cp ycm.cpp.py ~/.config/nvim/ycm.cpp.py
13-
rm -f ycm.c.py ycm.cpp.py
14-
fi
15-
if [ ! -f ~/.local/share/nvim/plugged/YouCompleteMe/third_party/ycmd/ycm_core.so ] ; then
16-
bash ~/.config/nvim/add_swap.sh
17-
pxy python2 ~/.local/share/nvim/plugged/YouCompleteMe/install.py --clang-completer
18-
bash ~/.config/nvim/del_swap.sh
19-
rm -rf ~/.local/share/nvim/plugged/YouCompleteMe/third_party/ycmd/clang_archives
20-
fi
21-
}
22-
232
function c_ins(){
243
! (grep -F 'nvim-gdb' ~/.config/nvim/init.vim &>/dev/null ) && \
254
sed -i "/plug#begin/aPlug 'vim-scripts/a.vim'" ~/.config/nvim/init.vim && \
265
sed -i "/plug#begin/aPlug 'gauteh/vim-cppman'" ~/.config/nvim/init.vim && \
276
sed -i "/plug#begin/aPlug 'rhysd/vim-clang-format'" ~/.config/nvim/init.vim && \
287
sed -i "/plug#begin/aPlug 'sakhnik/nvim-gdb' , { 'branch': 'legacy' }" ~/.config/nvim/init.vim
8+
! ( grep -F "languageserver" ~/.config/nvim/coc-settings.json ) && \
9+
sed -i '/suggest.timeout/i "languageserver": { \n "clangd": { \n "command": "clangd",\n"filetypes": ["c", "cpp", "objc", "objcpp"],\n"args": ["-background-index"]\n }\n },'
2910
}
11+
3012
function leetcode_ins(){
3113
! (grep -F 'leetcode' ~/.config/nvim/init.vim &>/dev/null ) && \
3214
pip3 install requests beautifulsoup4 && \
@@ -141,13 +123,10 @@ if [ "Y$OPT_PHP" == "Yyes" ];then
141123
php_ins
142124
fi
143125

144-
if [ "Y$OPT_VIM_C" == "Yyes" ];then
126+
if [ "Y$OPT_C" == "Yyes" ];then
145127
c_ins
146128
fi
147129

148-
if [ "Y$OPT_VIM_YCM" == "Yyes" ];then
149-
ycm_ins
150-
fi
151130

152131
if [ "Y$OPT_LUA" == "Yyes" ];then
153132
lua_ins

0 commit comments

Comments
 (0)