From 5e3da3748ee4c47574a13b8d82540161979fc3dd Mon Sep 17 00:00:00 2001 From: loctvl842 Date: Mon, 1 Apr 2024 21:06:37 +0700 Subject: [PATCH] fix(bufferline): Add configuration for bufferline tab (https://github.com/loctvl842/monokai-pro.nvim/issues/117) - Add higlight for bufferline tab - Fix the issue when transparent background is enabled --- lua/monokai-pro/color_helper.lua | 16 +++++++++++----- lua/monokai-pro/theme/plugins/bufferline.lua | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/lua/monokai-pro/color_helper.lua b/lua/monokai-pro/color_helper.lua index 8b56a59..1cf9e57 100644 --- a/lua/monokai-pro/color_helper.lua +++ b/lua/monokai-pro/color_helper.lua @@ -1,7 +1,7 @@ ---@class Helper local M = {} ----@param background? HexColor +---@param background? HexColor | "NONE" local function get_blend_background(background) if background ~= nil and background ~= "NONE" then return background @@ -33,9 +33,12 @@ local function rgb_to_hex(rgb) return "#" .. red .. green .. blue end ----@param hex HexColor +---@param hex HexColor | "NONE" ---@param amt number M.lighten = function(hex, amt) + -- stylua: ignore + if hex == "NONE" then return hex end + local rgb = hex_to_rgb(hex) -- over upper rgb.r = (rgb.r + amt > 255) and 255 or (rgb.r + amt) @@ -64,12 +67,15 @@ M.rgba = function(red, green, blue, alpha, background) return rgb_to_hex({ r = red, g = green, b = blue }) end ----@param hexColor HexColor +---@param hex HexColor | "NONE" ---@param alpha HexColorAlpha ---@param base? HexColor -M.blend = function(hexColor, alpha, base) +M.blend = function(hex, alpha, base) + -- stylua: ignore + if hex == "NONE" then return "NONE" end + base = get_blend_background(base) - local rgb = hex_to_rgb(hexColor) + local rgb = hex_to_rgb(hex) return M.rgba(rgb.r, rgb.g, rgb.b, alpha, base) end diff --git a/lua/monokai-pro/theme/plugins/bufferline.lua b/lua/monokai-pro/theme/plugins/bufferline.lua index 15fe02c..8f894df 100644 --- a/lua/monokai-pro/theme/plugins/bufferline.lua +++ b/lua/monokai-pro/theme/plugins/bufferline.lua @@ -58,6 +58,7 @@ function M.get(c, config, hp) local tabsBackground = isBackgroundClear and c.editor.background or c.editorGroupHeader.tabsBackground local amt = 10 + M.tab = vim.tbl_deep_extend("force", c.tab, isBackgroundClear and { activeBackground = hp.lighten(c.tab.activeBackground, amt), inactiveBackground = hp.lighten(c.tab.inactiveBackground, amt), @@ -257,10 +258,29 @@ function M.get(c, config, hp) bg = M.tab.unfocusedActiveBackground, fg = c.base.red, }, + BufferLineTab = { + bg = M.tab.inactiveBackground, + fg = hp.blend(c.base.white, normalAlpha, M.tab.inactiveBackground), + }, BufferLineTabClose = { bg = tabsBackground, fg = tabsBackground, }, + BufferLineTabSelected = { + bg = M.tab.activeBackground, + fg = M.tab.activeForeground, + }, + BufferLineTabSeparator = { + bg = M.tab.inactiveBackground, + fg = M.tab.inactiveBackground, + -- fg = tabsBackground, + }, + BufferLineTabSeparatorSelected = { + bg = M.tab.activeBackground, + fg = M.tab.activeBackground, + -- fg = tabsBackground, + }, + -- indicator BufferLineIndicatorSelected = { bg = M.tab.activeBackground,