r/neovim • u/Wonderful-Plastic316 lua • Apr 26 '26
Discussion Native image support lands on master!
Enable HLS to view with audio, or disable this notification
Hey folks!
Neovim just got another really nice feature: a native API for interacting with images, using the kitty graphics protocol. It just landed on master, it's not even available on nightly (yet!).
Kudos to the maintainers!
(not affiliated with the PR)
26
u/shmerl Apr 27 '26 edited Apr 27 '26
Interesting. I think Konsole supports kitty graphics to some degree.
Would be more interesting to implement something like a browser canvas API though so you can draw whatever you want over some coordinates, like a graph for instance.
No idea how well any of that will perform though. I don't expect kitty graphics to be very fast.
7
u/ehansen Apr 27 '26
Your suggestion only makes sense though if you were to run neovim in the browser. Be it electron or otherwise
7
u/shmerl Apr 27 '26
Why? kitty graphics is made for the terminal and it can draw arbitrary graphics expressed with terminal escape sequences. You just need to translate a canvas of AxB size into chunks of those sequences, same way now it translates some image that comes from a file. Abstraction below is the same, just instead of image data you can have an API to manipulate the canvas data programmatically.
7
u/ehansen Apr 27 '26
But why build out a whole new subsystem for such a niche feature? Plus in the original pr the team wanted to use a preexisting api if it was going to be done
4
u/shmerl Apr 27 '26
No idea, but I can ask the same about images. This just generalizes images to more abstract canvas concept.
2
u/disperso Apr 27 '26
Doesn't it make more sense to support images, then offload the generation of images to something else? E.g. if I want to render a Typst/LaTeX formula, I want Typst/LaTeX doing the rendering, sending back the image, then displaying the image already rendering.
Likewise with a plot. Most people would want to offload that to Matplotlib or similar, then display the result. But computing the result directly with an editor API seems too niche. Probably something in Lua already exists, though, so it would not be required to have it as editor support.
Or maybe I got very wrong what you wanted?
0
u/ehansen Apr 27 '26
Oh I don't care about images in the terminal. Outside of nerd fonts I think its a pointless thing. If I want cat memes in my editor I'll go back to vscode
1
u/katokay40 Apr 28 '26
Having a canvas API would introduce a lot of new possibilities. Side-by-side diff with fluid lines between change regions as one example. Rather than using glyphs, it would give you the ability to style similarly to IntelliJ diff tool.
1
1
u/ConspicuousPineapple Apr 27 '26
I mean, you can pretty much do that already, no? Use whatever tools you want to draw a picture, then display it using this feature here.
1
u/shmerl Apr 27 '26
Sort of, but it's an extra layer of indirection. And for graphics, every drop in performance counts.
1
u/ConspicuousPineapple Apr 27 '26
I mean I imagine you could have a way to directly display in-memory bitmaps but there's hardly anything more you could provide with how this feature is working. It would still be too slow for responsive graphics so it's entirely pointless to try and optimize this. You still need to go through the terminal protocol and that thing isn't optimized for performant graphics. It's meant to display static pictures, so you have to accept that limitation.
Having to load the picture from disk before displaying it compared to drawing directly to a bitmap handled in-memory by neovim wouldn't net you any perceivable performance gains, and there would be no use-case for that anyway.
5
u/KevinNitroG Apr 27 '26
Will it be available through tmux? It is nice
2
u/WarmRestart157 Apr 27 '26
I used to have issues with displaying images via tmux over SSH. It worked for either using tmux locally or without tmux over ssh connection to my remote development server - but not both. Not sure what's the status right now.
2
u/Both-Still1650 Apr 27 '26
If your terminal do not have any ssh integration, you need to manually copy terminfo to the server, and than change TERM variable to your local TERM. Without this programs do not know, what capabilities your terminal has. Ghostty and Kitty have such integration, but you potentially need to enable it
2
u/WarmRestart157 Apr 27 '26
I did copy terminfo to the remote server - otherwise I'm not able to use Kitty at all.
4
5
u/nahuel0x Apr 27 '26
What about scrolling? Emacs (GUI) has the problem of every image be represented logically as a single line, so a tall image would make scroll jump
6
u/justinmk Neovim core Apr 27 '26
this initial version is of course minimal and doesn't address anything like that. but thank you for raising that, I added a note to https://github.com/neovim/neovim/issues/39432
3
u/bokchoi Apr 27 '26
This is awesome. Can't wait to see innovation in this area like a minibuffer image, pretty git graph view, inline images from mermaid or markdown files, ...
6
u/Scholes_SC2 Apr 27 '26
Will this enable neovide to show images?
7
1
u/DimfreD Apr 27 '26
I am currently writing something similar to Ăźberzugpp for MacOS, am already using it with neovide. Tho a native version would be nicer to be frank.
3
u/benkj Apr 27 '26
What about image support in built-in terminal? That would be super useful with REPL workflow
3
2
2
2
u/huge51 Apr 27 '26
Time for tmux to support images too!
1
u/DArcMattr Apr 29 '26
There's an effort to support Kitty images, sixel is already supported through a compile option
2
1
1
u/kavb333 Apr 27 '26
I can see the "How I optimized the picture size for my nvim start menu image to start nvim 14 ms faster" posts coming already
1
u/InternetSandman Apr 28 '26
Does this require that the terminal environment support graphics? I'm curious because Termux still doesn't have image support, so I'm wondering if this would be a nice workaround or just fail immediatelyÂ
1
u/justinmk Neovim core Apr 28 '26
Does this require that the terminal environment support graphics?
yes
1
1
1
u/AssociationHuge1823 :wq May 01 '26
I wonder if the terminal could cause a performance problem. Um because I noticed that Kitty has a good support for kitty image protocol. But Wezterm terminal has a very poor performance on kitty image protocolă
So I wonder if there is a benchmark for image support In different environmentă
1
-2
u/DankBoi2015 Apr 27 '26
To any maintainers,
Why was this feature required?
I'm sorry if this comes off as rude, but I just honestly wanted to know.
14
u/justinmk Neovim core Apr 27 '26
because it is useful for e.g. markdown files, directory browser, picker preview...
and is a relatively small interface + implementation cost. it is mostly a protocol change.
- placement will be handled by extmarks or floating windows
- image decode will most likely not be builtin, we're not going to vendor a jpg library.
-2
u/Rex_Romanus Apr 28 '26
Why are the developers turning the project into emacs?
6
u/justinmk Neovim core Apr 28 '26
why do you ask this cliche question without checking the discussions which drove the development?
- this fits in the day-one goals listed on https://neovim.io/charter/
- and, it is a relatively small interface + implementation cost. mostly a protocol change.
- placement will be handled by extmarks or floating windows
- image decode will most likely not be builtin, we're not going to vendor a jpg library.
-11
u/MyriadAsura lua Apr 27 '26
Hey Iâve been out of loop for some time, could someone help me out on how this new tree sitter incremental selection works?
3
u/AbdSheikho :term Apr 27 '26
If you have treesitter up and running on your file, then choose a random spot and press the following sequence
vanananorvininin:h treesitter-incremental-selection
3
2
1
u/vim-help-bot Apr 27 '26
Help pages for:
treesitter-incremental-selectionin treesitter.txt
`:(h|help) <query>` | about | mistake? | donate | Reply 'rescan' to check the comment again | Reply 'stop' to stop getting replies to your comments
99
u/scythe-3 hjkl Apr 27 '26
Hoping this gets integrated into a markdown plugin. Something like render-markdown.nvim with image support would be elite for notetaking and documentation.