follow the terminal's light/dark theme

lualine uses the "gruvbox" theme, which picks the light or dark variant
from 'background' and is reloaded when that changes. 'background' itself
is left to nvim, which reads it from the terminal at startup and on theme
change reports (Ghostty + tmux >= 3.6, on Linux and macOS); on focus it
asks the terminal again, for setups that don't report changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jannikdonkerandClaude Opus 5.5 committed 2026-10-02 16:11:13 +02:00
1 parent d6099d6c01
commit 73e85be0cf
1 file changed
+14 -1
+14 -1
View File
@@ -36,6 +36,17 @@ vim.pack.add({
pcall(vim.cmd.colorscheme, "gruvbox") pcall(vim.cmd.colorscheme, "gruvbox")
-- Light/dark follows the terminal (Ghostty: `theme = light:...,dark:...`).
-- Nvim asks the terminal for its background at startup and again whenever the
-- terminal reports a theme change (DEC mode 2031: Ghostty does, tmux >= 3.6
-- passes it on), then sets 'background', which reloads gruvbox and everything
-- keyed off ColorScheme. That only works while 'background' is never set by
-- hand, so don't. Fallback for terminals that don't report changes: ask again
-- whenever nvim gets focus back.
vim.api.nvim_create_autocmd("FocusGained", {
callback = function() vim.api.nvim_ui_send("\027]11;?\007") end,
})
-- Simple setup({}) plugins -- Simple setup({}) plugins
for _, name in ipairs({ for _, name in ipairs({
"mini.pick", "mini.extra", "mini.icons", "mason", "typst-preview", "mini.pick", "mini.extra", "mini.icons", "mason", "typst-preview",
@@ -273,7 +284,9 @@ vim.api.nvim_create_autocmd("FileType", {
end, end,
}) })
require("lualine").setup({ options = { theme = "gruvbox_dark" } }) -- "gruvbox" picks gruvbox_light or gruvbox_dark from 'background', and lualine
-- reloads it when that changes.
require("lualine").setup({ options = { theme = "gruvbox" } })
-- Treesitter (main branch: no configs.setup; install parsers manually) -- Treesitter (main branch: no configs.setup; install parsers manually)
require("nvim-treesitter").install({ require("nvim-treesitter").install({