vim编译配置"YouCompleteMe"

在使用vim树形导航插件NERDtree时,启动vim总会提示:

The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). YCM core library not detected; you need to compile YCM before using it. Follow the instructions in the documentation.

Fedora安装YCM

在Fedora平台编译安装YouCompleteMe方法参考YouCompleteMe A code-completion engine for Vim:

  • 安装开发工具和CMake

sudo dnf install automake gcc gcc-c++ kernel-devel cmake
  • 确保已经安装了Python头文件:

sudo dnf install python-devel python3-devel
  • 安装LLVM Clang(如果不安装系统clang,则):

sudo dnf install clang
  • (可选)要支持各种开发语言,例如go, node.js ,则先安装对应工具

sudo dnf install golang
sudo dnf install nodejs
sudo dnf install ruby

详细请参考Fedora环境下Go快速起步Fedora环境下Node.js快速起步

  • 编译安装所有检测到的语言(我没有使用这个方法)

cd ~/.vim/bundle/YouCompleteMe
./install.py --all

注意:这个命令会下载CLang(如果没有找到libclang

如果只需要支持C语言(我没有使用这个方法):

多语言支持(使用这个方法,但是调整成使用系统libclang,见下文)

这里遇到一个报错

比较奇怪,我的系统是Fedora,却下载了ubuntu版本?后来发现实际上是官方网站CDN存在问题,导致下载文件大小为0.

不过,我不理解为何会下载ubuntu版本,install.py可传递参数中没有包含指定下载目录方法,单独指定安装目录可以参考vim进阶 | 使用插件打造实用vim工作环境手工从LLVM官方下载二进制程序,或者Boost your Vim autocompletion with YouCompleteMe and Jedi (on a CentOS system)

当所有编译完成后,执行

不过,我为了简化安装,采用了系统自带的libclang库,所以实际采用的安装方法是:

已验证,上述方法可行

编译安装后提示

参考

Last updated

Was this helpful?