jupytext
jupytext copied to clipboard
Driving jupyter from vim, a suggestion
Hello, this is not an issue but a question on a jupytext related subject.
I am usually using jupytext
in the following workflow
- Edit a
.R
file in vim using Nvim-R, to be able to send lines directly to terminal - Open a
ipynb
in parallel automatically synced usingjupytext
withR:spin
Every now and then I switch to the ipynb and execute/update a few cells, most of the times graphs. The ipynb
is really just a way to have a document holding many graphs, that gets gradually updated. That's the best way I found so far, while it is possible to have a process continuously knitting source it quickly gets unpractical when some largish data is involved.
I feel that this workflow must be common to jupytext users (as people are probably using jupytext to stay in text editors).
It feels to me that being able to execute a cell from vim, emacs, ...
would be super slick and that jupytext is somewhat not "far" from providing something like that (some bindings would be required from the editor)
Does such a tool already exists (I only know of vimpyter but it does not seem active any more) ? Do you think it could be something that jupytext help to achieve ?
I understand open-source is not free advice so please feel free to close this issue without answering. Many thanks for jupytext, it's great
Hi @statquant , thanks for asking.
I think it should be possible to execute code from Vim in the same R or Python session that is being used in Jupyter. That will at least update the variables in your notebook (not the outputs, though).
Does the %connect_info
magic command works in R notebooks? If so, you could try connecting to the kernel being used by the notebook by passing the output to jupyter console
.
This is not Vim exactly, but maybe someone can figure out how to send the code from the editor to the jupyter console
. A project that was doing something like this was Paul @ivanov's vim-ipython plugin. I don't think you can expect it to work now, but if you want to look at how it works (exchanging commands and outputs with the kernel) it is very instructive - at least I had a great time a few years back studying that project!
Thanks for the mention, @mwouts - I think some folks are maintaining a blessed continuation of vim-ipython over here: https://github.com/jupyter-vim/jupyter-vim
Oh that is super interesting! Thank you Paul for the update.
@statquant , I see that jupyter-vim
has support already for a Matlab mode with ##
markers for cells, maybe they will be interested in supporting the # %%
cells that Jupytext (and Spyder, and Hydrogen, and VS Code, and Pycharm) use. Would you like to open an issue there? I think a possible roadmap could be
- Support the
# %%
cells in jupyter-vim - Execute the code with the jupyter kernel (already the case) and update the
.ipynb
file accordingly (to be implemented) - Add support for more kernels like R
I am not a Vim user myself but I'd be glad to collaborate on the some part of the projects like e.g. the execution and update of a specific cell.
Hello, I wanted to come back to share a project I only v recently discovered: https://github.com/dccsillag/magma-nvim I think it is pretty amazing.
Hi @statquant , thank you for sharing the link. Does it work well with Jupytext notebooks? I mean, can you select a whole # %%
cell for execution?
If so maybe we could add the link to the documentation, what do you think? Also I see that the link to jupytext.vim
is only in the FAQ at the moment, maybe we could move the two links together.
Coming back on this I think it might be it: https://github.com/untitled-ai/jupyter_ascending Unfortunately it does not support the R or the kdb kernel (only py) and the development seems to have stalled for a few months.
Another message to say that this is solved by https://github.com/kiyoon/jupynium.nvim
Oh that's neat! Thank you for letting us know!