Skip to content

mgallegoa/telescope-media-files.nvim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telescope-media-files.nvim

Preview images Thumbnails for different kind of files, from Neovim using Telescope + ASCII Art (whit Chafa). Support Tmux + console kitty.

jpg | png | jpeg | svg | gif | avi | mp4 | wmv | dat | 3gp | ogv | mkv | mpg | mpeg | vob | m2v | mov | webm | mts | m4v | rm | qt | divx | pdf | epub | ttf | otf | woff | webp

Nvim

Nvim

Nvim + Tmux + Kitty

Tmux+kitty

Important: If you like, let your star

Videos

  1. Configuration
  2. Tmux + Kitty

Install

Lazy

return {
    "mgallegoa/telescope-media-files.nvim",
    dependencies = {
      "nvim-lua/plenary.nvim",
      "nvim-telescope/telescope.nvim",
      "nvim-lua/popup.nvim"
    },
}

Setup

require('telescope').load_extension('media_files')

Custom Configuration

This extension can be configured using extensions field inside Telescope setup function.

Example custom configuration with Lazy

In the next example, the filetypes is configure to accept other types of files (check the Prerequisites section optional) and change the default find command (fd) to rg -->

    config = function()
      local telescope = require('telescope')
      telescope.setup({
        extensions = {
          media_files = {
            filetypes = { "png", "jpg", "jpeg", "webp", "svg", "gif", "pdf", "epub", "ttf", "mp4", "3gp", "mpeg" }, -- default {"png", "jpg", "mp4", "webm", "pdf"}
            find_cmd = "rg", -- find command defaults to `fd`
            -- command_open_imen = "display" -- Example to use imageMagick to show the image instead default eog
            -- command_open_image = 'gnome-terminal -- env TMUX="" kitty --hold kitten ica' -- Example to use the kitty terminal for the images
            -- command_open_thumbnail = "kitten icat" -- Example open image Thumbnail with kitty
            -- show_file_details = 0 -- Example to disable the file details.
            -- tmux_always_open_pane = 1 -- Example to open a new pane in tmux for each Thumbnail
            -- tmux_time_wait = 1 -- Example to wait 1 second for console render the image
            -- tmux_index_pane_thumbnail = 0 -- Example to show the Thumbnail at the left of the tmux pane.
            -- tmux_resize_open_pane = 30 -- Example of number of columns to open the tmux pane.
          }
        },
      })
    end,
    keys = {
      { "<leader>fm", "<cmd>lua require('telescope').extensions.media_files.media_files()<cr>" },
      { "<leader>fn", "<cmd>lua require('telescope').extensions.media_files.media_files_console()<cr>" },
    }

💡 Tip: See the list of the config variables you can used to custom your view

Available commands

Over the file Ctl+i to open an image of the file (default viewer eog, but can be configured to other external viewer)

:Telescope media_files

lua require('telescope').extensions.media_files.media_files()
lua require('telescope').extensions.media_files.media_files_console()

or using key-binding

:Telescope media_files.media_files()
:Telescope media_files.media_files_console()

keys = {
      { "<leader>fm", "<cmd>lua require('telescope').extensions.media_files.media_files()<cr>" },
      { "<leader>fn", "<cmd>lua require('telescope').extensions.media_files.media_files_console()<cr>" },
    }

When you press <Enter> on a selected file, normal mode, it will copy its relative path to the clipboard

Recipes

Prerequisites

Requiered

  • Chafa : ASCII Art Image support ( Tmux + kitten required kitten icat )
  • fd : To find the files in Telescope pop up. Also support rg / find, find or fdfind in Ubuntu/Debian.

Optionals

Other usefull documents pages

credit to https://github.com/cirala/vifmimg