Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show image preview when open inside neovim #112

Closed
minhtien3297 opened this issue Jun 12, 2024 · 13 comments · Fixed by #116
Closed

Don't show image preview when open inside neovim #112

minhtien3297 opened this issue Jun 12, 2024 · 13 comments · Fixed by #116

Comments

@minhtien3297
Copy link

When opened inside neovim, the image preview just doesn't work

Screenshot 2024-06-12 at 3 52 49 PM

This is when open outside of neovim

Screenshot 2024-06-12 at 3 51 42 PM

@mikavilpas
Copy link
Owner

I have this issue myself. I looked into it a while ago and I think this is not supported in neovim's embedded terminal yet.

I don't know if this can be resolved until support is added. Let's keep this open to track the status as well as any additional findings and ideas.

@daUnknownCoder
Copy link

daUnknownCoder commented Jun 12, 2024

@mikavilpas buddy check this out: https://new.reddit.com/r/neovim/comments/1dcjuxc/simplyfilenvim_now_can_use_3rdimagenvim_to/

might be able to steal 😉 some code

@mikavilpas
Copy link
Owner

Ok, nice find - that was fast 😄 ! I think that might work nicely, but one issue remains: in neovim, we don't yet know
what is being previewed in yazi.

This is actually a neovim specific limitation and can be worked around with e.g. my proposal at
sxyazi/yazi#1004, which would add the ability to read events from the embedded yazi process in
real time. Currently we can only read them after yazi has closed.

So it would work like this:

sequenceDiagram
  neovim->>yazi: open yazi
  yazi->>neovim: file hovered event: /path/to/image.png
  neovim-->neovim: preview image
  yazi->>neovim: file hovered event: /path/to/file.txt
  neovim-->neovim: 🔎 not an image, don't preview anything
Loading

@mikavilpas
Copy link
Owner

I also wonder if this would work if yazi were configured to use https://github.com/jstkdng/ueberzugpp with yazi. I haven't tried this out, so it might be subject to the same neovim terminal limitation which causes images not to show.

@daUnknownCoder
Copy link

we don't yet know what is being previewed in yazi.

we can check the filetype? restrict the config to jpg, png, ...

@mikavilpas
Copy link
Owner

The issue is not yet knowing the name of the file that is hovered in yazi.

@daUnknownCoder
Copy link

I also wonder if this would work if yazi were configured to use https://github.com/jstkdng/ueberzugpp with yazi. I haven't tried this out, so it might be subject to the same neovim terminal limitation which causes images not to show.

https://yazi-rs.github.io/docs/configuration/yazi/#preview.ueberzug_scale

@mikavilpas
Copy link
Owner

Want to do an experiment with yazi + ueberzugpp + yazi.nvim to see if it works with this configuration? 🙂

@daUnknownCoder
Copy link

Want to do an experiment with yazi + ueberzugpp + yazi.nvim to see if it works with this configuration? 🙂

wait what? it already works there's no need for anything to be done 🙃, i havent updated, i dont use image.nvim

Important

we have to pass something to the main config of yazi for the ueberzug offset (~/.config/yazi/yazi.toml)

[preview]
ueberzug_offset = [7.5,1,0,0]

Important

this ⬆️ is what i configured for correct display of image, and it might be different for different people, as u might see the below images, the ueberzug offset is messed up ...

opts = {
    floating_window_scaling_factor = 1,
}

image

opts = {
    floating_window_scaling_factor = 0.8,
}

image

direct yazi window:
image

@mikavilpas
Copy link
Owner

Oh, nice! Excellent work!

@daUnknownCoder
Copy link

Oh, nice! Excellent work!

ok i didnt do anything, my ueberzug wasnt working (i hadnt updated it for a while) :p

@sxyazi
Copy link

sxyazi commented Jun 16, 2024

Regarding Yazi's behavior in Neovim: https://yazi-rs.github.io/docs/image-preview#neovim

@mikavilpas
Copy link
Owner

Awesome - thanks for the link!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants