Skip to content

Commit 80fb5cc

Browse files
authored
fix(config): options.darken.sidebars.enabled (#343)
Problem: `options.darken.sidebars.enabled` and `options.darken.sidebars.enable` both exist, but it is only one option. The default in `config.lua` is `enable`, but it is referred to as `enabled` as well (both in code and docs). It used to be `enable` but was renamed to `enabled`, so it is technically supposed to be `options.darken.sidebars.enabled` at this time (as of this commit's parent). Solution: Deprecate and revert `options.darken.sidebars.enabled` back to `options.darken.sidebars.enable`. This brings it back in-line with the changelog and runtime deprecation checks. `enable` is also more consistent as this is what is used in other parts of the config (e.g. config for `modules`). Problem: In a couple of places, `options.darken.sidebars` is checked for truthiness. This seems to be a typo of `options.darken.sidebars.enable` which is a boolean (unlike the former, which is a table by default and also documented as a table). Tables are always truthy. Solution: Use `options.darken.sidebars.enable` instead of `options.darken.sidebars` in conditionals. Reverts: fff3e20 Reverts: 806903c Fixes: #306
1 parent bd87e84 commit 80fb5cc

File tree

9 files changed

+70
-15
lines changed

9 files changed

+70
-15
lines changed

CHANGELOG.md

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

88
## [unreleased]
99

10+
### Configuration Deprecation and Migration
11+
12+
- Reverted/renamed `options.darken.sidebars.enabled` back to `options.darken.sidebars.enable` (see #343)
13+
1014
### What's New?
1115

1216
- Added new highlight groups for mini.nvim (#333 by @echasnovski)
@@ -32,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3236
- Fixed #340 and #341 (broken/outdated `overrides` example in docs)
3337
- Fixed floats not transparent when `transparent = true` (#337 fixed-by #351)
3438
- fix(Color): `Color.from_hsv()` is used for HSL
39+
- Fixed sidebar is not darkened when configured to do so (affects neo-tree, etc.) (#306 fixed-by #343)
3540

3641
## [v1.0.2] - 03 May 2023
3742

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ require('github-theme').setup({
283283
darken = { -- Darken floating windows and sidebar-like windows
284284
floats = true,
285285
sidebars = {
286-
enabled = true,
286+
enable = true,
287287
list = {}, -- Apply dark background to specific windows
288288
},
289289
},

Usage.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ Another setting is for sidebars, which is configured in the `sidebars` sub-table
249249

250250
#### options.darken.sidebars {table}
251251

252-
The `sidebars` sub table of `darken` contains settings for sidebar-like windows. It has two configurations: `enabled` is used to assign a darker background
253-
to the listed windows, and `list` specifies the windows to be included in the list.
252+
The `sidebars` sub table of `darken` contains settings for sidebar-like windows. It has two configurations: `enable` is used to assign a darker background
253+
to the listed windows, and `list` specifies the windows to be darkened.
254254

255255
Example:
256256

@@ -259,7 +259,7 @@ local options = {
259259
darken = {
260260
floats = false,
261261
sidebars = {
262-
enabled = true,
262+
enable = true,
263263
list = {'qf', 'netrw'} -- default is {}
264264
}
265265
}

doc/github-nvim-theme.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,9 @@ sub-table.
331331
options.darken.sidebars {table} *github-nvim-theme-options.darken.sidebars*
332332

333333
The `sidebars` sub table of `darken` contains settings for sidebar-like
334-
windows. It has two configurations: `enabled` is used to assign a darker
334+
windows. It has two configurations: `enable` is used to assign a darker
335335
background to the listed windows, and `list` specifies the windows to be
336-
included in the list.
336+
darkened.
337337

338338
Example:
339339

@@ -342,7 +342,7 @@ Example:
342342
darken = {
343343
floats = false,
344344
sidebars = {
345-
enabled = true,
345+
enable = true,
346346
list = {'qf', 'netrw'} -- default is {}
347347
}
348348
}

lua/github-theme/group/editor.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function M.get(spec, config)
4747
MoreMsg = { fg = spec.diag.info, style = 'bold' }, -- |more-prompt|
4848
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|.
4949
Normal = { fg = spec.fg1, bg = trans and 'NONE' or spec.bg1 }, -- normal text
50-
NormalSB = { fg = spec.fg1, bg = trans and 'NONE' or config.darken.sidebars.enabled and spec.bg0 or spec.bg1 }, -- normal text
50+
NormalSB = { fg = spec.fg1, bg = trans and 'NONE' or config.darken.sidebars.enable and spec.bg0 or spec.bg1 }, -- normal text
5151

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

lua/github-theme/group/modules/neotree.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ local M = {}
77

88
function M.get(spec, config, opts)
99
local hide_eof = config.hide_end_of_buffer
10-
local dark_sb = config.darken.sidebars
10+
local dark_sb = config.darken.sidebars.enable
1111
local c = spec.palette
1212

1313
local function blend(color, a)

lua/github-theme/group/modules/nvimtree.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local M = {}
44

55
function M.get(spec, config, opts)
66
local hide_eof = config.hide_end_of_buffer
7-
local dark_sb = config.darken.sidebars
7+
local dark_sb = config.darken.sidebars.enable
88
local c = spec.palette
99

1010
-- stylua: ignore

lua/github-theme/util/deprecation.lua

+10
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,16 @@ M.check_deprecation = function(opts)
157157
' for more info.'
158158
)
159159
end
160+
161+
if (((opts.options or {}).darken or {}).sidebars or {}).enabled ~= nil then
162+
dep.write(
163+
' ',
164+
{ 'options.darken.sidebars.enabled', 'WarningMsg' },
165+
' has been renamed/reverted back to ',
166+
{ 'options.darken.sidebars.enable', 'WarningMsg' }
167+
)
168+
end
169+
160170
M.checked_deprecation = true
161171
end
162172

test/github-theme/config/darken_spec.lua

+45-5
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@ end
88

99
describe('config > options > darken', function()
1010
before_each(function()
11+
-- Could reset more than just this, but this alone seems to work now that the
12+
-- compiler is fixed.
1113
require('github-theme.config').reset()
1214
end)
1315

1416
describe('> floats', function()
1517
for _, variant in ipairs(require('github-theme.palette').themes) do
1618
-- TODO: see #324
17-
local _it = variant:find('high[-_]*contrast') and pending or it
19+
local it_or_pending = variant:find('high[-_]*contrast') and pending or it
1820

19-
_it(('should be enabled by default (%s)'):format(variant), function()
21+
it_or_pending(('should be enabled by default (%s)'):format(variant), function()
2022
require('github-theme').setup()
2123
vim.cmd.colorscheme({ args = { variant } })
2224
local normal_float = t_util.get_hl('NormalFloat')
2325
local normal = t_util.get_hl('Normal')
2426

2527
assert.is_true(require('github-theme.config').options.darken.floats)
26-
assert.are.not_equal(normal_float.bg, normal.bg)
28+
assert.are.not_equal(normal.bg, normal_float.bg)
2729
assert(
2830
C(('#%x'):format(normal_float.bg)):luminance()
2931
< C(('#%x'):format(normal.bg)):luminance(),
@@ -39,10 +41,48 @@ describe('config > options > darken', function()
3941
vim.cmd.colorscheme({ args = { variant } })
4042
local normal_float = t_util.get_hl('NormalFloat')
4143
local normal = t_util.get_hl('Normal')
42-
4344
assert.is_false(require('github-theme.config').options.darken.floats)
44-
assert.are.equal(normal_float.bg, normal.bg)
45+
assert.are.equal(normal.bg, normal_float.bg)
4546
end)
4647
end
4748
end)
49+
50+
describe('> sidebars', function()
51+
describe('> enable', function()
52+
for _, variant in ipairs(require('github-theme.palette').themes) do
53+
-- TODO: see #324
54+
local it_or_pending = variant:find('high[-_]*contrast') and pending or it
55+
56+
it_or_pending(('should be enabled by default (%s)'):format(variant), function()
57+
require('github-theme').setup()
58+
vim.cmd.colorscheme({ args = { variant } })
59+
local normal_sb = t_util.get_hl('NormalSB')
60+
local normal = t_util.get_hl('Normal')
61+
62+
assert.is_true(require('github-theme.config').options.darken.sidebars.enable)
63+
assert.are.not_equal(normal.bg, normal_sb.bg)
64+
assert(
65+
C(('#%x'):format(normal_sb.bg)):luminance()
66+
< C(('#%x'):format(normal.bg)):luminance(),
67+
('expected `bg` of `NormalFloat` (#%x) to be darker than `bg` of `Normal` (#%x)'):format(
68+
normal_sb.bg,
69+
normal.bg
70+
)
71+
)
72+
end)
73+
74+
it(('should be disabled when set to `false` (%s)'):format(variant), function()
75+
require('github-theme').setup({
76+
options = { darken = { sidebars = { enable = false } } },
77+
})
78+
79+
vim.cmd.colorscheme({ args = { variant } })
80+
local normal_sb = t_util.get_hl('NormalSB')
81+
local normal = t_util.get_hl('Normal')
82+
assert.is_false(require('github-theme.config').options.darken.sidebars.enable)
83+
assert.are.equal(normal.bg, normal_sb.bg)
84+
end)
85+
end
86+
end)
87+
end)
4888
end)

0 commit comments

Comments
 (0)