首页 > 解决方案 > (Neo)vim python 支持和活动 virtualenv 冲突

问题描述

我在 Neovim 下通常支持 Python

init.vim

" Plug 'plytophogy/vim-virtualenv'

 if has('nvim')
  Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
 else
  Plug 'Shougo/deoplete.nvim'
  Plug 'roxma/nvim-yarp'
  Plug 'roxma/vim-hug-neovim-rpc'
 endif
 Plug 'zchee/deoplete-jedi'
 Plug 'davidhalter/jedi-vim'

当我nvim在某些虚拟环境处于活动状态时启动时,它以此错误消息开头

UltiSnips requires py >= 2.7 or py3
Press ENTER or type command to continue

当然还有更多。

我个人并不感到惊讶。插件的 Python 代码不应该在与它无关的虚拟环境中运行。然而我必须这样做。我能做些什么?

vim-virtualenv显然与这个问题没有任何关系。也没有解决它。

标签: pythonvimvirtualenvneovim

解决方案


有关Neovim 提供程序,请参阅此文档:

PYTHON PROVIDER CONFIGURATION ~
                        *g:python_host_prog*
Command to start Python 2 (executable, not directory). Setting this makes
startup faster. Useful for working with virtualenvs.  >
    let g:python_host_prog  = '/path/to/python'
<
                        *g:python3_host_prog*
Command to start Python 3 (executable, not directory). Setting this makes
startup faster. Useful for working with virtualenvs.  >
    let g:python3_host_prog = '/path/to/python3'

推荐阅读