YouCompleteMe插件安装全攻略和问题总结
来源:互联网 发布:php获取js变量的方法 编辑:程序博客网 时间:2024/04/28 03:52
一、安装的方法
1、安全之前确保系统安装了git和vim7.4版本,可以用yum install git 和yum install vim,其他系统可以apt安装这两个工具
2、bundle安装
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundlegit clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMecd ~/.vim/bundle/YouCompleteMegit submodule update --init --recursivecd ~/.vim/plugin/YouCompleteMe./install.py --clang-completer在~/.vimrc中添加
" Vunblefiletype off " required!set rtp+=~/.vim/bundle/vundle/call vundle#rc()" let Vundle manage VundleBundle 'gmarik/vundle'" vim-scripts reposBundle 'Valloric/YouCompleteMe'filetype plugin indent on " required!let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'执行安装 vim +BundleInstall +qall 或者 在vim中执行 :BundleInstall
3、直接安装
git clone https://github.com/Valloric/YouCompleteMe.git /usr/share/vim/vim74/plugin/YouCompleteMecd /usr/share/vim/vim74/plugin/YouCompleteMegit submodule update --init --recursivecd /usr/share/vim/vim74/plugin/YouCompleteMe./install.py --clang-completer执行sed -i '$a"YouCompleteMe\nlet g:ycm_global_ycm_extra_conf="/usr/share/vim/vim74/plugin/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py"\nnmap <C-\>G :YcmCompleter GoTo<CR>' ~/.vimrc
二、安装过程中下载的Clang.so链接库GLIBC版本不对的问题
这是因为YouCompleteMe安装脚本默认从官网下载Clang.so导致的,而不是本系统编译的,所以可以从本系统编译Clang.so替换进去就可以了。
1、安装之前安装Python2.7以上和CMake,有些系统python需要源码安装,CMake直接yum install cmake安装
wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgztar xzvf Python-2.7.11.tgzcd Python-2.7.11./configure --prefix=/usr/local/python2.7.11make make installmv /usr/bin/python /usr/bin/python.bakln -s /usr/local/python2.7.11/bin/python2.7 /usr/bin/python2、编译CLang
注意点:1) 不能直接在源码目录编译,必须建立一个目录编译
2)编译时必须加--enable-optimized --enable-targets=host-only选项,不然会很慢
wget http://llvm.org/releases/3.8.0/llvm-3.8.0.src.tar.xzwget http://llvm.org/releases/3.8.0/cfe-3.8.0.src.tar.xzwget http://llvm.org/releases/3.8.0/compiler-rt-3.8.0.src.tar.xztar xf llvm-3.8.0.src.tar.xzmv llvm-3.8.0.src llvmcp compiler-rt-3.8.0.src.tar.xz ./llvm/projectscp cfe-3.8.0.src.tar.xz ./llvm/toolscd ./llvm/toolstar xf cfe-3.8.0.src.tar.xzmv cfe-3.8.0.src clangcd ../projectstar xf compiler-rt-3.8.0.src.tar.xzmv compiler-rt-3.8.0.src compiler-rtcd ../../mkdir buildcd build../llvm/configure --enable-optimized --enable-targets=host-only CC=gcc CXX=g++make -j4make installclang --versionls -s /usr/local/bin/clang /usr/bin/clang
拷贝Clang.so拷贝到YouCompleteMe目录
cp ./build/Release+Asserts/lib/libclang.so /usr/share/vim/vim74/plugin/YouCompleteMe/third_party/ycmd/libclang.so.3.8三、中文GBK支持的问题
出现类似错误,则是插件解析中文GBK的错误问题
ycmd.responses.ServerError: UnicodeDecodeError: 'utf8' codec can't decode byte 0xc1 in position 0: invalid start byte这个问题需要修改用到转码的地方改为支持GBK,即把字符先gbk decode, 再encode成utf8
修改文件/usr/share/vim/vim74/plugin/YouCompleteMe/third_party/ycmd/ycmd/utils.py中的函数ToUnicode
# Returns a unicode type; either the new python-future str type or the real# unicode type. The difference shouldn't matter.def ToUnicode( value ): if not value: return str() if isinstance( value, str ): return value if isinstance( value, bytes ): # All incoming text should be utf8 return str( value, 'utf8' ) return str( value )改为
def ToUnicode( value ): if not value: return str() if isinstance( value, unicode ): return value if isinstance( value, str ): return value if isinstance( value, bytes ): # All incoming text should be utf8 try: return str( value.decode('gbk'), 'utf8' ) except UnicodeDecodeError,e: pass return str( value, 'utf8' ) return str( value )
1、注意要把.ycm_extra_conf.py放到正确的位置
按照官方文档C-family-semantic-completion中的说法
YCM looks for a .ycm_extra_conf.py file in the directory of the opened file or in any directory above it in the hierarchy (recursively);也就是说.ycm_extra_conf.py要放置在被打开的源文件的当前目录或者其上级目录下,该过程一直递归直到找到该文件或者到达顶级目录,所以普通用户将该文件放在~/下就可以了
2、补全时出现的preview窗口,buffer经常留在window中无法清空,十分annoying,直接在.vimrc中禁用preview
set completeopt-=preview
3、要在.ycm_extra_conf.py中链接需要使用的头文件目录(否则无法读取该头文件进行补全,因为找不到)。按照如下方式添加在flags数组里:
全选复制放进.ycm_extra_conf.py的flags数值里
'-I','/usr/local/A/include','-I','/usr/local/B/include',
0 0
- YouCompleteMe插件安装全攻略和问题总结
- vim补全插件YouCompleteMe安装
- Vim智能补全插件YouCompleteMe安装
- vim补全插件YouCompleteMe安装
- vim补全插件YouCompleteMe安装
- Vim智能补全插件YouCompleteMe安装
- vim安装youcompleteme自动补全插件
- Vim自动补全插件----YouCompleteMe安装与配置
- Vim自动补全插件----YouCompleteMe安装与配置
- CentOS7 Vim自动补全插件----YouCompleteMe安装与配置
- vim自动补全插件YouCompleteMe的安装及配置
- Vim 自动补全插件 YouCompleteMe 安装与配置
- Vim自动补全插件----YouCompleteMe安装与配置
- Vim自动补全插件----YouCompleteMe安装与配置
- VIM补全插件YouCompleteMe编译安装详细步骤
- Vim代码补全插件——YouCompleteMe安装说明
- Fedora25下vim智能补全插件YouCompleteMe安装
- 【环境配置】VIM 安装YouCompleteMe自动补全插件(MAC)
- Poj 3592 Instantaneous Transference【强连通Tarjan+染色缩点+SPFA】
- eclipse中的项目导入到源生项目中的各种问题
- 多态
- qt5做的简单计算器(校企作业)
- poj 1860 spfa算法判断图中是否有正环
- YouCompleteMe插件安装全攻略和问题总结
- hdu 2089 不要62 基础数位DP
- JAVA 文件输入/输出流
- win32,x64 程序显式链接dll的问题
- Android 子线程更新UI
- ssh学习笔记一:struts框架学习
- Akka学习笔记:Actor消息处理-请求和响应(2)
- CENTOS6.5搭建 LAMP nginx1.4.2 + mariaDb10.0 + php5.4
- Spring定时任务的几种实现