ubuntu16.04下VIM升级、配置插件YouCompleteMe
安装依赖:
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_
301_37@
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
升级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
@H_
301_37@
sudo apt-get remove gcc
@H_
301_37@
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."
网上有两种办法可以解决,但是我用第一种方法失败了,第二种方案可行!
自己编译VIM:
git clone https://github.com/vim/vim.git
cd vim
git pull
./configure --enable-multibyte --enable-pythoninterp=yes
编译:
cd src
make distclean # if you build Vim before
make
sudo make install
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
配置Vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vi ~/.vimrc
输入
:
@H_
301_37@
" 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'
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'
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
" 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