Currently, it seems no way to arbitrarily replace any Unicode character using listchars (issues:22017)
You can consider using nvim_create_autocmd to target specific events {BufRead, ...} to change the color of specific content to make it more noticeable
vim.api.nvim_create_autocmd(
{ "BufRead", "BufNewFile" },
{
group = vim.api.nvim_create_augroup("HighlightFullWidthSpace", {}),
pattern = "*",
callback = function()
local groupNameCJKSpace = "CJKFullWidthSpace"
vim.fn.matchadd(groupNameCJKSpace, ' ') -- Create group mapping: Match the special symbol U+3000
-- vim.fn.matchadd(groupNameCJKSpace, 'A') -- If you want to apply this color to other content, you can add multiple matchadd
-- Set highlighting for this group
vim.api.nvim_set_hl(0, groupNameCJKSpace, {
bg = "#a6a6a6", -- Background color
fg = 'white', -- Foreground color
-- You can also add other attributes, such as:
-- bold = true,
-- italic = true,
-- underline = true
})
-- (Another example below)
local groupNameTODO = "myTODO"
vim.fn.matchadd(groupNameTODO, 'TODO .*')
vim.api.nvim_set_hl(0, groupNameTODO, { fg = "#8bb33d", italic = true })
end
}
)
<p style="background-color:#a6a6a6;color:white">#a6a6a6</span>
<p style="color:#8bb33d"><i>#8bb33d italic</i></span>
