nvim-telescope / telescope-media-files.nvim

Telescope extension to preview media files using Ueberzug.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extension working but images are not showing

ls-devs opened this issue · comments

Hi,
I just installed the extension, everything seems to be working, I have no errors but the images are not showing on the right panel, I got no preview.
See :
image

Config :

Nvim :

NVIM v0.9.0-dev-525+ga7332ba9b
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/laurent/Utils/neovim/build/cmake.config -I/home/laurent/Utils/neovim/src -I/home/laurent/Utils/neovim/.deps/usr/include -I/usr/include -I/home/laurent/Utils/neovim/build/src/nvim/auto -I/home/laurent/Utils/neovim/build/include

Packer :

use({ "nvim-telescope/telescope.nvim", requires = { { "nvim-lua/plenary.nvim" } } })
use({ "nvim-telescope/telescope-media-files.nvim", requires = { { "nvim-lua/popup.nvim" } } })

Telescope.lua :

require("telescope").load_extension("media_files")


telescope.setup({
   extensions = {
    media_files = {
      -- filetypes whitelist
      -- defaults to {"png", "jpg", "mp4", "webm", "pdf"}
      filetypes = {"png", "webp", "jpg", "jpeg"},
      find_cmd = "rg" -- find command (defaults to `fd`)
    }
  },
	defaults = {
		file_ignore_patterns = {
			".git/",
			"node_modules/*",
		},
		mappings = {
			i = {
				["<C-j>"] = actions.move_selection_next,
				["<C-k>"] = actions.move_selection_previous,
				["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
				["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
			},
			n = {
				["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
				["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
			},
		},
	},
	pickers = {
		find_files = {
			theme = "dropdown",
			previewer = false,
		},
		buffers = {
			theme = "dropdown",
			previewer = false,
		},
	},
})

this can be caused by any of 3 2 reasons:

  • You haven't installed rg (though i would personally recommend fd here) or you are missing any of the mentioned dependencies required to render images. scratch that, your image shows that files were found
  • You are trying to use Ueberzug (the very core this plugin relies on), which has been discontinued and removed from pip/github/etc.
  • You are trying to use this plugin on a Mac

I have an alternative in the works (that also works on OSX), but I need to refine it a bit still with proper image scaling, you can find it here:
#35

you can import it as:

Plug 'HendrikPetertje/telescope-media-files.nvim', { 'branch': 'fix-replace-ueber-with-viu' }

or

use({ 
  "HendrikPetertje/telescope-media-files.nvim",
  branh = "fix-replace-ueber-with-viu"
  requires = { { "nvim-lua/popup.nvim" } } 
})

(make sure to install VIU as per instructions on https://github.com/nvim-telescope/telescope-media-files.nvim/blob/26cf84d25007544140a835c0644728e7a7e57d43/README.md)

My dotfile configuration for comparison:
https://git.hendrikpeter.net/hendrikpeter/pico-vim/-/blob/master/lua/peva/telescope.lua

(notice that on line 40 i call for the media-search specifically.. these image and video searches are not bundled in to the default git_files or find_files)

Hi,
I've tried to use it but I still get an error, please see (actually testing on my mac, not on my linux) :
(Not supported)

Capture d’écran 2022-12-20 à 12 34 07

What I've done :

Installing the plugin with your branch :

use({
	"HendrikPetertje/telescope-media-files.nvim",
         branh = "fix-replace-ueber-with-viu",
	requires = { { "nvim-lua/popup.nvim" } },
})

Installing viu :

tried with cargo, tried with brew too.
viu is working with cli , see :

Capture d’écran 2022-12-20 à 12 36 09

My configuration for telescope (tried to follow yours) :

local telescope = require("telescope")
local actions = require("telescope.actions")

if not telescope then
	return
end

if not actions then
	return
end
local function is_git_repo()
  local is_repo = vim.fn.system("git rev-parse --is-inside-work-tree")
  return vim.v.shell_error == 0
end



telescope.setup({
	defaults = {
		file_ignore_patterns = {
			".git/",
			"node_modules/*",
		},
		mappings = {
			i = {
				["<C-j>"] = actions.move_selection_next,
				["<C-k>"] = actions.move_selection_previous,
				["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
				["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
			},
			n = {
				["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
				["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
			},
		},
	},
	extensions = {
		media_files = {
			-- filetypes whitelist
			filetypes = { "png", "webp", "jpg", "jpeg", "gif", "mp4", "pdf" },
		},
	},
	pickers = {
		find_files = {
			theme = "dropdown",
			previewer = false,
		},
		buffers = {
			theme = "dropdown",
			previewer = false,
		},
	},
})
telescope.load_extension("media_files")

vim.keymap.set(
  'n', 
  '<leader>,', 
  function()

    if (is_git_repo()) then
      builtin.git_files()
    else
      builtin.find_files()
    end
  end
, {})

vim.keymap.set('n', '<leader>mf', telescope.extensions.media_files.media_files, {})

thanks for the reply @ls-devs, I removed the "not supported" warnings early on in my pull request (which where initially there to stop OSX users from using the app) and made them a lot more verbose in my pull request later on. are you sure that you cleaned the old repo up from your packer cache before installing mine?

thanks for the reply @ls-devs, I removed the "not supported" warnings early on in my pull request (which where initially there to stop OSX users from using the app) and made them a lot more verbose in my pull request later on. are you sure that you cleaned the old repo up from your packer cache before installing mine?

I didn't, but now even after cleaning cache and reinstalling I still get this error on OSX.
On my Linux, I have no errors, but the image is not displayed on the right panel too (viu cli works on my linux too I can see the image displayed in terminal).
Thanks for taking your time helping.

i pushed a little fix up to always render in blocks. i noticed on Iterm and on my gnome terminal that nothing was being rendered when i was outside tmux... it can't fit images in.

it's odd that you are getting this error, I don't think there is any code left in the bash script that could echo that error to the console view in the preview window 😅

So how did you manage to make it work on your presentation ?

i pushed a little fix up to always render in blocks. i noticed on Iterm and on my gnome terminal that nothing was being rendered when i was outside tmux... it can't fit images in.

Can't see any new commit on your repository, where did you push your fix ?

I'll try to run it with your config in a while. mine seems to be working fine, pushed additional things, but that is not fixing your issue i think (just resizing)

I'll try to run it with your config in a while. mine seems to be working fine, pushed additional things, but that is not fixing your issue i think (just resizing)

If you want to see the full config you can visit my nvim setup repository.
Thank you for helping 👍🏼

I ran your full config and I can reproduce your whoes!

it looks like when telescope-media-files gets pulled down that it just completely ignores the branch setting.
image

Everything starts working when i manually checkout to the correct branch, that's not really a desirable option though, I'm still on the Plug side of things, you might do some research to see if you can force packer to use the right branch.

(side-note: interesting choice to put leader on space-bar, took me a while to figure that one out :p)

I ran your full config and I can reproduce your whoes!

it looks like when telescope-media-files gets pulled down that it just completely ignores the branch setting. image

Everything starts working when i manually checkout to the correct branch, that's not really a desirable option though, I'm still on the Plug side of things, you might do some research to see if you can force packer to use the right branch.

(side-note: interesting choice to put leader on space-bar, took me a while to figure that one out :p)

Wow ! A huge thank ! I never would have thought to check this...
It works now, but as you said, the image is not really well sized.

Forgot to mention I use the space-bar, I learned nvim this way !

(side-note: writing this, I discovered why packer didn't use the right branch, Ii'm gonna let you find out in the next code ahah

use({
	"HendrikPetertje/telescope-media-files.nvim",
	branh = "fix-replace-ueber-with-viu",
	requires = { { "nvim-lua/popup.nvim" } },
	})

)

branh 🥇

small thing after my changes today. I switched from VIU to "chafa" as it is much better at putting things in the center and more importantly it uses glyphs with background/foreground colouring to make higher res images
#35 (comment)

so since you've been testing with viu you might get some breaking changes (or warnings to install a picture lib)
chafa is available on homebrew.

@HendrikPetertje
Installed chafa, it's working of course, but can't get the image to display correctly.
Please see :
image

Original image :
test

it turns images in to ASCII art at the capability of the terminal you are working in (an inline terminal inside a vim popup) as shown here https://hpjansson.org/chafa/
when displaying an image it's not going to be able to represent each little detail (especially small text) perfectly as it does a best effort of turning the picture into ascii art