tiagovla / tokyodark.nvim

A clean dark theme written in lua for neovim.
482 stars 20 forks source link

Overrides every highlight, even after :colorscheme #3

Closed hazeled closed 3 years ago

hazeled commented 3 years ago

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

tiagovla commented 3 years ago

Hi. Could you please check if the same happens when using this colorscheme?

hazeled commented 3 years ago

Just checked, highlighting groups still work as usual when using zephyr

tiagovla commented 3 years ago

Okay, I will look into it. Thank you.

tiagovla commented 3 years ago

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()

image

I will try to find another theme using the nvim api and see what they did to fix this.

tiagovla commented 3 years ago

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.

image