Activate the versions and the virtualenvs of pyenv within a live VIM session
VimL Python
Latest commit bed0d8b May 18, 2016 @lambdalisue Merge pull request #20 from ryunix/fix-typo
Fix typo
Permalink
Failed to load latest commit information.
autoload Fix exception Feb 28, 2016
doc Fix typo May 17, 2016
plugin Add 'ctags' of activated environment Jul 25, 2015
statics initial May 20, 2014
.gitignore initial May 20, 2014
README.md
initialize.py Aggressive refactoring May 28, 2015
pyenv_vim.py Aggressive refactoring May 28, 2015

README.md

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

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 major_version = pyenv#python#get_internal_major_version()
    call jedi#force_py_version(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.