stevearc / oil.nvim

Neovim file explorer: edit your filesystem like a buffer
MIT License
4.04k stars 122 forks source link

feature request: customize preview content #396

Open ndavd opened 5 months ago

ndavd commented 5 months ago

Did you check existing requests?

Describe the feature

Ideally, oil.nvim could replace any TUI file explorer, and it's not far from that. One thing that would be missing would be custom previewers, so that for example one could create a preview for image types, another for PDF types, and so on.

Provide background

No response

What is the significance of this feature?

strongly desired

Additional details

No response

daliusd commented 4 months ago

There is plugin that supports image previews for oil https://github.com/adelarsq/image_preview.nvim?tab=readme-ov-file

It is not ideal but better than nothing.

daliusd commented 4 months ago

Here is my idea how to preview images, svg files, pdf files and etc.: https://www.reddit.com/r/neovim/comments/1e1txpz/comment/lcxrkbr/?context=3

oil.nvim could expose some new API methods, e.g. add possibility to add callback on file preview and this way it would be possible to use something external.

stevearc commented 4 months ago

I don't think oil needs to do anything in particular here. When we preview the file, we're just opening the buffer in another window. If you have a plugin that can display images in neovim, you can define a BufReadCmd autocmd that matches that filetype (*.png, for example) and customize the logic to display the image. Then it would work in general across all of neovim and not just for oil in particular.

daliusd commented 4 months ago

I don't think oil needs to do anything in particular here. When we preview the file, we're just opening the buffer in another window. If you have a plugin that can display images in neovim, you can define a BufReadCmd autocmd that matches that filetype (*.png, for example) and customize the logic to display the image. Then it would work in general across all of neovim and not just for oil in particular.

Problem is that preview in neovim is not always an option and preview can be done in different environment, e.g. in different split of terminal, or browser (why not?) and etc. It would be nice to have preview callback where plugins authors could do whatever they want. I have demonstrated that it can be done even now but IMHO that adds little performance hit.