From 92b284a37584f787acd151e2d39255eacb033c34 Mon Sep 17 00:00:00 2001 From: Frederick Zhang Date: Mon, 17 Mar 2025 12:31:38 +1100 Subject: [PATCH 1/3] fix: add chafa arguments '--format symbols' Otherwise chafa chooses a protocol based on the terminal. --- lua/chafa/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/chafa/init.lua b/lua/chafa/init.lua index cb59573..3b2e967 100644 --- a/lua/chafa/init.lua +++ b/lua/chafa/init.lua @@ -11,7 +11,7 @@ local global_opts = nil ---@diagnostic disable-next-line: unused-local local get_image_data_sync = function(buf_path, width, height, opts, callback) - local command = { "chafa", buf_path, "--size", width .. "x" .. height } + local command = { "chafa", buf_path, "--size", width .. "x" .. height, "--format", "symbols" } vim.fn.jobstart(command, { stdout_buffered = true, From 46a42fba674f746321e0bc2a23ca9805dee8a60b Mon Sep 17 00:00:00 2001 From: Frederick Zhang Date: Mon, 17 Mar 2025 12:35:51 +1100 Subject: [PATCH 2/3] fix: use chafa arguments '--polite on' to suppress escape sequences Chafa printed '\033[?25h' to hide the cursor. Adding a table.remove(data, 1) works too under *nix but '--polite on' should cater for Windows at the same time. [1] https://github.com/hpjansson/chafa/blob/aa8a3d928c9b476f548c9c79cce03cc80f437239/tools/chafa/chafa.c#L1656-L1659 --- lua/chafa/init.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/chafa/init.lua b/lua/chafa/init.lua index 3b2e967..3a26e7a 100644 --- a/lua/chafa/init.lua +++ b/lua/chafa/init.lua @@ -11,13 +11,12 @@ local global_opts = nil ---@diagnostic disable-next-line: unused-local local get_image_data_sync = function(buf_path, width, height, opts, callback) - local command = { "chafa", buf_path, "--size", width .. "x" .. height, "--format", "symbols" } + local command = { "chafa", buf_path, "--size", width .. "x" .. height, "--format", "symbols", "--polite", "on" } vim.fn.jobstart(command, { stdout_buffered = true, on_stdout = function(_, data) if data then - table.remove(data) callback(data) end end, From 3c8f412cf6fdfcb002f64813a75907f22b57ac36 Mon Sep 17 00:00:00 2001 From: Frederick Zhang Date: Fri, 16 May 2025 10:11:56 +1000 Subject: [PATCH 3/3] fix: migrate to new vim.health APIs --- lua/chafa/health.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/chafa/health.lua b/lua/chafa/health.lua index 5e007fb..6cfaa94 100644 --- a/lua/chafa/health.lua +++ b/lua/chafa/health.lua @@ -1,12 +1,12 @@ local M = {} M.check = function() - vim.health.report_start("chafa.nvim health check") + vim.health.start("chafa.nvim health check") if vim.fn.executable("chafa") == 1 then - vim.health.report_ok("no issues found") + vim.health.ok("no issues found") else - vim.health.report_error("chafa executable not found") - vim.health.report_info("Follow installations instructions at https://hpjansson.org/chafa/download/") + vim.health.error("chafa executable not found") + vim.health.info("Follow installations instructions at https://hpjansson.org/chafa/download/") end end