folke / tokyonight.nvim

🏙 A clean, dark Neovim theme written in Lua, with support for lsp, treesitter and lots of plugins. Includes additional themes for Kitty, Alacritty, iTerm and Fish.
Apache License 2.0
6.45k stars 433 forks source link

bug: tokyonight forces vim.o.background to dark, breaking automatic day/night switching based on terminal background #565

Closed strayer closed 4 months ago

strayer commented 4 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

v0.10.0

Operating system/version

macOS 14.5 (23F79)

Describe the bug

After updating tokyonight to 18116ad it seems like neovim doesn't correctly determine the terminal background anymore.

Happens with wezterm 20240203-110809-5046fc22. When reverting back to 30d7be3 the background color is detected correctly again.

It looks like tokyonight is setting this in its init.lua:

:verbose set background?
 background=dark
    Last set from ~/.local/share/nvim/lazy/tokyonight.nvim/lua/tokyonight/init.lua line 2

I don't set any settings when loading the plugin, so I'm loading the defaults. Reading the docs I'm unsure how to configure tokyonight to not change my neovim background and just use day or storm/moon/... based on my terminal settings. It seems like the default behaviour changed with 4.0? Previously tokyonight automatically switched between day and storm/moon/... (I'm not exactly sure which dark theme it used) based on vim.o.background.

Sorry if the issue is not containing all details, I'm having a bit of trouble understanding the logic in the init.lua due to my limited lua skills… please let me know if and how I can contribute!

Steps To Reproduce

  1. update tokyonight to 18116ad
  2. launch nvim

Expected Behavior

tokyonight should respect vim.o.background and set its colors accordingly, not forcing the background to dark/light

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/tokyonight.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
folke commented 4 months ago

Right, I forgot that Neovim only detects background later. Will see for a proper fix...

folke commented 4 months ago

Should be fixed. Let me know if you'd still have issues. Thanks

strayer commented 4 months ago

Works great, thanks for taking time to fix this! ❤️