From f37c36ffb3794d3ac6c429d49e2bf71269710cd3 Mon Sep 17 00:00:00 2001 From: Daniel Fry Date: Mon, 23 Mar 2026 22:31:00 +0000 Subject: [PATCH] feat: add custom_highlights option for user overrides Accepts a table or a function(colors, variant) that returns a table. Overrides are applied after all built-in groups, so users can tweak any highlight. The variant parameter ("dark"/"light") future-proofs for a potential light theme. Closes #3 --- README.md | 8 ++++++++ lua/lume/init.lua | 1 + lua/lume/theme.lua | 13 +++++++++++++ 3 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 3503210..63ec0e5 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,14 @@ All options are optional — defaults work out of the box. require("lume").setup({ transparent = false, -- set to true to use your terminal's background italics = true, -- set to false to disable italic comments/keywords + custom_highlights = function(colors, variant) + -- colors contains: backgrounds, foregrounds, accents, ansi, special + -- variant is "dark" (or "light" when a light theme is added) + return { + Normal = { bg = "#1E1F2E" }, + MiniDiffSignAdd = { fg = colors.accents.sage }, + } + end, }) ``` diff --git a/lua/lume/init.lua b/lua/lume/init.lua index f10e28b..e442234 100644 --- a/lua/lume/init.lua +++ b/lua/lume/init.lua @@ -3,6 +3,7 @@ local M = {} local defaults = { transparent = false, italics = true, + custom_highlights = nil, } M.config = vim.deepcopy(defaults) diff --git a/lua/lume/theme.lua b/lua/lume/theme.lua index 1ce2868..07d92fa 100644 --- a/lua/lume/theme.lua +++ b/lua/lume/theme.lua @@ -56,6 +56,19 @@ function M.apply(config) load_module(mod, false) end + -- Apply custom highlights + if config.custom_highlights then + local custom = config.custom_highlights + if type(custom) == "function" then + custom = custom(p, "dark") + end + if type(custom) == "table" then + for k, v in pairs(custom) do + groups[k] = vim.tbl_extend("force", groups[k] or {}, v) + end + end + end + for group, settings in pairs(groups) do vim.api.nvim_set_hl(0, group, settings) end