auto-dark-mode.nvim
auto-dark-mode.nvim copied to clipboard
bufferline and lualine theme broken
I don't know what commit created this issue but since a while I have the issue that bufferline and lualine theme is broken on startup until I manually call :colorscheme <theme>. It does not matter if I use your example from the docs or only use auto_dark_mode with an empty setup function.
Steps to reproduce:
Install tokyonight, bufferline, lualine and use the following setup:
vim.cmd [[colorscheme tokyonight]]
local auto_dark_mode = require('auto-dark-mode')
auto_dark_mode.setup()
auto_dark_mode.init()
Look at the lualine at bottom (it's broken).
Then call :colorscheme tokyonight
Lualine should be fixed now.
Additional info
You can also disable the auto-dark-mode config completely and just call vim.cmd [[colorscheme tokyonight]]. You can see that the theme is correct. Then when you manually set background color it switches and works.
This used to work for a long time but at some point just stopped working.
Additionally I can say, that I worked around this by doing the following
local auto_dark_mode = require('auto-dark-mode')
auto_dark_mode.setup({
update_interval = 1000,
set_dark_mode = function()
local current = vim.api.nvim_get_option('background')
if (current == 'light') then
vim.api.nvim_set_option('background', 'dark')
vim.cmd [[colorscheme tokyonight]]
end
end,
set_light_mode = function()
local current = vim.api.nvim_get_option('background')
if (current == 'dark') then
vim.api.nvim_set_option('background', 'light')
vim.cmd [[colorscheme tokyonight]]
end
end,
})
But even with this it still happens sometimes randomly. It looks like some race condition issue maybe? It's weird to debug of course but maybe it helps you pinpoint the issue.
You can pass custom set_dark_mode & set_light_mode and do the required setup for your environment.
The default functions call vim.api.nvim_set_option_value("background", background, {}), nothing more :)
I did that but it still happens. See my 2nd comment. This used to work for a long time but started to happen after some commit. Do you have any idea why it could happen? It's also not the theme, i have the issue with multiple themes that auto switch.
fwiw it's only broken after start. when I switch to dark and light again and again no problems happen after that. it has to do with some default applied before the set_dark or set_light functions are getting applied, dunno.
also as of right now, the issue happens every time. it used to be flaky but now i can consistently reproduce the issue. when I have auto-dark-mode enabled and start neovim in a terminal, both lualine and bufferline are broken.
Hey! Sorry, missed this or forgot to check it out in more detail. I'll try to find some time in the near future and look into the issue / check the code to see if there's something potentially causing this :) Thanks for using the plugin <3
Oh, are you the creator of bluloco? So cool! I've used it as a primary theme for quite some time! Still switch back from time to time :)
Some additional context: neovim changed the way that background gets set twice in recent times:
https://github.com/neovim/neovim/pull/23701
https://github.com/neovim/neovim/pull/26284
which could(?) explain why the behavior changed?
Looks like the issues is caused by another plugin I was using.
See:
- https://github.com/nvim-telescope/telescope-frecency.nvim/issues/210
I put it in my themes documentation. https://github.com/uloco/bluloco.nvim#switching-light-and-dark-theme-according-your-os-settings