以前用vim都是从网上down别人的配置文件和插件,虽然他们每个人的配置都各有优点,用起来感觉还行,但有的功能却没有。
于是,在前几天,我就自己摸索,按照自己所需要的功能,同时参考了网上其他大牛配置的vim,我自己也配了一个vim。在这个配置中,我用到了一个网上都说是很强大的代码提示工具就是YouCompleteMe(ycm).这个插件安装起来是比较麻烦的,我也是装了两三次才装好,为了是我下次能快速安装,也同时给想要安装此插件的朋友们一个参考。其实,这里的一些资料我也是参考别人的,就是自己在有的地方做了些修改而已,
所以,我也是很感谢那些热心的技术爱好者门!
安装ycm需要Vim 7.3.584+的支持, 并且开启 +python , 可以通过:version
查看升级Vim需要先卸载原有的Vim.
升级Vim (参考:http://www.cnblogs.com/scue/p/3234102.html)
- ~$: sudo apt-get install -y hgsvn libncurses5-dev libgnome2-dev libgnomeui-dev libgtk2.0-dev libatk1.0-dev libbonoboui2-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev ruby-dev mercurial cscope exuberant-ctags
- ~$: cd ~
- ~$: hg clone https://code.google.com/p/vim/ #如果没装hg,就自行安装.
- ~$: cd vim
- ~$: ./configure --with-features=huge \
- --enable-rubyinterp \
- --enable-pythoninterp \
- --with-python-config-dir=/usr/lib/python2.7-config/config \
- --enable-perlinterp \
- --enable-gui=gtk2 --enable-cscope --prefix=/usr
- ~$: make VIMRUNTIMEDIR=/usr/share/vim/vim74
- ~$: sudo make install
- ~$: sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vim 1
- ~$: sudo update-alternatives --set editor /usr/bin/vim
- ~$: sudo update-alternatives --install /usr/bin/vi vi /usr/bin/vim 1
- ~$: sudo update-alternatives --set vi /usr/bin/vim
编译Clang3_3
- ~$: sudo apt-get install -y g++ subversion cmake
- ~$: cd ~
- ~$: mkdir Clang && cd Clang
- ~$: svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
- ~$: cd llvm/tools
- ~$: svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
- ~$: cd ../../
- ~$: mkdir build
- ~$: cd build
- ~$: ../llvm/configure --prefix=/usr/clang_3_3 --enable-optimized --enable-targets=host
- ~$: make -j 4
- ~$: sudo make install
- export PATH=/usr/clang_3_3/bin:$PATH #这一句最好写到~/.bashrc内
安装YouCompleteMe
- ~$: git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
- ~$: vim ~/.vimrc
- #复制下面的代码
- """"""""""""""""""""""""""""""
- " Vunble
- """"""""""""""""""""""""""""""
- filetype off " required!
- set rtp+=~/.vim/bundle/vundle/
- call vundle#rc()
- " let Vundle manage Vundle
- Bundle 'gmarik/vundle'
- " vim-scripts repos
- Bundle 'Valloric/YouCompleteMe'
- filetype plugin indent on "
- ~$: vim BundleInstall +qall
编译YouCompleteMe
- ~$: cd ~
- ~$: mkdir ycm_build
- ~$: cd ycm_build
- ~$: cmake -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/cpp
- ~$: cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=/usr/clang_3_3/ . ~/.vim/bundle/YouCompleteMe/cpp
- ~$: make ycm_core
- ~$: cp /usr/clang_3_3/lib/libclang.so ~/.vim/bundle/YouCompleteMe/python/libclang.so #这一步是为了使用新的libcang.so
- ~$: cd ~/.vim/bundle/YouCompleteMe
- .vim/bunble/YouCompleteMe$: ./install.sh --clang-completer
OK!,到这里算是已经装好了ycm。。。。