From f3321f269d1a45162793a62f8f622ea07d4fdb73 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sat, 20 Sep 2025 16:38:37 -0400 Subject: [PATCH] feat: warn ansi colors unset on fail --- lua/cp/ansi.lua | 19 +++++++++---------- lua/cp/init.lua | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lua/cp/ansi.lua b/lua/cp/ansi.lua index 51067fe..c8e2a01 100644 --- a/lua/cp/ansi.lua +++ b/lua/cp/ansi.lua @@ -4,6 +4,8 @@ local M = {} +local logger = require('cp.log') + ---@param raw_output string|table ---@return string function M.bytes_to_string(raw_output) @@ -192,20 +194,17 @@ function M.setup_highlight_groups() BrightWhite = vim.g.terminal_color_15, } - local missing_colors = {} - for color_name, terminal_color in pairs(color_map) do + local missing_color = false + for _, terminal_color in pairs(color_map) do if terminal_color == nil then - table.insert(missing_colors, color_name) + missing_color = true + break end end - if #missing_colors > 0 then - vim.notify( - string.format( - '[cp.nvim] Terminal colors not configured: %s. ANSI colors will not display properly. ' - .. 'Set vim.g.terminal_color_* variables or use a colorscheme that provides them.', - table.concat(missing_colors, ', ') - ), + if missing_color or #color_map == 0 then + logger.log( + 'ansi terminal colors (vim.g.terminal_color_*) not configured. . ANSI colors will not display properly. ', vim.log.levels.WARN ) end diff --git a/lua/cp/init.lua b/lua/cp/init.lua index b8c2397..7560f01 100644 --- a/lua/cp/init.lua +++ b/lua/cp/init.lua @@ -8,7 +8,7 @@ local scrape = require('cp.scrape') local snippets = require('cp.snippets') if not vim.fn.has('nvim-0.10.0') then - vim.notify('[cp.nvim]: requires nvim-0.10.0+', vim.log.levels.ERROR) + logger.log('[cp.nvim]: requires nvim-0.10.0+', vim.log.levels.ERROR) return {} end