ubuntu 16.04配置YouCompleteme插件

这个东西害我倒腾了几天,总算出成效了,发现还不错,我这里把我的方法记录下来,希望帮助后面的人。

1.删除原来的vim包

sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-common vim-gui-common

2.安装依赖

vim依赖

sudo apt-get install liblua5.1-dev luajit libluajit-5.1 python-dev libperl-dev libncurses5-dev ruby-dev

必要的话,删除以前编译的vim安装文件

// Clean and prepare folders
sudo rm -rf /usr/local/share/vim
sudo rm /usr/bin/vim

3.编译安装vim

git clone https://github.com/vim/vim
cd vim
./configure --with-features=huge \
            --enable-largefile \
            --enable-multibyte \
            --enable-fail-if-missing \
            \
            --enable-rubyinterp \
            --with-ruby-command=$(which ruby) \
            --enable-pythoninterp \
            --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu \
            --enable-perlinterp \
            --enable-luainterp \
            --with-luajit \
            --enable-gui=auto --enable-cscope
make
sudo make install

然后vim就安装成功了,自己可以在terminal上敲击vim试试,如果有反应,则安装成功啦。

 

4.安装vundle

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

将下面内容添加到vimrc的顶部:

set nocompatible " be iMproved, required
filetype off " required
set backspace=indent,eol,start
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" install youcompleteme
Plugin 'Valloric/YouCompleteMe'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}

" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py'

5. 安装YouCompleteMe

sudo apt install build-essential cmake clang
git clone --recursive https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer --system-libclang

youcompleteme的源文件稍稍有些大,这里需要花费的时间较长,需要等待一下。

然后这些弄完以后,创建一个文件,小试牛刀:

touch test.cpp

你在写c++代码的时候,发现正在提示一些库文件,如果没有提示,则注意.vimrc中的

let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py'

的路径是否正确.我的教程就到这里哈,虽然我讲的简单,但是本人也是吃了不少苦头的。

 

参考文献

[1].Ubuntu 16.04下编译安装vim/gvim 8.0.http://mikewootc.com/wiki/linux/usage/ubuntu_make_vim80.html

[2].Ubuntu 16.04 + vim8 + vundle + YouCompleteMe.http://blog.51cto.com/walkerqt/1935024

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

农民小飞侠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值