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

Recipe for permanently previewing an arbitrary file

Open snoblenet opened this issue 1 year ago • 1 comments

Could the README.md please include a recipe for permanently previewing an arbitrary Markdown file, even if that file is not currently open in a buffer.

snoblenet avatar Apr 02 '24 01:04 snoblenet

If you're okay with loading file into a buffer just once, then you could use a user command e.g.:

require('peek').setup({ close_on_bdelete = false, auto_load = false })

vim.api.nvim_create_user_command('PeekOpenFile', function(arg)
  vim.api.nvim_command('edit ' .. arg.args)
  require('peek').open()
  vim.api.nvim_command('bdelete')
end, { nargs = 1, complete = 'file' })

And you would use it like so: :PeekOpenFile path/to/file.md

Not ideal, but it's currently not possible to load preview without loading the file into a buffer. And I don't think something like that should / needs to be implemented.

toppair avatar Apr 09 '24 19:04 toppair