ubuntu16.04下VIM升级、配置插件YouCompleteMe

前端之家收集整理的这篇文章主要介绍了ubuntu16.04下VIM升级、配置插件YouCompleteMe前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_502_1@安装依赖:

sudo apt-get install libncurses5-dev
sudo apt-get install build-essential cmake
sudo apt-get install python-dev python3-dev
sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev libisl-dev libcloog-isl-dev zlib1g-dev
sudo apt-get install autogen
sudo apt-get install libclang-dev

@H_502_1@
@H_502_1@升级CMake(可选):

wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz

tar xvf cmake-3.5.2.tar.gz
cdcmake-3.5.2
./bootstrap --prefix=/usr
make
sudo make install


@H_502_1@升级GCC到4.9.2(如果你的gcc版本<=4.8):

wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.9.2/gcc-4.9.2.tar.gz
cd gcc-4.9.2
./configure --prefix=/opt/gcc-4.9.2 --enable-languages=c,c++ --disable-multilib --disable-bootstrap --with-system-zlib
make && make check
sudo make install

这样在/opt目录下就生成gcc4.9.2目录。

删除当前的gcc(可选):

sudo apt-get remove gcc

创建软连接到bin文件夹:

sudo rm /usr/bin/gcc /usr/bin/g++
sudo ln -s /opt/gcc-4.9.2/bin/gcc /usr/bin/gcc
sudo ln -s /opt/gcc-4.9.2/bin/g++ /usr/bin/g++




------------------------------------------------------------------------------------------------------

安装YCM插件的时候会提示"requires Vim compiled with Python (2.6+ or 3.3+) support."
网上有两种办法可以解决,但是我用第一种方法失败了,第二种方案可行!

@H_502_1@方法一:

自己编译VIM:

git clone https://github.com/vim/vim.git
cd vim
git pull


配置python支持,否则在

./configure --enable-multibyte --enable-pythoninterp=yes


编译:

cd src
make distclean # if you build Vim before
make
sudo make install


@H_502_1@方法二:

sudo add-apt-repository ppa:jonathonf/vim
sudo apt-get update
sudo apt-get install vim-nox-py2
sudo mv /usr/local/bin/vim /usr/local/bin/vim.old
sudo ln -s /usr/bin/vim.nox-py2 /usr/local/bin/vim



@H_502_1@配置Vundle

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vi ~/.vimrc
输入 @H_502_1@:
set nocompatible " be iMproved,required
filetype off " required

" 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')

Plugin 'scrooloose/nerdtree'
Plugin 'majutsushi/tagbar'
Plugin 'kien/ctrlp.vim'
Plugin 'powerline/powerline'
" let Vundle manage Vundle,required
Plugin 'VundleVim/Vundle.vim'

" 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'}

" Solarized: 非常流行的配色。
Plugin 'altercation/vim-colors-solarized'

" Commentary: 快速注释。
Plugin 'tpope/vim-commentary'

" Airline: 小巧美观的状态栏。
" Plugin 'bling/vim-airline'


Plugin 'Valloric/YouCompleteMe'
" for VCM
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
"let g:ycm_key_invoke_completion = '<C-j>'
"let g:ycm_semantic_triggers = {}
"let g:ycm_semantic_triggers.c = ['->','.',' ','(','[','&']
let g:ycm_confirm_extra_conf=1
nnoremap <C-g> :YcmCompleter GoToDefinitionElseDeclaration<CR>
" 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

进入VIM安装Plugin:
vim
:PluginInstall

安装YCM:
cd ~/.vim/bundle/YouCompleteMe
./install.py--clang-completer #这一步可能要等很久,下载clang好慢

安装完成后发现还是不能用,YCM没有任何提示
在vim中查看log:
:YcmToggleLogs ycmd_43693_stderr_EstRnF.log

发现提示:“version `GLIBCXX_3.4.20’ not found”
使用:
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX
发现最高只有GLIBCXX_3.4.19

上面升级GCC到4.9.2的时候,只把bin文件的东西考过去,并没有把新的libstdc++.so.6也搞过来。
接下去执行
locate libstdc++.so
得到结果:


把opt下libstdc++.so.6.0.20拷贝到/usr/lib/x86_64-linux-gnu/下, 并制作软连接:
sudo cp /opt/gcc-4.9.2/lib64/libstdc++.so.6.0.20/usr/lib/x86_64-linux-gnu/
sudo rm/usr/lib/x86_64-linux-gnu/libstdc++.so.6
sudo ln -s/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.20/usr/lib/x86_64-linux-gnu/libstdc++.so.6

再次使用VIM就可以看到好用的YCM啦!

猜你在找的Ubuntu相关文章