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

feature request: customize preview content

Open ndavd opened this issue 1 year ago • 4 comments

Did you check existing requests?

  • [X] I have searched the existing issues

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

ndavd avatar May 31 '24 13:05 ndavd

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 avatar Jul 09 '24 06:07 daliusd

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.

daliusd avatar Jul 13 '24 16:07 daliusd

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.

stevearc avatar Jul 16 '24 06:07 stevearc

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.

daliusd avatar Jul 16 '24 07:07 daliusd