Tip 3 | Enabling Python Support in Neovim |
In Neovim, Python is not supported out of the box. If you want to use plugins and tools that are implemented in Python (such as neovim-remote), then you’ll have to install the Python client.
In Vim 8, you can have support for either Python 2 or Python 3. (You could have support for neither, but you can’t have support for both!) Find out which version of Python is supported in Vim 8 by running :version and looking for +python or +python3. If your version of Vim 8 has support for Python 2, but you need Python 3, you’ll have to recompile Vim.
In Neovim, however, you can enable support for both Python 2 and Python 3 at the same time. Try running this command in Neovim:
=> | :py3 print('hello') |
<= | E117: Unknown function: provider#python3#Call |
The :py3 {statement} command executes the specified statement using a Python 3 interpreter. If this doesn’t work out of the box, you can fix it by setting up the Python provider.
To enable the Python 3 provider, you need to install the Python client.[14] You can get this using pip:
=> | $ pip3 install --user --upgrade neovim |
Now restart Neovim and try running this command again:
=> | :py3 print('hello') |
<= | hello |
You’ll see the hello message printed.
Neovim-remote[15] by Marco Hinz is a tool that lets you control Neovim processes remotely. It depends on the Python 3 Neovim client, so make sure you have that installed before you proceed.
Install the neovim-remote tool with pip:
=> | $ pip3 install --user --upgrade neovim-remote |
The package is called neovim-remote, but the executable is abbreviated to nvr. Check that it’s installed okay by consulting the help:
=> | $ nvr -h |
<= | usage: nvr [arguments] |
| |
| Remote control Neovim instances. |
| ... |
For an example of how to use neovim-remote, skip ahead to Tip 21, Avoiding Nested Neovim Instances.
3.147.104.120