Skip to content

Commit 492f43e

Browse files
authored
Merge pull request #351 from projekt0n/fix-transparent-floats
fix: floats not transparent when `transparent = true`
2 parents a24960a + 8e0afee commit 492f43e

File tree

3 files changed

+50
-14
lines changed

3 files changed

+50
-14
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2929
- fix(compiler): consider entire config when hashing (#350) (related-to #262, #340, #341)
3030
- fix(compiler): always write hash to filesystem when compilation occurs incl. when `require('github-theme').compile()` is called directly (#350)
3131
- Fixed #340 and #341 (broken/outdated `overrides` example in docs)
32+
- Fixed floats not transparent when `transparent = true` (#337 fixed-by #351)
3233

3334
## [v1.0.2] - 03 May 2023
3435

lua/github-theme/group/editor.lua

+3-14
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,10 @@ local C = require('github-theme.lib.color')
33
local M = {}
44

55
function M.get(spec, config)
6-
local dark_sb = config.darken.sidebars.enabled
76
local hide_eof = config.hide_end_of_buffer
87
local inactive = config.dim_inactive
98
local inv = config.inverse
109
local trans = config.transparent
11-
12-
local sb_bg
13-
if trans then
14-
sb_bg = 'NONE'
15-
elseif dark_sb then
16-
sb_bg = spec.bg0
17-
else
18-
sb_bg = spec.bg1
19-
end
20-
2110
local c = spec.palette
2211
local sts_bg = C.from_hex(spec.bg0):blend(C.from_hex(c.blue.base), 0.7):to_css()
2312

@@ -58,11 +47,11 @@ function M.get(spec, config)
5847
MoreMsg = { fg = spec.diag.info, style = 'bold' }, -- |more-prompt|
5948
NonText = { fg = spec.bg4 }, -- '@' at the end of the window, characters from 'showbreak' and other characters that do not really exist in the text (e.g., '>' displayed when a double-wide character doesn't fit at the end of the line). See also |hl-EndOfBuffer|.
6049
Normal = { fg = spec.fg1, bg = trans and 'NONE' or spec.bg1 }, -- normal text
61-
NormalSB = { fg = spec.fg1, bg = sb_bg }, -- normal text
50+
NormalSB = { fg = spec.fg1, bg = trans and 'NONE' or config.darken.sidebars.enabled and spec.bg0 or spec.bg1 }, -- normal text
6251

63-
NormalNC = { fg = spec.fg1, bg = (inactive and spec.bg0) or (trans and 'NONE') or spec.bg1 }, -- normal text in non-current windows
52+
NormalNC = { fg = spec.fg1, bg = inactive and spec.bg0 or trans and 'NONE' or spec.bg1 }, -- normal text in non-current windows
6453

65-
NormalFloat = { fg = spec.fg1, bg = config.darken.floats and spec.bg0 or spec.bg1 }, -- Normal text in floating windows.
54+
NormalFloat = { fg = spec.fg1, bg = trans and 'NONE' or config.darken.floats and spec.bg0 or spec.bg1 }, -- Normal text in floating windows.
6655
FloatBorder = { fg = c.border.default }, -- TODO
6756
Pmenu = { fg = spec.fg1, bg = spec.bg0 }, -- Popup menu: normal item.
6857
PmenuSel = { bg = spec.sel1 }, -- Popup menu: selected item.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
local assert = require('luassert')
2+
local t_util = require('github-theme._test.util')
3+
4+
if vim.fn.has('nvim-0.9.0') == 0 or vim.fn.has('nvim-0.9.0') == false then
5+
return
6+
end
7+
8+
describe('config > transparent', function()
9+
before_each(function()
10+
require('github-theme.util.reload')(true)
11+
end)
12+
13+
it('should clear `bg` of Normal', function()
14+
require('github-theme').setup({ options = { transparent = true } })
15+
vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } })
16+
assert.is_nil(t_util.get_hl('Normal').bg)
17+
end)
18+
19+
it('should clear `bg` of NormalFloat', function()
20+
require('github-theme').setup({ options = { transparent = true } })
21+
vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } })
22+
assert.is_nil(t_util.get_hl('NormalFloat').bg)
23+
end)
24+
25+
it('should clear `bg` of NormalSB', function()
26+
require('github-theme').setup({ options = { transparent = true } })
27+
vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } })
28+
assert.is_nil(t_util.get_hl('NormalSB').bg)
29+
end)
30+
31+
it('should override `darken.floats`', function()
32+
require('github-theme').setup({
33+
options = { transparent = true, darken = { floats = true } },
34+
})
35+
vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } })
36+
assert.is_nil(t_util.get_hl('NormalFloat').bg)
37+
end)
38+
39+
it('should override `darken.sidebars`', function()
40+
require('github-theme').setup({
41+
options = { transparent = true, darken = { sidebars = { enable = true } } },
42+
})
43+
vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } })
44+
assert.is_nil(t_util.get_hl('NormalSB').bg)
45+
end)
46+
end)

0 commit comments

Comments
 (0)