diff --git a/lua/lualine/themes/rose-pine.lua b/lua/lualine/themes/rose-pine.lua index 4c2c9a6..e409130 100644 --- a/lua/lualine/themes/rose-pine.lua +++ b/lua/lualine/themes/rose-pine.lua @@ -1,7 +1,7 @@ local p = require("rose-pine.palette") local config = require("rose-pine.config") -local bg_base = p.base +local bg_base = p.surface if config.options.styles.transparency then bg_base = "NONE" end diff --git a/lua/rose-pine.lua b/lua/rose-pine.lua index 4f4dfdc..f10ffcd 100644 --- a/lua/rose-pine.lua +++ b/lua/rose-pine.lua @@ -121,7 +121,7 @@ local function set_highlights() PmenuSel = { fg = palette.text, bg = palette.overlay }, PmenuThumb = { bg = palette.muted }, Question = { fg = palette.gold }, - -- QuickFixLink = {}, + QuickFixLine = { fg = palette.foam }, -- RedrawDebugNormal = {}, RedrawDebugClear = { fg = palette.base, bg = palette.gold }, RedrawDebugComposed = { fg = palette.base, bg = palette.pine }, @@ -462,6 +462,7 @@ local function set_highlights() -- mvllow/modes.nvim ModesCopy = { bg = palette.gold }, ModesDelete = { bg = palette.love }, + ModesFormat = { bg = palette.rose }, ModesInsert = { bg = palette.foam }, ModesReplace = { bg = palette.pine }, ModesVisual = { bg = palette.iris }, @@ -722,6 +723,7 @@ local function set_highlights() DapUIThread = { fg = palette.gold }, DapUIValue = { fg = palette.text }, DapUIVariable = { fg = palette.text }, + DapUIType = { fg = palette.iris }, DapUIWatchesEmpty = { fg = palette.love }, DapUIWatchesError = { link = "DapUIWatchesEmpty" }, DapUIWatchesValue = { link = "DapUIThread" }, @@ -960,6 +962,8 @@ local function set_highlights() GrugFarInputPlaceholder = { link = "Comment" }, GrugFarResultsActionMessage = { fg = palette.foam }, GrugFarResultsChangeIndicator = { fg = groups.git_change }, + GrugFarResultsRemoveIndicator = { fg = groups.git_delete }, + GrugFarResultsAddIndicator = { fg = groups.git_add }, GrugFarResultsHeader = { fg = palette.pine }, GrugFarResultsLineNo = { fg = palette.iris }, GrugFarResultsLineColumn = { link = "GrugFarResultsLineNo" }, @@ -974,9 +978,12 @@ local function set_highlights() AvanteReversedSubtitle = { fg = palette.foam }, AvanteThirdTitle = { fg = palette.highlight_med, bg = palette.iris }, AvanteReversedThirdTitle = { fg = palette.iris }, + AvantePromptInput = { fg = palette.text, bg = groups.panel }, + AvantePromptInputBorder = { fg = groups.border }, -- Saghen/blink.cmp - BlinkCmpDoc = { fg = palette.text }, + BlinkCmpDoc = { bg = palette.highlight_low }, + BlinkCmpDocSeparator = { bg = palette.highlight_low }, BlinkCmpDocBorder = { fg = palette.highlight_high }, BlinkCmpGhostText = { fg = palette.muted }, @@ -1022,6 +1029,44 @@ local function set_highlights() SnacksIndentScope = { fg = palette.foam }, SnacksPickerMatch = { fg = palette.rose, bold = styles.bold }, + + -- justinmk/vim-sneak + Sneak = { fg = palette.base, bg = palette.love }, + SneakCurrent = { link = "StatusLineTerm" }, + SneakScope = { link = "IncSearch" }, + + -- sindrets/diffview.nvim + DiffviewPrimary = { fg = palette.pine }, + DiffviewSecondary = { fg = palette.foam }, + DiffviewNormal = { fg = palette.text, bg = palette.surface }, + DiffviewWinSeparator = { fg = palette.text, bg = palette.surface }, + + DiffviewFilePanelTitle = { fg = palette.foam, bold = styles.bold }, + DiffviewFilePanelCounter = { fg = palette.rose }, + DiffviewFilePanelRootPath = { fg = palette.foam, bold = styles.bold }, + DiffviewFilePanelFileName = { fg = palette.text }, + DiffviewFilePanelSelected = { fg = palette.gold }, + DiffviewFilePanelPath = { link = "Comment" }, + + DiffviewFilePanelInsertions = { fg = groups.git_add }, + DiffviewFilePanelDeletions = { fg = groups.git_delete }, + DiffviewFilePanelConflicts = { fg = groups.git_merge }, + DiffviewFolderName = { fg = palette.foam, bold = styles.bold }, + DiffviewFolderSign = { fg = palette.subtle }, + DiffviewHash = { fg = palette.rose }, + DiffviewReference = { fg = palette.foam, bold = styles.bold }, + DiffviewReflogSelector = { fg = palette.rose }, + DiffviewStatusAdded = { fg = groups.git_add }, + DiffviewStatusUntracked = { fg = groups.untracked }, + DiffviewStatusModified = { fg = groups.git_change }, + DiffviewStatusRenamed = { fg = groups.git_rename }, + DiffviewStatusCopied = { fg = groups.untracked }, + DiffviewStatusTypeChange = { fg = groups.git_change }, + DiffviewStatusUnmerged = { fg = groups.git_change }, + DiffviewStatusUnknown = { fg = groups.git_delete }, + DiffviewStatusDeleted = { fg = groups.git_delete }, + DiffviewStatusBroken = { fg = groups.git_delete }, + DiffviewStatusIgnored = { fg = groups.git_ignore }, } local transparency_highlights = { DiagnosticVirtualTextError = { fg = groups.error }, @@ -1122,9 +1167,18 @@ local function set_highlights() if config.options.before_highlight ~= nil then config.options.before_highlight(group, highlight, palette) end + if highlight.blend ~= nil and (highlight.blend >= 0 and highlight.blend <= 100) and highlight.bg ~= nil then highlight.bg = utilities.blend(highlight.bg, highlight.blend_on or palette.base, highlight.blend / 100) end + + highlight.blend = nil + highlight.blend_on = nil + + if highlight._nvim_blend ~= nil then + highlight.blend = highlight._nvim_blend + end + vim.api.nvim_set_hl(0, group, highlight) end @@ -1171,6 +1225,12 @@ function M.colorscheme(variant) end vim.g.colors_name = "rose-pine" + if variant == "dawn" then + vim.o.background = "light" + elseif variant == "main" or variant == "moon" then + vim.o.background = "dark" + end + set_highlights() end diff --git a/lua/rose-pine/palette.lua b/lua/rose-pine/palette.lua index 59c300c..cfefd65 100644 --- a/lua/rose-pine/palette.lua +++ b/lua/rose-pine/palette.lua @@ -47,7 +47,7 @@ local variants = { overlay = "#f2e9e1", muted = "#9893a5", subtle = "#797593", - text = "#575279", + text = "#464261", love = "#b4637a", gold = "#ea9d34", rose = "#d7827e", diff --git a/lua/rose-pine/utilities.lua b/lua/rose-pine/utilities.lua index 26e019e..32a8575 100644 --- a/lua/rose-pine/utilities.lua +++ b/lua/rose-pine/utilities.lua @@ -14,10 +14,17 @@ local function color_to_rgb(color) return { byte(new_color, 16), byte(new_color, 8), byte(new_color, 0) } end +local color_cache = {} + ---@param color string Palette key or hex value function utilities.parse_color(color) + if color_cache[color] then + return color_cache[color] + end + if color == nil then - return print("Invalid color: " .. color) + print("Invalid color: " .. color) + return nil end color = color:lower() @@ -26,13 +33,21 @@ function utilities.parse_color(color) color = require("rose-pine.palette")[color] or vim.api.nvim_get_color_by_name(color) end + color_cache[color] = color return color end +local blend_cache = {} + ---@param fg string Foreground color ---@param bg string Background color ---@param alpha number Between 0 (background) and 1 (foreground) function utilities.blend(fg, bg, alpha) + local cache_key = fg .. bg .. alpha + if blend_cache[cache_key] then + return blend_cache[cache_key] + end + local fg_rgb = color_to_rgb(fg) local bg_rgb = color_to_rgb(bg) @@ -41,7 +56,10 @@ function utilities.blend(fg, bg, alpha) return math.floor(math.min(math.max(0, ret), 255) + 0.5) end - return string.format("#%02X%02X%02X", blend_channel(1), blend_channel(2), blend_channel(3)) + local result = string.format("#%02X%02X%02X", blend_channel(1), blend_channel(2), blend_channel(3)) + + blend_cache[cache_key] = result + return result end return utilities diff --git a/readme.md b/readme.md index 8a2740c..6ef48bc 100644 --- a/readme.md +++ b/readme.md @@ -27,8 +27,8 @@ Install `rose-pine/neovim` using your favourite package manager: ```lua -- lua/plugins/rose-pine.lua -return { - "rose-pine/neovim", +return { + "rose-pine/neovim", name = "rose-pine", config = function() vim.cmd("colorscheme rose-pine") @@ -123,9 +123,13 @@ require("rose-pine").setup({ -- }, }, + -- NOTE: Highlight groups are extended (merged) by default. Disable this + -- per group via `inherit = false` highlight_groups = { -- Comment = { fg = "foam" }, + -- StatusLine = { fg = "love", bg = "love", blend = 15 }, -- VertSplit = { fg = "muted", bg = "muted" }, + -- Visual = { fg = "base", bg = "text", inherit = false }, }, before_highlight = function(group, highlight, palette)