Closed Acumane closed 2 hours ago
We already have the hide-preview.yazi
plugin, and it provides an API to do so.
Based on that, implementing your request is very easy and only requires a few lines of Lua code, save these lines as ~/.config/yazi/plugins/contextual-preview.yazi/init.lua
:
local function setup()
ps.sub("hover", function()
local h = cx.active.current.hovered
if not h then
return
end
local is_image = (h:mime() or ""):find("image/") ~= nil
if is_image == require("hide-preview"):enabled() then
require("hide-preview"):entry()
end
end)
end
return { setup = setup }
Then enable it in your init.lua
:
require("contextual-preview"):setup()
https://github.com/user-attachments/assets/e07a0313-0ad2-4e5e-988e-23c48b48f5ae
Doc of the folder::File
userdata: https://yazi-rs.github.io/docs/plugins/types#app-data.folder-file
Doc of the DDS API: https://yazi-rs.github.io/docs/plugins/utils#ps
yazi --debug
outputPlease describe the problem you're trying to solve
Only show the preview panel for certain MIME types and optionally hide it on error/unsupported types.
Would you be willing to contribute this feature?
Describe the solution you'd like
Example: I really only care to see previews of images
(I know it's under
[open]
but we're already enumerating MIME types here, so...)Additional context
No response
Validations