From 8e0afee547ccf5025400e2f8c6a730db2b0e24a0 Mon Sep 17 00:00:00 2001 From: Tyler Miller Date: Tue, 16 Jul 2024 01:12:08 -0700 Subject: [PATCH] fix: floats not transparent when `transparent = true` Fixes: #337 --- CHANGELOG.md | 1 + lua/github-theme/group/editor.lua | 17 ++----- test/github-theme/config/transparent_spec.lua | 46 +++++++++++++++++++ 3 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 test/github-theme/config/transparent_spec.lua diff --git a/CHANGELOG.md b/CHANGELOG.md index 27a838d..b4c3dc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lua/github-theme/group/editor.lua b/lua/github-theme/group/editor.lua index 060d923..deb5c0e 100644 --- a/lua/github-theme/group/editor.lua +++ b/lua/github-theme/group/editor.lua @@ -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() @@ -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. diff --git a/test/github-theme/config/transparent_spec.lua b/test/github-theme/config/transparent_spec.lua new file mode 100644 index 0000000..67fd116 --- /dev/null +++ b/test/github-theme/config/transparent_spec.lua @@ -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)