Skip to content

Commit

Permalink
fix(highlights): avoid NONE highlights when replicating shades
Browse files Browse the repository at this point in the history
  • Loading branch information
ramojus committed Jul 31, 2024
1 parent 1d4884d commit 2a493a7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lua/mellifluous/highlights/custom_groups.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
local M = {}

local function fallback_if_none(color, fallback_color)
if type(color) == "string" and color == "NONE" then
return fallback_color
end
return color
end

-- Any shared highlight groups that cannot be found in general highlights or
-- treesitter highlights are created here.

function M.get(colors)
local config = require("mellifluous.config").config
local shader = require("mellifluous.utils.shader")
Expand All @@ -11,9 +17,11 @@ function M.get(colors)
MainKeyword = { fg = colors.main_keywords, style = config.styles.keywords },

IndentLine = function(bg)
bg = fallback_if_none(bg, colors.bg)
return { fg = shader.replicate_shade(colors.bg, colors.fg5, bg) }
end,
IndentLineInactive = function(bg)
bg = fallback_if_none(bg, colors.bg)
return {
fg = config.is_bg_dark and shader.replicate_shade(colors.bg, colors.bg4, bg)
or shader.replicate_shade(colors.bg, colors.dark_bg2, bg),
Expand All @@ -22,6 +30,7 @@ function M.get(colors)

MenuButton = { fg = colors.ui_blue },
MenuButtonSelected = function(bg)
bg = fallback_if_none(bg, colors.bg)
local applied_bg = config.is_bg_dark and shader.replicate_shade(colors.bg, colors.bg4, bg)
or shader.replicate_shade(colors.bg, colors.dark_bg2, bg)
return {
Expand All @@ -37,6 +46,7 @@ function M.get(colors)
or colors.dark_bg,
},
FileTreeWinSeparator = function(bg)
bg = fallback_if_none(bg, colors.bg)
return {
fg = config.flat_background.line_numbers ~= config.flat_background.file_tree and bg -- no separator if LineNr bg differs from this bg
or config.flat_background.line_numbers and config.flat_background.file_tree and colors.fg5 -- stronger separator if both bg are flat
Expand Down

0 comments on commit 2a493a7

Please sign in to comment.