Skip to content

Commit

Permalink
fix(color): do not remove extra colors
Browse files Browse the repository at this point in the history
  • Loading branch information
MunifTanjim committed Dec 15, 2023
1 parent 4bd8ce3 commit 6c7f542
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lua/nougat/color.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ local store = Store("nougat.color", {
get_hl_def = {},
---@type table<string, boolean>
get_hl_name = {},
---@class nougat.color
color = {},
---@type nougat.color
theme = {},
})

local color = store.color
local theme = store.theme
---@class nougat.color
local color = { accent = {} }
---@type nougat.color
local theme = { accent = {} }

local get_hl_def_cache = store.get_hl_def

Expand Down
30 changes: 30 additions & 0 deletions tests/nougat/color_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,36 @@ describe("nougat.color", function()
t.eq(hl_def.bg, "#dc143c")
t.eq(hl_def.fg, "#ffcd00")
end)

it("keeps extra color from previous colorscheme", function()
local hl_name, hl_def

load_color_theme("a", vim.go.background, {
get = function()
return {
purple = "#663399",
}
end,
})

hl_name = color.get_hl_name({ bg = c.purple, fg = c.yellow }, {})
hl_def = color.get_hl_def(hl_name)
t.eq(hl_def.bg, "#663399")
t.eq(hl_def.fg, "#ffff00")

load_color_theme("b", vim.go.background, {
get = function()
return {
yellow = "#ffcd00",
}
end,
})

hl_name = color.get_hl_name({ bg = c.purple, fg = c.yellow }, {})
hl_def = color.get_hl_def(hl_name)
t.eq(hl_def.bg, "#663399")
t.eq(hl_def.fg, "#ffcd00")
end)
end)

describe(".get_hl_def", function()
Expand Down

0 comments on commit 6c7f542

Please sign in to comment.