From fdb089daf6d66e9d559645e664a172ff5b6a5ddd Mon Sep 17 00:00:00 2001 From: Rene Schallner Date: Fri, 19 Aug 2022 16:17:24 +0200 Subject: [PATCH] added `viu` img previewer support --- README.md | 13 ++++++++++++- doc/telekasten.txt | 3 +++ lua/telekasten.lua | 7 +++++++ scripts/viu-previewer | 5 +++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 scripts/viu-previewer diff --git a/README.md b/README.md index a55fadc..e0ad586 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ mixing it with a journal, based on [telescope.nvim](https://github.com/nvim-tele - paste images from clipboard - toggle [ ] todo status of line - insert links to images -- **image previews**, via `catimg` or extension _(Linux only)_ +- **image previews**, via `catimg`, `viu`, or extension
@@ -119,6 +119,7 @@ of being able to edit it. - [0.0.3 For pasting images: xclip (optional)](#003-for-pasting-images-xclip-optional) - [0.0.4 For image previews: telescope-media-files.nvim (optional)](#004-for-image-previews-telescope-media-filesnvim-optional) - [catimg](#catimg) + - [viu](#viu) - [telescope-media-files.nvim](#telescope-media-filesnvim) - [0.1 Install the plugin](#01-install-the-plugin) - [0.1.0 Other useful plugins](#010-other-useful-plugins) @@ -186,12 +187,22 @@ There are two supported ways to preview images: - **ONLY supported on Linux** - via [catimg](https://github.com/posva/catimg) - supported at least on Linux and macOS +- via [viu](https://github.com/atanunq/viu) + - supports both iTerm and Kitty graphics protocols. + - Note: on my Linux machine, Kitty graphics rendering inside neovim / + telescope does not work at all, so it falls back to block rendering + mode. ##### catimg Just install [catimg](https://github.com/posva/catimg), then set `media_previewer` to `"catimg-previewer"` in the config. +##### viu + +Just install [viu](https://github.com/atanunq/viu), then set +`media_previewer` to `"viu-previewer"` in the config. + ##### telescope-media-files.nvim Per default, or by setting `media_previewer` to `"telescope-media-files"` in the diff --git a/doc/telekasten.txt b/doc/telekasten.txt index b19082f..0b42a90 100644 --- a/doc/telekasten.txt +++ b/doc/telekasten.txt @@ -154,6 +154,7 @@ telekasten.setup({opts}) -- how to preview media files -- "telescope-media-files" if you have telescope-media-files.nvim installed -- "catimg-previewer" if you have catimg installed + -- "viu-previewer" if you have viu installed media_previewer = "telescope-media-files", } < @@ -412,6 +413,8 @@ telekasten.setup({opts}) plugin - `'catimg-previewer'` : use the built-in `catimg` previewer. Requires `catimg` to be installed. + - `'viu-previewer'` : use the built-in `viu` previewer. + Requires `viu` to be installed. Default: `telescope-media-files` diff --git a/lua/telekasten.lua b/lua/telekasten.lua index fd9e48f..c771583 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -153,6 +153,7 @@ local function defaultConfig(home) -- how to preview media files -- "telescope-media-files" if you have telescope-media-files.nvim installed -- "catimg-previewer" if you have catimg installed + -- "viu-previewer" if you have viu installed media_previewer = "telescope-media-files", } M.Cfg = cfg @@ -979,6 +980,12 @@ local media_preview = defaulter(function(opts) .. "/telekasten.nvim/scripts/catimg-previewer" end + if vim.startswith(M.Cfg.media_previewer, "viu-previewer") then + preview_cmd = M.base_directory + .. "/telekasten.nvim/scripts/" + .. M.Cfg.media_previewer + end + if vim.fn.executable(preview_cmd) == 0 then print("Previewer not found: " .. preview_cmd) return conf.file_previewer(opts) diff --git a/scripts/viu-previewer b/scripts/viu-previewer new file mode 100755 index 0000000..7d94bdd --- /dev/null +++ b/scripts/viu-previewer @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +img="$1" + +viu "$img"