vim代码补全:YouCompleteMe\Vundle\python

来源:互联网 发布:在线报名系统源码 编辑:程序博客网 时间:2024/06/08 01:56

[YouCompleteMe: a code-completion engine for Vim]该插件是vim下的代码补全插件,功能非常强大,安装方法也很简单,但因为使用的操作系统及环境配置各不相同,所以安装起来非常容易出错,该文就是将本人在安装过程中所遇到的问题避开,把必要步骤及需要注意的点一一列出,供大家参考。

vim使用YouCompleteMe支持python代码补全需要注意以下几点:

1、Make sure you have Vim 7.4.143 with Python 2 or Python 3 support.
(https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source)

#如果vim版本不符合就需要卸载旧版本,然后下载最新版本vimgit clone https://github.com/vim/vim.git

2、如果需要vim同时支持python2和python3,那么就需要在编译vim的时候配置with-python-config-dir与with-python3-config-dir,此路径一定不能错,否则是不能支持的(如果不需要同时支持,可以删除)

sudo ./configure --with-features=huge \            --enable-multibyte \            --enable-rubyinterp=yes \            --enable-pythoninterp=yes \            --with-python-config-dir=/usr/lib/python2.7/config \            --enable-python3interp=yes \            --with-python3-config-dir=/Users/frankslg/.pyenv/versions/3.5.2/lib/python3.5/config-3.5m \            --enable-perlinterp=yes \            --enable-luainterp=yes \            --enable-gui=gtk2 --enable-cscope --prefix=/usr

3、编译

#如果vim是8.0需要使用下面命令进行编译sudo make VIMRUNTIMEDIR=/usr/share/vim/vim80sudo make install

vim –version | grep python #查看python及python3前面是“+”还是“-”

localhost:shims frankslg$ vim --version | grep python+cryptv          +linebreak       +python/dyn      +vreplace+cscope          +lispindent      +python3/dyn     +wildignore

4、使用vundle插件管理vim插件,安装YouCompleteMe需要先安装vundle
Install YouCompleteMe with Vundle.

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim     #没有git自行安装

5、将下面的配置复制到vimrc顶部(如果没有vimrc自己创建一个)
Put this at the top of your .vimrc to use Vundle. Remove plugins you don’t need, they are for illustration purposes.
(https://github.com/VundleVim/Vundle.vim#about)

set nocompatible              " be iMproved, requiredfiletype off                  " required" set the runtime path to include Vundle and initializeset rtp+=~/.vim/bundle/Vundle.vimcall vundle#begin()" alternatively, pass a path where Vundle should install plugins"call vundle#begin('~/some/path/here')" let Vundle manage Vundle, requiredPlugin 'VundleVim/Vundle.vim'" The following are examples of different formats supported." Keep Plugin commands between vundle#begin/end." plugin on GitHub repoPlugin 'tpope/vim-fugitive'" plugin from http://vim-scripts.org/vim/scripts.htmlPlugin 'L9'" Git plugin not hosted on GitHubPlugin '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 linecall vundle#end()            " requiredfiletype 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

6、在配置文件中添加下句

Bundle 'Valloric/YouCompleteMe'     #vundle配置段中添加此句#或Plugin 'Valloric/YouCompleteMe'

7、安装插件

:BundleInstall                      #在vim配置模式输入,进行安装#或:PluginInstall  

8、安装YouCompleteMe插件

cd ~/.vim/bundle/YouCompleteMe && ./install.py --all

make一遍的时候,第二遍make时会出现cached,所以第二次make的时候还会使用第一次的执行结果,所以想修改就必须清除make操作之后,两次make

make uninstall   //卸载
make clean  

rm -f src/auto/config.cache
0 0