magma-nvim icon indicating copy to clipboard operation
magma-nvim copied to clipboard

Request - Persistent output below cell

Open Lun4m opened this issue 3 years ago • 3 comments

Would it be possible to have a persistent output "window" below the executed cell that doesn't cover the code? Something like in this other plugin that reads .ipynb files.

Lun4m avatar Aug 18 '21 14:08 Lun4m

The thing is that it's currently impossible to add content between lines of a buffer without changing its text.

Simply changing the buffers' text is problematic; to name a few issues:

  • Syntax highlight would probably get messed up
  • Diagnostics&LSP would probably get messed up
  • Treesitter and plugins which use treesitter would probably get messed up
  • If we are not extremely careful, we might end up writing our content/extra newlines to the actual file
  • Line numbers are changed

But there is work in progress for this:

  • https://github.com/neovim/neovim/pull/15351
  • https://github.com/neovim/neovim/pull/9496

We could also try to add some hacky solutions for this (e.g., maybe something with diff mode?), but I'm not very confident.

dccsillag avatar Aug 18 '21 14:08 dccsillag

Yeah, I assumed it was impossible, but I still wanted to ask because having the persistent output window would almost completely replicate the Jupyter notebook experience. The two pull requests you linked sound promising though, so hopefully it's something that can be implemented in the future!

Lun4m avatar Aug 18 '21 15:08 Lun4m

This isn't a perfect solution by any means but either a good alternative which will potentially provide parts of a solution or a separate request.

What you could do is allow connecting to the same jupyter kernel with a different frontend, which would end up being something like jupyter console a la https://github.com/jpalardy/vim-slime, which would allow using stuff like https://github.com/jktr/matplotlib-backend-kitty or something like https://github.com/joouha/euporie.

Users can then toggle that pane (which is my current notebook set up pretty much, a Lua copy of vim-slime I wrote and then matplotlib kitty in a separate kitty pane controlled by the kitty remote control)

yingzhu146 avatar Aug 20 '21 17:08 yingzhu146