Vigemus / iron.nvim

Interactive Repl Over Neovim
BSD 3-Clause "New" or "Revised" License
1.01k stars 81 forks source link

[feature request] images in REPL #381

Open rwijtvliet opened 4 months ago

rwijtvliet commented 4 months ago

Running code in the ipython buffer created with iron, I noticed that images are not being drawn:

image

Whereas the same code in the terminal proper does draw the images:

image

From what I gather, there is an issue displaying images in the terminal buffer in vim. Yet, some plugins (e.g. magma) are able to draw images (maybe because they are not inside a terminal buffer?).

Either way, my feature request is to show images in ipython for sixel or kitty-image-protocol enabled terminals. Maybe using https://github.com/3rd/image.nvim ?

(I think it's not relevant, but my iron config in the first screenshot is:

      iron.setup {
        config = {
          scratch_repl = true,
          repl_definition = {
            sh = {command = { 'zsh' }},
            python = {
              format = require('iron.fts.common').bracketed_paste,
              command = { 'ipython', '-i', '--no-autoindent', '--nosep' },
            },
          },
          repl_open_cmd = require('iron.view').split.vertical.botright(0.40, {winfixwidth = false, winfixheight = false, number = true}),

PS: See this question on stackexchange for an overview of the options that I have tried.

frere-jacques commented 2 months ago

I had a look at your stackexchange question and looked at jupyter-vim.

If you are still interested in Iron, you can have the very same functionality with iron. Also with this setup you send multiline blocks as single execution.

Copied post from the discussion here https://github.com/Vigemus/iron.nvim/discussions/380#discussion-6821945:

python = {
  command = { "jupyter-console", "--ZMQTerminalInteractiveShell.image_handler=None" },
  format = require("iron.fts.common").bracketed_paste,
  block_deviders = { "# %%", "#%%" },
},

The option , "--ZMQTerminalInteractiveShell.image_handler=None" can be removed to get the jupyter-console default image display.

I had a look today at https://github.com/jupyter-vim/jupyter-vim. They open qtconsole in an extra window and attach it to the jupyter-console kernel. I can do now the same and can see the repl output like images in qtconsole while sending with iron code from my buffer to the python-console in the nvim buffer. This works even, if the iron buffer is hidden.

Just start the repl in iron and then in a different terminal run jupyter qtconsole --existing --ConsoleWidget.include_other_output=True or set this option in the config file, like instructed in jupyter-vim.