DEV Community

Cui Mingda
Cui Mingda

Posted on

How to config python provider for neovim

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

which python
# /usr/bin/python

which python3
# /usr/bin/python
Enter fullscreen mode Exit fullscreen mode

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

let g:python_host_prog = '/usr/bin/python'
let g:python3_host_prog = '/usr/bin/python3'
Enter fullscreen mode Exit fullscreen mode

安装Python2的provider

python -m pip install pynvim --user
Enter fullscreen mode Exit fullscreen mode

安装Python3的provider

python3 -m pip install pynvim --user
Enter fullscreen mode Exit fullscreen mode

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

python3 -m pip install --upgrade pip --user
Enter fullscreen mode Exit fullscreen mode

最后,打开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.
Enter fullscreen mode Exit fullscreen mode

Top comments (0)