vim-pyenv


Ⅰ. 插件描述

Activate the versions and the virtualenvs of pyenv within a live VIM session

Ⅱ. 基本信息

创建日期:  2014-05-20
使用用户:  118
Github星:  96
插件作者:  Alisue

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'lambdalisue/vim-pyenv'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'lambdalisue/vim-pyenv'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'lambdalisue/vim-pyenv'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/lambdalisue/vim-pyenv

Ⅳ. 文档说明

vim-pyenv

vim-pyenv allows you to activate and deactivate the pyenv Python correctly
in a live Vim session.

pyenv is a simple Python version management
system and users can change the Python versions in a simple way.
However, if you use pyenv to switch the Python version or virtualenv, the
omni-completion would not work correctly.
This is because Vim refers to the system Python and does not know anything
about the pyenv Python, especially the packages you installed on the pyenv
Python.

vim-pyenv activates the pyenv Python and adds the external Python library
search path (PYTHONPATH) to Vim's internal Python PYTHONPATH.
Thus, with vim-pyenv, your jedi-vim
or any kind of Python omni-completion system returns a correct completion list.

![vim-pyenv allows you to select pyenv Python within a live Vim
session](./statics/_screenshot01.png)

Additionally, vim-pyenv supports Vim's dual Python 2 and 3 system.
If your Vim is compiled with +python and +python3, vim-pyenv automatically
synchronizes the Python version to the external Python version.

jedi-vim omni completion works correctly

Documentation

See :help vim-pyenv in Vim.

Installation

Installing vim-pyenv by using Neobundle
is strongly recommended, because with Neobundle you can specify the
dependencies of the plugins via depends options.
The following is an example of Neobundle entry which specifies jedi-vim as a
dependency.

NeoBundle 'davidhalter/jedi-vim'

" Do not load vim-pyenv until *.py is opened and
" make sure that it is loaded after jedi-vim is loaded.
NeoBundleLazy 'lambdalisue/vim-pyenv', {
        \ 'depends': ['davidhalter/jedi-vim'],
        \ 'autoload': {
        \   'filetypes': ['python', 'python3'],
        \ }}

You can use vundle or
pathogen, but make sure
that vim-pyenv is loaded after jedi-vim.

Using vim-pyenv with jedi-vim

vim-pyenv-activate-post and vim-pyenv-deactivate-post autocmd can be used
to change the major version of jedi like

if jedi#init_python()
  function! s:jedi_auto_force_py_version() abort
    let g:jedi#force_py_version = pyenv#python#get_internal_major_version()
  endfunction
  augroup vim-pyenv-custom-augroup
    autocmd! *
    autocmd User vim-pyenv-activate-post   call s:jedi_auto_force_py_version()
    autocmd User vim-pyenv-deactivate-post call s:jedi_auto_force_py_version()
  augroup END
endif

The code above automatically call jedi#force_py_version every after user change a python version of pyenv via :PyenvActivate or :PyenvDeactivate command.

添加新评论