NvChad / base46

NvChad's base46 theme plugin with caching ( Total re-write )
Other
210 stars 203 forks source link

toggle_theme replaces string in the theme_toggle, which should not be changed #167

Closed Switch1220 closed 1 year ago

Switch1220 commented 1 year ago

Currently, toggle_theme() also replaces string in the theme_toggle, which should not be changed.

Here's example:

Before

theme = "ayu_dark",
theme_toggle = { "ayu_dark", "ayu_light" },

After invoking toggle_theme

theme = "ayu_light",
theme_toggle = { "ayu_light", "ayu_light" },

What I did to fix this bug:

-- base46/lua/base46/init.lua
if g.nvchad_theme == theme1 then
  g.toggle_theme_icon = "   "
  vim.g.nvchad_theme = theme2
  require("nvchad").replace_word(theme1, theme2) -- <= here

to

require("nvchad").replace_word('theme = "' .. theme1, 'theme = "' .. theme2)
Switch1220 commented 1 year ago

Also, due to the order of load_all_highlights(), it doesn't reload highlights immediately.

  -- M.load_all_highlights()

  if g.nvchad_theme == theme1 then
    g.toggle_theme_icon = "   "
    vim.g.nvchad_theme = theme2
    require("nvchad").replace_word('theme = "' .. theme1, 'theme = "' .. theme2)
  else
    vim.g.nvchad_theme = theme1
    g.toggle_theme_icon = "   "
    require("nvchad").replace_word('theme = "' .. theme2, 'theme = "' .. theme1)
  end

  M.load_all_highlights() -- <= I think it should be moved here
siduck commented 1 year ago

hi @Switch1220 send a PR :D , sorry i closed your previous PR without reasoning much. it was valid.