ibhagwan / fzf-lua

Improved fzf.vim written in lua
MIT License
2.31k stars 150 forks source link

Blurring image preview #636

Closed TroySigX closed 1 year ago

TroySigX commented 1 year ago

Info

fzf-lua configuration ```lua require('fzf-lua').setup({ previewers = { builtin = { ueberzug_scaler = "cover", extensions = { ["gif"] = { "viu", "-b" }, ["png"] = { "viu", "-b" }, ["jpg"] = { "viu", "-b" }, ["jpeg"] = { "viu", "-b" }, }, }, }, }) ```

Description

Image is very blurry when previewing in fzf-lua, like this: image

This is the original image previewed through viu in terminal: image

ibhagwan commented 1 year ago

This happens due to the limitations of the neovim terminal, open a new terminal with :new | term and run viu inside and the result would be the same, not much I can do about it (that’s why you have to use viu -b).

You can try chafa, it works a bit better inside neovim.

TroySigX commented 1 year ago

Chafa doesn't work for me, it shows like this: image

How do I solve it, here's my config:

local img_previewer = { "chafa" }

require("fzf-lua").setup({
    previewers = {
        builtin = {
            ueberzug_scaler = "cover",
            extensions = {
                ["gif"] = img_previewer,
                ["png"] = img_previewer,
                ["jpg"] = img_previewer,
                ["jpeg"] = img_previewer,
            },
        },
    },
})
ibhagwan commented 1 year ago

Does it work if you open a terminal inside neovim with :new | term and run chafa <image_path.png>?

TroySigX commented 1 year ago

It doesn't

ibhagwan commented 1 year ago

It doesn't

Then you have your answer why it doesn’t work within fzf-lua, these media previews are mere suggestions I have no control over how or if they work within the neovim terminal.

TroySigX commented 1 year ago

Thank you!

ibhagwan commented 1 year ago

If you’re on Linux and use Xorg I recommend ueberzug, it works differently, it spawns an x-window on top of the preview pane, doesn’t use a terminal so it’s not bound by these limitations, will provide the most crisp previews.

TroySigX commented 1 year ago

It works perfectly, thank you so much!

ibhagwan commented 1 year ago

It works perfectly, thank you so much!

That’s great! Play around with the scaler to get the result you like most, possible options (from the ueberzug project page) are: "crop", "distort", "fit_contain", "contain", "forced_cover" and "cover" (default)