feat: warn ansi colors unset on fail
This commit is contained in:
parent
f60f6dd5bb
commit
f3321f269d
2 changed files with 10 additions and 11 deletions
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
local logger = require('cp.log')
|
||||||
|
|
||||||
---@param raw_output string|table
|
---@param raw_output string|table
|
||||||
---@return string
|
---@return string
|
||||||
function M.bytes_to_string(raw_output)
|
function M.bytes_to_string(raw_output)
|
||||||
|
|
@ -192,20 +194,17 @@ function M.setup_highlight_groups()
|
||||||
BrightWhite = vim.g.terminal_color_15,
|
BrightWhite = vim.g.terminal_color_15,
|
||||||
}
|
}
|
||||||
|
|
||||||
local missing_colors = {}
|
local missing_color = false
|
||||||
for color_name, terminal_color in pairs(color_map) do
|
for _, terminal_color in pairs(color_map) do
|
||||||
if terminal_color == nil then
|
if terminal_color == nil then
|
||||||
table.insert(missing_colors, color_name)
|
missing_color = true
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if #missing_colors > 0 then
|
if missing_color or #color_map == 0 then
|
||||||
vim.notify(
|
logger.log(
|
||||||
string.format(
|
'ansi terminal colors (vim.g.terminal_color_*) not configured. . ANSI colors will not display properly. ',
|
||||||
'[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, ', ')
|
|
||||||
),
|
|
||||||
vim.log.levels.WARN
|
vim.log.levels.WARN
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ local scrape = require('cp.scrape')
|
||||||
local snippets = require('cp.snippets')
|
local snippets = require('cp.snippets')
|
||||||
|
|
||||||
if not vim.fn.has('nvim-0.10.0') then
|
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 {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue