Skip to content

Commit

Permalink
Merge pull request #299 from tmillr/fix-298
Browse files Browse the repository at this point in the history
fix(palette): get `canvas` from primitives
  • Loading branch information
ful1e5 authored Nov 26, 2023
2 parents 48f95f7 + da1edb8 commit f2de78a
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 63 deletions.
21 changes: 21 additions & 0 deletions lua/github-theme/_test/util.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
local M = {}
local api = vim.api

function M.await_VimEnter()
if vim.v.vim_did_enter == 0 then
local co = assert(coroutine.running(), 'test is not running in coroutine')

api.nvim_create_autocmd('VimEnter', {
pattern = '*',
once = true,
nested = true,
callback = vim.schedule_wrap(function()
coroutine.resume(co)
end),
})

coroutine.yield()
end
end

return M
9 changes: 2 additions & 7 deletions lua/github-theme/palette/github_dark.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local scale = primitives.scale

C.WHITE = C(scale.white)
C.BLACK = C(scale.black)
C.BG = C(scale.gray[7])
C.BG = C(assert(primitives.canvas.default))

local function alpha(color, a)
return color:alpha_blend(a):to_css()
Expand Down Expand Up @@ -42,12 +42,7 @@ local palette = {
on_emphasis = scale.white,
},

canvas = {
default = scale.gray[7],
overlay = scale.gray[9],
inset = scale.gray[8],
subtle = scale.gray[9],
},
canvas = primitives.canvas,

border = {
default = scale.gray[9],
Expand Down
9 changes: 2 additions & 7 deletions lua/github-theme/palette/github_dark_colorblind.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local scale = primitives.scale

C.WHITE = C(scale.white)
C.BLACK = C(scale.black)
C.BG = C(scale.gray[10])
C.BG = C(assert(primitives.canvas.default))

local function alpha(color, a)
return color:alpha_blend(a):to_css()
Expand Down Expand Up @@ -42,12 +42,7 @@ local palette = {
on_emphasis = scale.white,
},

canvas = {
default = scale.gray[10],
overlay = scale.gray[9],
inset = scale.black,
subtle = scale.gray[9],
},
canvas = primitives.canvas,

border = {
default = scale.gray[7],
Expand Down
9 changes: 2 additions & 7 deletions lua/github-theme/palette/github_dark_dimmed.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local scale = primitives.scale

C.WHITE = C(scale.white)
C.BLACK = C(scale.black)
C.BG = C(scale.gray[10])
C.BG = C(assert(primitives.canvas.default))

local function alpha(color, a)
return color:alpha_blend(a):to_css()
Expand Down Expand Up @@ -42,12 +42,7 @@ local palette = {
on_emphasis = scale.white,
},

canvas = {
default = scale.gray[10],
overlay = scale.gray[9],
inset = scale.black,
subtle = scale.gray[9],
},
canvas = primitives.canvas,

border = {
default = scale.gray[7],
Expand Down
9 changes: 2 additions & 7 deletions lua/github-theme/palette/github_dark_high_contrast.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local scale = primitives.scale

C.WHITE = C(scale.white)
C.BLACK = C(scale.black)
C.BG = C(scale.gray[10])
C.BG = C(assert(primitives.canvas.default))

local function alpha(color, a)
return color:alpha_blend(a):to_css()
Expand Down Expand Up @@ -42,12 +42,7 @@ local palette = {
on_emphasis = scale.gray[10],
},

canvas = {
default = scale.gray[10],
overlay = scale.gray[9],
inset = scale.black,
subtle = scale.gray[9],
},
canvas = primitives.canvas,

border = {
default = scale.gray[4],
Expand Down
9 changes: 2 additions & 7 deletions lua/github-theme/palette/github_dark_tritanopia.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local scale = primitives.scale

C.WHITE = C(scale.white)
C.BLACK = C(scale.black)
C.BG = C(scale.gray[10])
C.BG = C(assert(primitives.canvas.default))

local function alpha(color, a)
return color:alpha_blend(a):to_css()
Expand Down Expand Up @@ -42,12 +42,7 @@ local palette = {
on_emphasis = scale.white,
},

canvas = {
default = scale.gray[10],
overlay = scale.gray[9],
inset = scale.black,
subtle = scale.gray[9],
},
canvas = primitives.canvas,

border = {
default = scale.gray[7],
Expand Down
9 changes: 2 additions & 7 deletions lua/github-theme/palette/github_light.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local scale = primitives.scale

C.WHITE = C(scale.white)
C.BLACK = C(scale.black)
C.BG = C(scale.white)
C.BG = C(assert(primitives.canvas.default))

local function alpha(color, a)
return color:alpha_blend(a):to_css()
Expand Down Expand Up @@ -43,12 +43,7 @@ local palette = {
on_emphasis = scale.white,
},

canvas = {
default = scale.white,
overlay = scale.white,
inset = scale.gray[1],
subtle = scale.gray[1],
},
canvas = primitives.canvas,

border = {
default = scale.gray[3],
Expand Down
9 changes: 2 additions & 7 deletions lua/github-theme/palette/github_light_colorblind.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local scale = primitives.scale

C.WHITE = C(scale.white)
C.BLACK = C(scale.black)
C.BG = C(scale.white)
C.BG = C(assert(primitives.canvas.default))

local function alpha(color, a)
return color:alpha_blend(a):to_css()
Expand Down Expand Up @@ -43,12 +43,7 @@ local palette = {
on_emphasis = scale.white,
},

canvas = {
default = scale.white,
overlay = scale.white,
inset = scale.gray[1],
subtle = scale.gray[1],
},
canvas = primitives.canvas,

border = {
default = scale.gray[3],
Expand Down
9 changes: 2 additions & 7 deletions lua/github-theme/palette/github_light_high_contrast.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local scale = primitives.scale

C.WHITE = C(scale.white)
C.BLACK = C(scale.black)
C.BG = C(scale.white)
C.BG = C(assert(primitives.canvas.default))

local function alpha(color, a)
return color:alpha_blend(a):to_css()
Expand Down Expand Up @@ -43,12 +43,7 @@ local palette = {
on_emphasis = scale.white,
},

canvas = {
default = scale.white,
overlay = scale.white,
inset = scale.white,
subtle = scale.gray[2],
},
canvas = primitives.canvas,

border = {
default = scale.gray[9],
Expand Down
9 changes: 2 additions & 7 deletions lua/github-theme/palette/github_light_tritanopia.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local scale = primitives.scale

C.WHITE = C(scale.white)
C.BLACK = C(scale.black)
C.BG = C(scale.white)
C.BG = C(assert(primitives.canvas.default))

local function alpha(color, a)
return color:alpha_blend(a):to_css()
Expand Down Expand Up @@ -43,12 +43,7 @@ local palette = {
on_emphasis = scale.white,
},

canvas = {
default = scale.white,
overlay = scale.white,
inset = scale.gray[1],
subtle = scale.gray[1],
},
canvas = primitives.canvas,

border = {
default = scale.gray[3],
Expand Down
33 changes: 33 additions & 0 deletions test/github-theme/smoketest/startup_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
local assert = require('luassert')
local t_util = require('github-theme._test.util')

describe('(smoke test)', function()
describe('setting colorscheme during startup', function()
it('should not error', function()
assert.does_not_error(function()
vim.cmd('colorscheme github_dark_dimmed')
end)

assert.is.equal('', vim.v.errmsg or '')
end)
end)

describe('setting/switching colorscheme post-startup', function()
it('should not error', function()
t_util.await_VimEnter()

for _, cs in ipairs({
'default',
'github_dark_dimmed',
'github_dark_dimmed',
'github_light',
}) do
assert.does_not_error(function()
vim.cmd('colorscheme ' .. cs)
end)

assert.is.equal('', vim.v.errmsg or '')
end
end)
end)
end)

0 comments on commit f2de78a

Please sign in to comment.