Syncing iTerm light and dark mode with neovim
My workspace gets pretty bright during the day, and I find it easier to work with a light color scheme neovim config then. But syncing everything up has been a hassle. Notes on how I get this to work, because I'm far from a neovim & lua master:
This is all using LazyVim, but may differ for you.
iTerm
I have an iTerm profile called "Light" that has a light background theme.
Neovim background
I want Neovim to match iTerm's light or dark setting. So I pull the $ITERM_PROFILE environment variable that iTerm sets and use it to switch neovim's background option:
In ~/.config/neovim/lua/config/options.lua
opt.background = vim.fn.getenv("ITERM_PROFILE") == "Light" and "light" or "dark"Neovim color scheme
My default color scheme - aurora - doesn't look that great in light mode, so I switch to papercolor. So, in ~/.config/neovim/lua/plugins/color.lua, another switch based on the iTerm environment variable:
return {
{
"LazyVim/LazyVim",
opts = {
colorscheme = vim.fn.getenv("ITERM_PROFILE") == "Light" and "papercolor" or "aurora",
},
}
}