Open khughitt opened 8 years ago
Adding my support for this. I use R + neovim (with the Terminal method mentioned above) and it's brilliant. But I need to work with Python too. Would love this big feature.
It would be great indeed. In the meantime, there is a nice little plugin that I have been using for python, it supports terminal as for the R plugin. It's early in dev and simple but it does the job: https://github.com/hkupty/iron.nvim
In principle this shouldn't be too hard, after launching the kernel in nvim-ipy, also connect to it in a :terminal
using jupyter console --existing {connectionfile}
. We should add a helper function that determines the connectionfile and puts together the :term
command.
A simple proof of concept here #24, note you still need to launch :IPython
first, then do :IPySplitTerm
. A limitation in jupyter console is though that it only shows output from the terminal in the terminal, so you currently still need to use the [jupyter]
buffer to get output from nvim.
@bfredl I think there is already the solution to this limitation. The most maintained fork of vim-ipython
is by wilywampa, he added a lot of improvement, you should look into it.
Among his changes is a script monitor.py.
It could be run in the background, then when the jupyter console is launched it attaches to the kernel and echos what is processed.
I had this working with python2
, somehow I can't get this to work right now. But I am working on WSL, which has some problems with jupyter console
. The script might give you some insight anyway.
I don't see how the monitor script will help, it would just show the input/output which the [Jupyter]
buffer already does, it does not allow any interaction in the terminal.
I did some testing, apparently it works with ipython console
but not with jupyter console
. Sadly I have no insight how it works to fix this.
In a terminal you can do the following:
python monitor.py&
ipython console
Now you have an ipython console to work with, but it will also print what connected sessions execute.
I used it with vim-ipython, having one terminal with the ipython console
and another one with vim. The ipython console
printed everything I sent with vim.
nvim-ipy
seems to work differently, monitor.py
doesn't print things from it. Also it works only with ipython console
, not with jupyter console
~Also it seems to not work when run form within neovim
.~ The combination of neovim's :terminal
and vim-ipython works fine.
I just tested on nvim-ipy with a recent version of NeoVim and IPython 4.2.0, and can successfully connect to IPython from NeoVim using
:IPython
.Currently, however, commands which are sent to IPython,and the corresponding results are displayed in a NeoVim buffer.
Instead of using a buffer, would it be possible to make use of NeoVim's built-in terminal support? This way, in addition to send commands to the terminal, one could also interact with the IPython console directly in NeoVim.
This has been done with R, for example: https://github.com/jalvesaq/Nvim-R
Is this something that might be possible with IPython as well?