Closed hazeled closed 3 years ago
Hi. Could you please check if the same happens when using this colorscheme?
Just checked, highlighting groups still work as usual when using zephyr
Okay, I will look into it. Thank you.
I think the problem is that I'm using the nvim highlight api instead of cmd like other themes do.
Meanwhile, you could you use something like this:
local set_hl_ns = vim.api.nvim__set_hl_ns or vim.api.nvim_set_hl_ns
local create_namespace = vim.api.nvim_create_namespace
local highlight = vim.api.nvim_set_hl
local M = {}
local g, cmd = vim.g, vim.cmd
function M.tokyodark()
g.tokyodark_transparent_background = true
pcall(cmd, "colorscheme tokyodark")
end
local set_hl_ns = vim.api.nvim__set_hl_ns or vim.api.nvim_set_hl_ns
local create_namespace = vim.api.nvim_create_namespace
local highlight = vim.api.nvim_set_hl
function _G.custom_highlights()
local ns = create_namespace("tokyodark")
highlight(ns, "Comment", {fg = "#FF00FF"})
-- ...
-- overwrite and add other highlights
set_hl_ns(ns)
end
function M.highlights()
cmd([[
augroup custom_theme_highlights
autocmd!
au ColorScheme * lua custom_highlights()
augroup END
]])
end
function M.setup()
M.tokyodark()
M.highlights()
end
M.setup()
I will try to find another theme using the nvim api and see what they did to fix this.
After some research, I found that we cannot change the highlights with :highlight
because it's in another namespace. If you check the documentation it appears as a TODO, so they might implement this soon. You can still overwrite it like I did above.
This doesn't happen if the colorscheme isn't applied, and also doesn't happen if you use another colorscheme. However, when using tokyodark (Which is amazing, by the way), every single ":highlight" is overridden. If you check the highlight group, ctermfg/ctermbg/etc IS correctly updated, but not shown