1.安装vundle插件;

2.安装vim-go;

3.安装最为头大的YouCompleteMe;

通过git clone 来离线安装YouCompleteMe。步骤如下:

cd ~/.vim/bundle

然后执行

git clone https://gitee.com/Random_Coder/YouCompleteMe.git

把YouCompleteMe目录的所有者改为当前用户(bysu)

sudo chown -R bysu:bysu YouCompleteMe

然后执行

git submodule update --init --recursive  

up-6aa23ef779a872afc7b70c4312faf269a34.png

报上面的错一般是因为curl的postBuffer的默认值太小和git clone速度太慢,可能被限制了,现在贴出这两方面的解决方案。

postBuffer的默认值太小:

在这里,笔者把postBuffer的值配置成500M,对笔者来说已经够了。可以根据你需要下载的文件大小,将postBuffer值配置成合适的大小。

git config --global http.postBuffer 524288000

   这样已经配置好了,如果你不确定,可以根据以下命令查看postBuffer。

git clone速度太慢

1、查找域名对应的ip地址,并修改hosts文件

先执行 pacman -Sy dnsutils 安装dnsutils,要不会提示没有nslookup命令。 ifconfig,route在net-tools中,nslookup,dig在dnsutils中,ftp,telnet等在inetutils中,ip命令在iproute2中;netcfg

nslookup github.global.ssl.fastly.Net
Server:  127.0.0.53
Address: 127.0.0.53#53

Non-authoritative answer:
Name: github.global.ssl.fastly.Net
Address: 151.101.229.194

nslookup github.com
Server:  127.0.0.53
Address: 127.0.0.53#53

Non-authoritative answer:
Name: github.com
Address: 13.229.188.59

sudo vim /etc/hosts

在文末加上下面两行,下面分别对应上面查出来标了底色部分的内容。然后重启网络服务,archlinux上重启网络服务的命令找到了,但是提示不对,反正我是直接重启了的。

up-5487608ec7db9811ed052a5b960be80a35c.png

解决掉git clone慢的问题后,可以直接通过git clone把相关文件下到对应的目录

cd /home/bysu/.vim/bundle/YouCompleteMe/third_party
git clone https://github.com/Valloric/ycmd

继续执行

git submodule update --init --recursive 

不行就多试几次,搞完之后,要安装

编译之前先安装: cmake   gcc

sudo pacman -Sy cmake gcc

安装完后,开始执行下面进行编译

cd ~/.vim/bundle/YouCompleteMe
./install.py
##########如果需要支持golang########
./install.py  --go-completer
##########如果需要同时支持多种语言如:golang,java,C########
./install.py  --go-completer --java-completer --clangd-completer

##########如果需要插件当前支持的所有语言########
./install.py --all

开始编译之后,我被卡在了45%那个地方,我以为是树莓派性能太差了的原因,第二天起来还是在45%,打算留个三天三夜,谁知道过一两个小时就报错了。这个时候连报错都觉得是好消息——报错没关系,就怕卡在那里又没错误。

[ 42%] Building CXX object BoostParts/CMakeFiles/BoostParts.dir/libs/regex/src/regex_raw_buffer.cpp.o
[ 45%] Building CXX object BoostParts/CMakeFiles/BoostParts.dir/libs/regex/src/regex_traits_defaults.cpp.o
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
make[3]: *** [BoostParts/CMakeFiles/BoostParts.dir/build.make:232: BoostParts/CMakeFiles/BoostParts.dir/libs/regex/src/instances.cpp.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory '/tmp/ycm_build_galdq8zl'
make[2]: *** [CMakeFiles/Makefile2:115: BoostParts/CMakeFiles/BoostParts.dir/all] Error 2
make[2]: Leaving directory '/tmp/ycm_build_galdq8zl'
make[1]: *** [CMakeFiles/Makefile2:149: ycm/CMakeFiles/ycm_core.dir/rule] Error 2
make[1]: Leaving directory '/tmp/ycm_build_galdq8zl'
make: *** [Makefile:131: ycm_core] Error 2
ERROR: the build failed.

NOTE: it is *highly* unlikely that this is a bug but rather
that this is a problem with the configuration of your system
or a missing dependency. Please carefully read CONTRIBUTING.md
and if you're sure that it is a bug, please raise an issue on the
issue tracker, including the entire output of this script
and the invocation line used to run it.

搜索发现是因为树莓派内存不足引起报错。

解决方案: 通过增加swap交换分区来解决

再重新编译,这次100%了,总算成功了。

[ 88%] Building CXX object ycm/CMakeFiles/ycm_core.dir/Result.cpp.o
[ 90%] Building CXX object ycm/CMakeFiles/ycm_core.dir/Utils.cpp.o
[ 92%] Building CXX object ycm/CMakeFiles/ycm_core.dir/Word.cpp.o
[ 95%] Building CXX object ycm/CMakeFiles/ycm_core.dir/versioning.cpp.o
[ 97%] Building CXX object ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o
[100%] Linking CXX shared library /home/bysu/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so
make[3]: Leaving directory '/tmp/ycm_build_u4swi38l'
[100%] Built target ycm_core
make[2]: Leaving directory '/tmp/ycm_build_u4swi38l'
make[1]: Leaving directory '/tmp/ycm_build_u4swi38l'
CMake Error: The source directory "/home/bysu/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/cregex" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
ERROR: the build failed.

哈哈哈,功夫不负有心人啊!慢着“ERROR: the build failed.”是什么鬼?竟然构建失败了!!!!

通过搜索

CMake Error: The source directory "/home/bysu/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/cregex" does not appear to contain CMakeLists.txt.发现这是因为 ~/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/cregex/ 的内部文件没有clone下来

-- Generating done
-- Build files have been written to: /tmp/regex_build_znc86h74
make[1]: Entering directory '/tmp/regex_build_znc86h74'
make[2]: Entering directory '/tmp/regex_build_znc86h74'
make[3]: Entering directory '/tmp/regex_build_znc86h74'
Scanning dependencies of target _regex
make[3]: Leaving directory '/tmp/regex_build_znc86h74'
make[3]: Entering directory '/tmp/regex_build_znc86h74'
[ 66%] Building C object CMakeFiles/_regex.dir/regex_3/_regex.c.o
[ 66%] Building C object CMakeFiles/_regex.dir/regex_3/_regex_unicode.c.o
[100%] Linking C shared library /home/bysu/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/cregex/regex_3/_regex.so
make[3]: Leaving directory '/tmp/regex_build_znc86h74'
[100%] Built target _regex
make[2]: Leaving directory '/tmp/regex_build_znc86h74'
make[1]: Leaving directory '/tmp/regex_build_znc86h74'
go: downloading golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7