Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: floats not transparent when transparent = true #351

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading