Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 10 days 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 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-05T14:21:49.000Z (3 months ago)
- Last Synced: 2024-10-03T09:27:57.409Z (about 1 month ago)
- Language: Lua
- Homepage:
- Size: 2.39 MB
- Stars: 299
- Watchers: 4
- Forks: 22
- Open Issues: 7
-
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)
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
## Installation
### Using [vim-plug](https://github.com/junegunn/vim-plug)
```vim
Plug 'f-person/auto-dark-mode.nvim'
```## Requirements
* macOS, a Linux environment that implements
[`org.freedesktop.appearance.color-scheme`](https://github.com/flatpak/xdg-desktop-portal/issues/629),
Windows 10+ or WSL
* Neovim## Configuration
You need to call `setup` for initialization.
`setup` accepts a table with options – `set_dark_mode` function,
`set_light_mode` function, and `update_interval` integer.`set_dark_mode` is called when the system appearance changes to dark mode, and
`set_light_mode` is called when it changes to light mode.
By default, they just change the background option, but you can do whatever you like.`update_interval` is how frequently the system appearance is checked.
The value needs to be larger than whatever time your system takes to query dark mode.
Otherwise you risk freezing neovim on shutdown.
The value is stored in milliseconds.
Defaults to `3000`.```lua
local auto_dark_mode = require('auto-dark-mode')auto_dark_mode.setup({
update_interval = 1000,
set_dark_mode = function()
vim.api.nvim_set_option_value('background', 'dark', {})
vim.cmd('colorscheme gruvbox')
end,
set_light_mode = function()
vim.api.nvim_set_option_value('background', 'light', {})
vim.cmd('colorscheme gruvbox')
end,
})
```### Using [lazy](https://github.com/folke/lazy.nvim)
```lua
return {
"f-person/auto-dark-mode.nvim",
opts = {
update_interval = 1000,
set_dark_mode = function()
vim.api.nvim_set_option_value("background", "dark", {})
vim.cmd("colorscheme gruvbox")
end,
set_light_mode = function()
vim.api.nvim_set_option_value("background", "light", {})
vim.cmd("colorscheme gruvbox")
end,
},
}
```#### Disable
You can disable `auto-dark-mode.nvim` at runtime via `lua require('auto-dark-mode').disable()`.## Thanks To
* [@nekowinston](https://github.com/nekowinston) for implementing Linux support and other contributions! <3
* [@adityamwagh](https://github.com/adityamwagh) for implementing Windows support# Support
If you enjoy the plugin and want to support what I do