https://github.com/f-person/auto-dark-mode.nvim
A Neovim plugin for macOS, Linux & Windows that automatically changes the editor appearance based on system settings.
https://github.com/f-person/auto-dark-mode.nvim
Last synced: 2 months ago
JSON representation
A Neovim plugin for macOS, Linux & Windows that automatically changes the editor appearance based on system settings.
- Host: GitHub
- URL: https://github.com/f-person/auto-dark-mode.nvim
- Owner: f-person
- License: gpl-3.0
- Created: 2022-02-08T23:27:50.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-03-10T15:38:22.000Z (4 months ago)
- Last Synced: 2025-05-10T11:34:44.375Z (2 months ago)
- Language: Lua
- Homepage:
- Size: 2.41 MB
- Stars: 398
- Watchers: 3
- Forks: 30
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-neovim - f-person/auto-dark-mode.nvim - Follow the system appearance on macOS. (Colorscheme / Colorscheme Switchers)
- awesome-neovim-sorted - f-person/auto-dark-mode.nvim
README
# auto-dark-mode.nvim
A Neovim plugin for macOS, Linux, and Windows that automatically changes the
editor appearance based on system settings.
![]()
Linux demo
![]()
Windows demo
![]()
## 📋 Requirements
Your operating system needs to be:- a Linux desktop environment that implements [`org.freedesktop.appearance.color-scheme`](https://github.com/flatpak/xdg-desktop-portal/issues/629), such as
- [Gnome](https://gnome.org)
- [KDE](https://kde.org)
- [darkman](https://gitlab.com/WhyNotHugo/darkman) for window managers
- macOS Mojave or newer
- Windows 10 or newer (or WSL)Notes for WSL
To query the appearance of the Windows host system, two options **must be**
enabled in `/etc/wsl.conf`:```ini
[automount]
enabled = true[interop]
enabled = true
```See [the Microsoft docs](https://learn.microsoft.com/en-us/windows/wsl/wsl-config)
for more information about WSL settings.## 📦 Installation
Install the plugin with your preferred package manager:
### [lazy.nvim](https://github.com/folke/lazy.nvim)
```lua
-- Lua
{
"f-person/auto-dark-mode.nvim",
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
}
```### [vim-plug](https://github.com/junegunn/vim-plug)
```vim
Plug 'f-person/auto-dark-mode.nvim'
```## ⚙️ Configuration
**auto-dark-mode** comes with the following defaults:
```lua
{
set_dark_mode = function()
vim.api.nvim_set_option_value("background", "dark", {})
end,
set_light_mode = function()
vim.api.nvim_set_option_value("background", "light", {})
end,
update_interval = 3000,
fallback = "dark"
}
````set_dark_mode` and `set_light_mode` are the hooks called when the system
appearance changes. By default, they change the
[background](https://neovim.io/doc/user/options.html#'background') option,
overriding the function allows for further customization.`update_interval` is how frequently the system appearance is checked, in
milliseconds. The value needs to be higher than the amount of milliseconds it
takes to query your system for the dark mode state. Otherwise, you risk
freezing neovim on shutdown.`fallback` specifies the appearance (`"dark" | "light"`) to use when the
auto-detection fails. This can be particularly useful to specify a default
version when remotely connecting via SSH, or when using neovim on a tty.## 🚀 Usage
### Disabling at runtime
You can disable `auto-dark-mode.nvim` at runtime via `lua require('auto-dark-mode').disable()`.
## 💖 Contributors
[](https://github.com/f-person/auto-dark-mode.nvim/graphs/contributors)👩🎤 Special thanks to [@nekowinston](https://github.com/nekowinston) for
maintaining the plugin 👩🎤