Closed beyarkay closed 1 year ago
GH doesn't support uploading ipynb files, so here's the raw text of a minimal Jupyter notebook to reproduce the issue:
Don't have an answer to this unfortunately. Known issue: https://github.com/neovim/pynvim/issues/489
Possible workaround: https://github.com/neovim/pynvim/issues/326#issuecomment-403166302
Thanks for the swift reply
A workaround is to use nest_asyncio. It is not a perfect solution as the behavior of nested asyncio loop can be quite unintuitive and strange, but works at least minimally:
[1]: import nest_asyncio
nest_asyncio.apply()
[2]: from pynvim import attach
nvim = attach('socket', path='/tmp/nvim.sock')
[3]: nvim.current.buffer[:] = 'foo'
I've got a jupyter notebook, from which I want to control an instance of neovim. Following the instructions in the pynvim repo, I can setup neovim to listen like so:
and then I can control that instance of neovim from a regular (non-notebook) python session like so:
The above all works fine from a regular python session (
python3
oripython
) but it doesn't work from a jupyter notebook. Trying to run the following cell:Results in the following error:
Which looks like both jupyter and pynvim are trying to run async loops at the same time. I'm not sure how to get around the issue though.
How can I control neovim from a python jupyter notebook?
I'm running on a Mac, Python 3.11.3, IPython version 8.4.0, ipykernel version 6.15.1, pynvim version 0.4.3