Skip to content

Automatically set Neovim's background and colorscheme based on your system's dark/light theme.

License

Notifications You must be signed in to change notification settings

mCassy/autobg.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

autobg.nvim

Automatically set Neovim's background and colorscheme based on your system's dark/light theme.

Features

  • Detects system theme (dark/light) on macOS, Linux (GNOME), and Windows
  • Sets vim.opt.background to match your system theme
  • Optionally sets a colorscheme for dark or light mode

Installation

Use your favorite plugin manager.

{
  'mCassy/autobg.nvim',
  config = function()
    require('autobg').setup()
  end,
}
use {
  'mCassy/autobg.nvim',
  config = function()
    require('autobg').setup()
  end
}

Usage

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
}

Configuration

Option Type Description
dark string Colorscheme for dark mode (optional)
light string Colorscheme for light mode (optional)

Using lazy.nvim events

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,
}

Supported Platforms

  • macOS: Uses defaults read -g AppleInterfaceStyle
  • Linux (GNOME): Uses gsettings get org.gnome.desktop.interface color-scheme
  • Windows: Reads registry key for theme preference

Contributing

Pull requests and issues are welcome!

License

MIT

About

Automatically set Neovim's background and colorscheme based on your system's dark/light theme.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages