Automatically set Neovim's background and colorscheme based on your system's dark/light theme.
- Detects system theme (dark/light) on macOS, Linux (GNOME), and Windows
- Sets
vim.opt.backgroundto match your system theme - Optionally sets a colorscheme for dark or light mode
Use your favorite plugin manager.
With lazy.nvim
{
'mCassy/autobg.nvim',
config = function()
require('autobg').setup()
end,
}With packer.nvim
use {
'mCassy/autobg.nvim',
config = function()
require('autobg').setup()
end
}Basic setup (auto-detects system theme and sets Neovim background):
require('autobg').setup()Optionally, specify colorschemes for dark and light modes:
require('autobg').setup {
dark = 'tokyonight', -- colorscheme for dark mode
light = 'github_light' -- colorscheme for light mode
}| Option | Type | Description |
|---|---|---|
| dark | string | Colorscheme for dark mode (optional) |
| light | string | Colorscheme for light mode (optional) |
You can use lazy.nvim's event option to control when autobg.nvim loads. For best results, use VimEnter or VeryLazy:
{
'mCassy/autobg.nvim',
event = 'VimEnter', -- or 'VeryLazy'
config = function()
require('autobg').setup {
dark = 'tokyonight',
light = 'github_light'
}
end,
}- macOS: Uses
defaults read -g AppleInterfaceStyle - Linux (GNOME): Uses
gsettings get org.gnome.desktop.interface color-scheme - Windows: Reads registry key for theme preference
Pull requests and issues are welcome!
MIT