Skip to content

A Neovim plugin for macOS, Linux & Windows that automatically changes the editor appearance based on system settings.

License

Notifications You must be signed in to change notification settings

f-person/auto-dark-mode.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

auto-dark-mode.nvim

A Neovim plugin for macOS, Linux, and Windows that automatically changes the editor appearance based on system settings.

macOS demo
Linux demo
Linux demo
Windows demo
Windows demo

📋 Requirements

Your operating system needs to be:

📦 Installation

Install the plugin with your preferred package manager:

-- 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
  }
}
Plug 'f-person/auto-dark-mode.nvim'

⚙️ Configuration

auto-dark-mode comes with the following defaults:

{
    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 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 theme 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

👩‍🎤 Special thanks to @nekowinston for maintaining the plugin 👩‍🎤

About

A Neovim plugin for macOS, Linux & Windows that automatically changes the editor appearance based on system settings.

Resources

License

Stars

Watchers

Forks

Languages