Debian下安装YouCompleteMe

本文介绍如何通过Vundle安装YouCompleteMe(YCM),并避免编译源码。包括配置vim、安装所需依赖库、编译过程及常见问题解决方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

尝试不用编译源码的方式安装YCM,注意:YCM是以编译方式安装的,这里说的不用编译源码指的是不用编译YCM所需的库文件,如ycm_support_libs

一、通过Vundle安装YCM
1、安装Vundle

    git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

2、配置~/.vimrc

set nocompatible  
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
call vundle#end()     
Bundle 'Valloric/YouCompleteMe'
filetype plugin indent on  

然后在命令行模式下输入

:PluginInstall

注意标明的插件只是举例,并不是所有都需要,可根据自身情况安装,接着执行

:BundleInstall

在安装完YoucompleteMe之后,如果提示YoucompleteMe unavailable requires vim compiled with python 2.x support
执行下面命令

apt-get install vim-nox

之后打开vim会出现:
ycm_client_support.[so|pyd|dll] and ycm_core.[so|pyd|dll] not detected; you need to compile YCM before using it. Read the docs!
这是正常提示,因为还需接着编译安装
两种安装插件的方法目前还没有具体比较过。
安装完YoucompleteMe以后,首先需要做配置可参考配置YCM
然后安装:

apt-get install libclang-dev

然后执行

cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer --system-libclang

这个过程中会自动安装clang,并且也会安装系统clang以防出现兼容问题,安装完成后会在~/.vim/bundle/YouCompleteMe/third_party/ycmd/下生成libclang.so、ycm_client_support.so、ycm_core.so等,之后的操作参考博文
在Debian中,.ycm_extra_conf.py在 ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm 下,将其复制到当前用户的根目录下。 之后YouCompleteMe就可以正常使用了,

Trouble Shooting
安装YCM的过程中最大的坑就是They ycmd server shut down (restart with:YcmRestartServer) stderr( last 30 lines).解决方法是在.vimrc中输入

let g:ycm_server_keep_logfiles = 1
let g:ycm_server_log_level = 'debug'

然后执行

:YcmToggleLogs stderr

查看错误日志,最终看到是 ~/.ycm.extra.conf.py文件中的缩进有问题,因为之前是自己手动编辑的,而不是将生成的~/.ycm.extra.conf.py复制到用户根目录下

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值