Skip to content

Commit

Permalink
Merge pull request #351 from projekt0n/fix-transparent-floats
Browse files Browse the repository at this point in the history
fix: floats not transparent when `transparent = true`
  • Loading branch information
tmillr committed Jul 16, 2024
2 parents a24960a + 8e0afee commit 492f43e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- fix(compiler): consider entire config when hashing (#350) (related-to #262, #340, #341)
- fix(compiler): always write hash to filesystem when compilation occurs incl. when `require('github-theme').compile()` is called directly (#350)
- Fixed #340 and #341 (broken/outdated `overrides` example in docs)
- Fixed floats not transparent when `transparent = true` (#337 fixed-by #351)

## [v1.0.2] - 03 May 2023

Expand Down
17 changes: 3 additions & 14 deletions lua/github-theme/group/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,10 @@ local C = require('github-theme.lib.color')
local M = {}

function M.get(spec, config)
local dark_sb = config.darken.sidebars.enabled
local hide_eof = config.hide_end_of_buffer
local inactive = config.dim_inactive
local inv = config.inverse
local trans = config.transparent

local sb_bg
if trans then
sb_bg = 'NONE'
elseif dark_sb then
sb_bg = spec.bg0
else
sb_bg = spec.bg1
end

local c = spec.palette
local sts_bg = C.from_hex(spec.bg0):blend(C.from_hex(c.blue.base), 0.7):to_css()

Expand Down Expand Up @@ -58,11 +47,11 @@ function M.get(spec, config)
MoreMsg = { fg = spec.diag.info, style = 'bold' }, -- |more-prompt|
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|.
Normal = { fg = spec.fg1, bg = trans and 'NONE' or spec.bg1 }, -- normal text
NormalSB = { fg = spec.fg1, bg = sb_bg }, -- normal text
NormalSB = { fg = spec.fg1, bg = trans and 'NONE' or config.darken.sidebars.enabled and spec.bg0 or spec.bg1 }, -- normal text

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

NormalFloat = { fg = spec.fg1, bg = config.darken.floats and spec.bg0 or spec.bg1 }, -- Normal text in floating windows.
NormalFloat = { fg = spec.fg1, bg = trans and 'NONE' or config.darken.floats and spec.bg0 or spec.bg1 }, -- Normal text in floating windows.
FloatBorder = { fg = c.border.default }, -- TODO
Pmenu = { fg = spec.fg1, bg = spec.bg0 }, -- Popup menu: normal item.
PmenuSel = { bg = spec.sel1 }, -- Popup menu: selected item.
Expand Down
46 changes: 46 additions & 0 deletions test/github-theme/config/transparent_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
local assert = require('luassert')
local t_util = require('github-theme._test.util')

if vim.fn.has('nvim-0.9.0') == 0 or vim.fn.has('nvim-0.9.0') == false then
return
end

describe('config > transparent', function()
before_each(function()
require('github-theme.util.reload')(true)
end)

it('should clear `bg` of Normal', function()
require('github-theme').setup({ options = { transparent = true } })
vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } })
assert.is_nil(t_util.get_hl('Normal').bg)
end)

it('should clear `bg` of NormalFloat', function()
require('github-theme').setup({ options = { transparent = true } })
vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } })
assert.is_nil(t_util.get_hl('NormalFloat').bg)
end)

it('should clear `bg` of NormalSB', function()
require('github-theme').setup({ options = { transparent = true } })
vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } })
assert.is_nil(t_util.get_hl('NormalSB').bg)
end)

it('should override `darken.floats`', function()
require('github-theme').setup({
options = { transparent = true, darken = { floats = true } },
})
vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } })
assert.is_nil(t_util.get_hl('NormalFloat').bg)
end)

it('should override `darken.sidebars`', function()
require('github-theme').setup({
options = { transparent = true, darken = { sidebars = { enable = true } } },
})
vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } })
assert.is_nil(t_util.get_hl('NormalSB').bg)
end)
end)

0 comments on commit 492f43e

Please sign in to comment.