Skip to content

Commit da7281e

Browse files
authored
Merge pull request #345 from tmillr/fix-options-darken-floats
fix(config): `options.darken.floats` is not used
2 parents c96c1f0 + 24fc179 commit da7281e

File tree

6 files changed

+88
-3
lines changed

6 files changed

+88
-3
lines changed

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [unreleased]
99

10+
### What's New?
11+
12+
- Added new highlight groups for mini.nvim (#333 by @echasnovski)
13+
14+
### Changes
15+
16+
- Clarify `options.transparent` in README (resolves #327)
17+
- Renamed function `Color:lumanance()` -> `Color:luminance()` in `Color` lib (typo/misspelling)
18+
19+
### Issues Fix
20+
21+
- Fixed `punctuation.delimiter` treesitter group nearly invisible (#329 fixed by #331)
22+
- Closed #305 (no longer valid, fixed)
23+
- Closed #292 (no longer valid, fixed)
24+
- fix(config): `options.darken.floats` is not used (#345)
25+
1026
## [v1.0.2] - 03 May 2023
1127

1228
### What's New?

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ require('github-theme').setup({
281281
search = false,
282282
},
283283
darken = { -- Darken floating windows and sidebar-like windows
284-
floats = false,
284+
floats = true,
285285
sidebars = {
286286
enabled = true,
287287
list = {}, -- Apply dark background to specific windows

lua/github-theme/_test/util.lua

+20
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,24 @@ function M.await_VimEnter()
1818
end
1919
end
2020

21+
---@param group string
22+
---@param link? boolean
23+
---@return vim.api.keyset.hl_info
24+
function M.get_hl(group, link)
25+
return api.nvim_get_hl(0, {
26+
name = group,
27+
link = not not link,
28+
create = false,
29+
})
30+
end
31+
32+
if vim.fn.has('nvim-0.10.0') == false or vim.fn.has('nvim-0.10.0') == 0 then
33+
function M.get_hl(group, link)
34+
return api.nvim_get_hl(0, {
35+
name = group,
36+
link = not not link,
37+
})
38+
end
39+
end
40+
2141
return M

lua/github-theme/config.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ local defaults = {
3030
search = false,
3131
},
3232
darken = {
33-
floats = false,
33+
floats = true,
3434
sidebars = {
3535
enable = true,
3636
list = {},

lua/github-theme/group/editor.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function M.get(spec, config)
6262

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

65-
NormalFloat = { fg = spec.fg1, bg = spec.bg0 }, -- Normal text in floating windows.
65+
NormalFloat = { fg = spec.fg1, bg = config.darken.floats and spec.bg0 or spec.bg1 }, -- Normal text in floating windows.
6666
FloatBorder = { fg = c.border.default }, -- TODO
6767
Pmenu = { fg = spec.fg1, bg = spec.bg0 }, -- Popup menu: normal item.
6868
PmenuSel = { bg = spec.sel1 }, -- Popup menu: selected item.
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
local assert = require('luassert')
2+
local t_util = require('github-theme._test.util')
3+
local C = require('github-theme.lib.color')
4+
local api = vim.api
5+
6+
if not api.nvim_get_hl then
7+
return
8+
end
9+
10+
describe('config > options > darken', function()
11+
before_each(function()
12+
require('github-theme.config').reset()
13+
end)
14+
15+
describe('> floats', function()
16+
for _, variant in ipairs(require('github-theme.palette').themes) do
17+
-- TODO: see #324
18+
local _it = variant:find('high[-_]*contrast') and pending or it
19+
20+
_it(('should be enabled by default (%s)'):format(variant), function()
21+
require('github-theme').setup()
22+
vim.cmd.colorscheme({ args = { variant } })
23+
local normal_float = t_util.get_hl('NormalFloat')
24+
local normal = t_util.get_hl('Normal')
25+
26+
assert.is_true(require('github-theme.config').options.darken.floats)
27+
assert.are.not_equal(normal_float.bg, normal.bg)
28+
assert(
29+
C(('#%x'):format(normal_float.bg)):luminance()
30+
< C(('#%x'):format(normal.bg)):luminance(),
31+
('expected `bg` of `NormalFloat` (#%x) to be darker than `bg` of `Normal` (#%x)'):format(
32+
normal_float.bg,
33+
normal.bg
34+
)
35+
)
36+
end)
37+
38+
it(('should be disabled when set to `false` (%s)'):format(variant), function()
39+
require('github-theme').setup({ options = { darken = { floats = false } } })
40+
vim.cmd.colorscheme({ args = { variant } })
41+
local normal_float = t_util.get_hl('NormalFloat')
42+
local normal = t_util.get_hl('Normal')
43+
44+
assert.is_false(require('github-theme.config').options.darken.floats)
45+
assert.are.equal(normal_float.bg, normal.bg)
46+
end)
47+
end
48+
end)
49+
end)

0 commit comments

Comments
 (0)