zephyr-nvim icon indicating copy to clipboard operation
zephyr-nvim copied to clipboard

Color Scheme cannot be enabled twice

Open chrisgrieser opened this issue 2 years ago • 2 comments

Basically the same as #37, which for whatever reason got closed by the op without the issue being fixed.

The color scheme can only be changed once. changing to a different colorscheme and back does not work.

This is also relevant when using plugins like styler or autodarkmode.

I had the same issue with oxocarbon, maybe their solution can be used here as well? https://github.com/nyoom-engineering/oxocarbon.nvim/issues/38

chrisgrieser avatar Jan 15 '23 09:01 chrisgrieser

The problem I have with this colorscheme-plugin is that it does not work like it should in that when I define overrides to various highlight styles, the colorscheme clobbers them still even when i set these overrides to happen in autocmds.

I'm pretty sure it's because of this code (the only real code in here anyway):

local async_load_plugin

local set_hl = function(tbl)
  for group, conf in pairs(tbl) do
    vim.api.nvim_set_hl(0, group, conf)
  end
end

async_load_plugin = vim.loop.new_async(vim.schedule_wrap(function()
  z.terminal_color()
  set_hl(plugin_syntax)
  async_load_plugin:close()
end))

function z.colorscheme()
  vim.api.nvim_command("hi clear")

  vim.o.background = "dark"
  vim.o.termguicolors = true
  vim.g.colors_name = "zephyr"
  set_hl(syntax)
  async_load_plugin:send()
end

z.colorscheme()

return z

It would be wonderful if author could grace us with an explanation of why this is but I would imagine that we could easily turn this into a more well behaved colorscheme by simply synchronously making the calls in here.

I think I know what the reason is though actually. It's that some of these hl's are intended to get set after the other ones are because there are probably subtle interactions going on. I'm going to just go ahead fork the colorscheme instead of trying to add code to set override highlight groups, because that aint working.

unphased avatar Feb 22 '23 08:02 unphased