How to config python provider for neovim

先确认Python2和Python3的执行路径:

which python
# /usr/bin/python

which python3
# /usr/bin/python

修改~/.config/nvim/init.vim,增加python运行路径的设置

let g:python_host_prog = '/usr/bin/python'
let g:python3_host_prog = '/usr/bin/python3'

安装Python2的provider

python -m pip install pynvim --user

安装Python3的provider

python3 -m pip install pynvim --user

如果提示pip需要升级,我们就升级一下

python3 -m pip install --upgrade pip --user

最后,打开nvim,运行:checkhealth检查一下,可以看到成功配置的信息:

## Python 2 provider (optional)
  - INFO: Using: g:python_host_prog = "/usr/bin/python"
  - INFO: Executable: /usr/bin/python
  - INFO: Python version: 2.7.16
  - INFO: pynvim version: 0.4.3
  - OK: Latest pynvim is installed.

## Python 3 provider (optional)
  - INFO: Using: g:python3_host_prog = "/usr/bin/python3"
  - INFO: Executable: /usr/bin/python3
  - INFO: Python version: 3.8.2
  - INFO: pynvim version: 0.4.3
  - OK: Latest pynvim is installed.

43