nvim-telescope / telescope-media-files.nvim

Telescope extension to preview media files using Ueberzug.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Preview is displayed on top of the Previewer border

jonathannerat opened this issue · comments

Here's how it looks right now:

image

I'm using neovim v0.6.0-dev+151-ge01b88c79, ueberzug v18.1.9.

Here's a minimal config that reproduces this behaviour:

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      {
        'nvim-telescope/telescope.nvim',
        requires = {
          'nvim-lua/plenary.nvim',
          'nvim-lua/popup.nvim',
          { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' },
        },
      },
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
      'nvim-telescope/telescope-media-files.nvim',
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
      display = { non_interactive = true },
    },
  }
end
_G.load_config = function()
  require('telescope').setup()
  require('telescope').load_extension('fzf')
  -- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
  require('telescope').load_extension('media_files')
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing Telescope and dependencies.")
  vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path }
end
load_plugins()
require('packer').sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]]

Then run :Telescope media_files.

There's a "dirty" way to fix this, by just changing the parameters passed to the script that eventually display the content:

diff --git a/lua/telescope/_extensions/media_files.lua b/lua/telescope/_extensions/media_files.lua
index 6e779ee..f19061f 100644
--- a/lua/telescope/_extensions/media_files.lua
+++ b/lua/telescope/_extensions/media_files.lua
@@ -33,7 +33,7 @@ M.media_preview = defaulter(function(opts)
         M.base_directory .. '/scripts/vimg' ,
         string.format([[%s]],tmp_table[1]),
         preview.col ,
-        preview.line ,
+        preview.line + 1,
         preview.width ,
         preview.height
       }

But I'm not really sure if this is the best way to do this. Maybe something changed in the preview table, like before we used to get coordinates inside but now they are outside?