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