Keep Neovim and Rex (the terminal by Superlogical) on the same color theme, in both directions, with separate dark and light themes.
https://github.com/user-attachments/assets/efcf46d1-14c9-49d6-b60f-c20a2d8bf87e
rex-<id> (:colorscheme rex-static-noir). The editor UI uses the theme's own interface colors from Rex, and syntax uses its 16 terminal colors.<name> (nvim). You don't need Ghostty or any other theme file.This is an unofficial plugin. It reads Rex's preferences and controls Rex through the rex CLI.
rex-* themes.rex CLI on PATH, with Remote Control turned on in Rex Settings > Rex Server. Neovim needs this to change Rex's theme.vim.ui.select with no preview. :colorscheme still syncs.{
"Christian-SC26/rex-theme.nvim",
lazy = false,
priority = 1000,
opts = {},
keys = {
{ "<leader>uC", function() require("rex-theme").pick() end, desc = "Colorscheme (rex-theme)" },
{ "<leader>uB", function() require("rex-theme").toggle_transparent() end, desc = "Transparent background" },
},
}
Colorscheme plugins you want to choose from can stay lazy = true; lazy.nvim loads them on :colorscheme.
LazyVim sets a colorscheme at startup, so turn that off. Add this to the spec above:
{ "LazyVim/LazyVim", opts = { colorscheme = function() end } },
LazyVim already maps leaderuC to its own picker. The keys above replace it.
vim.pack (Neovim 0.12+), or any manager that doesn't call setup() for you:
vim.pack.add({
"https://github.com/Christian-SC26/rex-theme.nvim",
-- colorschemes to choose from, e.g. "https://github.com/rebelot/kanagawa.nvim",
})
require("rex-theme").setup({
fallback = { dark = "habamax", light = "default" },
})
vim.keymap.set("n", "<leader>uC", function() require("rex-theme").pick() end, { desc = "Colorscheme" })
vim.keymap.set("n", "<leader>uB", function() require("rex-theme").toggle_transparent() end, { desc = "Transparent background" })
Call setup() early in init.lua, before anything that draws the UI.
[!IMPORTANT] Remove every
vim.cmd.colorscheme(...)/colorscheme ...from your config. rex-theme picks the colorscheme itself. Every:colorschemecounts as a pick, so a leftover one would overwrite your saved theme on each start and push it to Rex.
:RexTheme / :RexTheme pick |
Colorscheme picker with live preview |
:RexTheme transparent |
Toggle the transparent background |
:RexTheme refresh |
Re-read Rex's themes (this also runs on every start) |
:colorscheme <name> |
Works too: the theme is stored and synced like a pick |
:checkhealth rex-theme |
Check the setup |
When Neovim starts, Rex's current dark and light themes win. After that, whichever side changes last wins.
These are the defaults:
opts = {
-- Colorschemes for an empty slot, or one whose theme fails to load.
fallback = { dark = "default", light = "default" },
-- Clear the editor background. nil: on when running inside Rex.
transparent = nil,
-- Show the dark or light slot following the macOS appearance.
follow_system = true,
-- Two-way sync of the selected themes with Rex.
sync = true,
-- How often to check the macOS appearance and Rex's selection, in ms.
interval = 1500,
-- Rex themes that are really copies of nvim themes (e.g. imported from
-- Ghostty): { ["Rex theme name"] = "nvim colorscheme" }. They are hidden
-- from the rex-* list and replaced in Rex by an exact export when shown.
aliases = {},
-- Highlight groups whose background is cleared when transparent.
transparent_groups = { "Normal", "NormalNC", "SignColumn", "EndOfBuffer", "LineNr", "FoldColumn" },
}
With follow_system = true, you don't need a separate dark mode plugin.
(nvim) copy in Rex. The next pick imports it again.everforest with background=dark and background=light), the second copy is named <name> (nvim light).themes.json in the app bundle. Imported themes and the current selection come from defaults export com.superlogical.rex.rex do client.theme.import and rex do client.setting.themes.<dark|light>.palette.interval ms, one defaults read checks the macOS appearance and Rex's selected theme IDs.Normal, Cursor, Visual and terminal_color_0..15. Themes without terminal colors get them from their diagnostic and syntax colors.MIT