From 73e85be0cf5fbc4a8802fbefed528c876e1da8d1 Mon Sep 17 00:00:00 2001 From: Jannik Donker Date: Fri, 2 Oct 2026 16:11:13 +0200 Subject: [PATCH] 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 --- lua/plugins.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index 01e376a..7091e4c 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -36,6 +36,17 @@ vim.pack.add({ 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 for _, name in ipairs({ "mini.pick", "mini.extra", "mini.icons", "mason", "typst-preview", @@ -273,7 +284,9 @@ vim.api.nvim_create_autocmd("FileType", { 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) require("nvim-treesitter").install({