Accessing the tty from Neovim to show images with Notcurses


I’m the author of a Neovim plugin for interacting with Jupyter kernels from Neovim, GitHub - dccsillag/magma-nvim: Interact with Jupyter from NeoVim..
One of our features is to be able to show images “inside” neovim, as can be seen in the GIF in our README.

Our main (and the only non terminal-specific) way of showing images uses Ueberzug. However, we’ve found it is Linux-only, and has some issues with some terminal emulators. As such, we’ve been looking at showing images with Notcurses, a very prominent TUI library which has support for showing images with whichever terminal-specific protocol is available, using all the necessary hacks and even giving support for images in the framebuffer. The library’s author is also very cooperative, which is great.

However, we’ve hit a nag: for us to initialize and use notcurses, we need to have access to the current tty. But apparently Neovim does quite a bit of magic which we failed to understand: Help with using Notcurses through Neovim · Issue #2308 · dankamongmen/notcurses · GitHub. Right now, we are a bit at a loss of what is happening / what to do. Help for someone more experienced with Neovim internals would be highly appreciated!

1 Like

I haven’t looked into your source code, but how are you spawning the process that is attempting to write to /dev/tty? This issue might be relevant: :! (bang) and system() are not interactive · Issue #1496 · neovim/neovim · GitHub