From 58fe621cfcd94a3572c5934b100d801ba648bb8a Mon Sep 17 00:00:00 2001 From: Olivia Kinnear Date: Fri, 17 Jul 2026 06:09:04 -0500 Subject: [PATCH] feat(health): rearrange vim.ui.img checks #40782 --- runtime/doc/news.txt | 5 +++-- runtime/lua/vim/health/health.lua | 20 ++++++++++++++++++++ runtime/lua/vim/ui/img/health.lua | 24 ------------------------ 3 files changed, 23 insertions(+), 26 deletions(-) delete mode 100644 runtime/lua/vim/ui/img/health.lua diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 360a3114a3..ef9a9ba945 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -37,6 +37,7 @@ LUA Use range.mark() and range.to_mark() instead. • pos.to_cursor() returns a (`row,` `col)` tuple instead of returning them as separate values. +• Healthchecks for |vim.ui.img| were moved to `:checkhealth vim.health`. DIAGNOSTICS @@ -277,8 +278,8 @@ LSP LUA -• |vim.ui.img| can display images. Use `:checkhealth img` to confirm your - terminal supports it. +• |vim.ui.img| can display images. Use `:checkhealth vim.health` to confirm + your terminal supports it. • |vim.net.request()| can specify custom headers by passing `opts.headers`. • |vim.net.request()| can now accept `method` param overload for multiple HTTP methods. • |writefile()| treats Lua and RPC strings as |Blob|, so it can be used to diff --git a/runtime/lua/vim/health/health.lua b/runtime/lua/vim/health/health.lua index 09b3882d40..6ea239675b 100644 --- a/runtime/lua/vim/health/health.lua +++ b/runtime/lua/vim/health/health.lua @@ -391,6 +391,8 @@ local function check_tmux() health.start('tmux') + health.warn('tmux is detected. Images may not display correctly.') + -- check escape-time local suggestions = { 'set escape-time in ~/.tmux.conf:\nset-option -sg escape-time 10', suggest_faq } @@ -469,12 +471,30 @@ local function check_tmux() end end +-- Note: this is part of check_terminal(). +local function check_graphics() + local supported, msg = require('vim.ui.img')._supported() + + if supported then + if msg then + health.ok(('Graphics protocol: supported (%s)'):format(msg)) + else + health.ok('Graphics protocol: supported') + end + else + health.error('Graphics protocol: not supported by this terminal.') + end +end + local function check_terminal() if vim.fn.executable('infocmp') == 0 then return end health.start('Terminal') + + check_graphics() + local cmd = { 'infocmp', '-L' } local ok, out = system(cmd) local kbs_entry = vim.fn.matchstr(out, 'key_backspace=[^,[:space:]]*') diff --git a/runtime/lua/vim/ui/img/health.lua b/runtime/lua/vim/ui/img/health.lua deleted file mode 100644 index 466e15953b..0000000000 --- a/runtime/lua/vim/ui/img/health.lua +++ /dev/null @@ -1,24 +0,0 @@ -local M = {} -local health = vim.health - -function M.check() - health.start('vim.ui.img') - - local supported, msg = require('vim.ui.img')._supported() - - if supported then - if msg then - health.ok(('Graphics protocol: supported (%s)'):format(msg)) - else - health.ok('Graphics protocol: supported') - end - else - health.error('Graphics protocol: not supported by this terminal.') - end - - if vim.env.TMUX then - health.warn('tmux is detected. Images may not display correctly.') - end -end - -return M