image.nvim icon indicating copy to clipboard operation
image.nvim copied to clipboard

image does not flush on tmux session

Open fm39hz opened this issue 1 year ago โ€ข 17 comments

  • I enabled rendered at cursor, and it work flawlessly when on kitty terminal, but in tmux the image does not flush whatsoever, and will still show the image on every panel then keep spawning this error image image image
  • here is my plugin and tmux config:
return {
	{
		"3rd/image.nvim",
		ft = { "markdown", "quarto", "vimwiki" },
		dependencies = { "leafo/magick" },
		opts = {
			integrations = {
				markdown = {
					clear_in_insert_mode = true,
					only_render_image_at_cursor = true,
				},
			},
			html = {
				enabled = true,
			},
			editor_only_render_when_focused = true,
			window_overlap_clear_enabled = true, -- auto show/hide images when the editor gains/looses focus
			tmux_show_only_in_active_window = true,
		},
	},
}
set-option -a terminal-features 'xterm-256color:RGB'
set-option -g status-position top
set -gq allow-passthrough on
set -g visual-activity off
set -ga update-environment TERM
set -ga update-environment TERM_PROGRAM

fm39hz avatar Oct 30 '24 06:10 fm39hz

Wasn't able to reproduce this, do you have anything special / shell wrappers / something different going on? Kitty + tmux works ok for me.

3rd avatar Nov 02 '24 13:11 3rd

Same issue using tmux + kitty, works flawlessly without tmux on wezterm and kitty terminal. I am running it on m1 macbook pro.

uvxdotdev avatar Nov 19 '24 13:11 uvxdotdev

Same issue here, running outside of tmux on kitty works fine but with tmux the image stays

RUGMJ avatar Nov 23 '24 11:11 RUGMJ

Same issue here, works in ghostty (which supports kitty image protocol), but images get stuck with tmux + ghostty.

Update: it seems to not happen in a fresh tmux session, but it was happening in a session I had running for a while. Not sure what was different about that one.

b0o avatar Nov 23 '24 13:11 b0o

i got the same issue as well. am using leetcode.nvim and have the questions with images rendered on the side, even after closing the buffer and window it is stuck to my terminal on all the tmux sessions and on all my subsequent windows in the same place

reynard93 avatar Dec 03 '24 05:12 reynard93

I had this problem and setting tmux_show_only_in_active_window = true fixed it.

ficd0 avatar Dec 04 '24 00:12 ficd0

Any update on this? following the proposed solution by @ficcdaf didn't work for me, as I actually have it set already :/

SimonYde avatar Jan 02 '25 15:01 SimonYde

Same problem here, reproduced with ghostty + tmux and kitty + tmux. Both emulators work fine outside the tmux session.

crierr avatar Jan 06 '25 05:01 crierr

Can't reproduce on:

โžœ nvim --version
NVIM v0.11.0-nightly+e4bc8b5
Build type: Release
LuaJIT 2.1.1713773202
Run "nvim -V1 -v" for more info

โžœ tmux -V
tmux 3.5a

โžœ kitty --version
kitty 0.38.1

Which versions of Neovim, Tmux and Kitty does this happen with?

3rd avatar Jan 06 '25 13:01 3rd

The problem was due to nushell. The substitution syntax is different in nushell ๐Ÿ˜ข

From /tmp/nvim-image.txt

09:31:29.120661 [image.nvim] write: "\27Ptmux;\27\27_Gq=2,d=i,i=1,a=d\27\27\\\27\\" Error: nu::parser::parse_mismatch_with_did_you_mean

  ร— Parse mismatch during operation.
   โ•ญโ”€[source:1:20]
 1 โ”‚ tmux list-panes -t $(tmux display-message -p '#{client_session}') -F '#{pane_tty}' -f '#{pane_active}'
   ยท                    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   ยท                                           โ•ฐโ”€โ”€ expected valid variable name.
   โ•ฐโ”€โ”€โ”€โ”€

It works fine when I remove my shell option

-- vim.opt.shell = "nu"

crierr avatar Jan 09 '25 01:01 crierr

In the above screenshot, @fm39hz is using fish. Fish users may experience the same issue because fish also substitute with () instead of $()

I made this PR#267 to resolve the issue

crierr avatar Jan 09 '25 03:01 crierr

Thank you @crierr!

3rd avatar Jan 17 '25 22:01 3rd

This issue is still occurring in my environment (kitty+tmux).

I've tried all the suggested configuration options, but the problem persists.

I suspect the root cause is that the FocusLost event doesn't fire when nvim actually loses focus, but rather when focus returns to nvim. I attempted a workaround by executing img:clear() on all displayed images just before leaving the drawing area, but this didn't resolve the issue either.

endaaman avatar Feb 20 '25 06:02 endaaman

is anyone still having this issue?

3rd avatar Apr 22 '25 01:04 3rd

I also have the same problem even with tmux_show_only_in_active_window = true

First, I only have this in my .tmux.conf

set -gq allow-passthrough on
set -g visual-activity off

But when I ran :checkhealth this showed up in tmux section - โš ๏ธ WARNING focus-events is not enabled. |'autoread'| may not work.

So, I added this to my .tmux.conf and everything seem to work fine.

set -gq allow-passthrough on
set -g visual-activity off
set-option -g focus-events on

Chayanon-Ninyawee avatar Jun 20 '25 15:06 Chayanon-Ninyawee

For me tmux_show_only_in_active_window = true fixed the problem when changing windows, but still occurs in the tmux choose commands

gabrielmusskopf avatar Aug 31 '25 22:08 gabrielmusskopf

set-option -g focus-events on

This configuration fixed it for me. I should probably be added to the README/docs somewhere

ChausseBenjamin avatar Oct 02 '25 16:10 ChausseBenjamin