Skip to content

Commit 9743808

Browse files
committed
fix(config): options.darken.sidebars.enabled
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, 806903c Fixes: #306
1 parent da7281e commit 9743808

File tree

10 files changed

+89
-19
lines changed

10 files changed

+89
-19
lines changed

CHANGELOG.md

+6-1
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)
@@ -18,10 +22,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1822

1923
### Issues Fix
2024

21-
- Fixed `punctuation.delimiter` treesitter group nearly invisible (#329 fixed by #331)
25+
- Fixed `punctuation.delimiter` treesitter group nearly invisible (#329 fixed-by #331)
2226
- Closed #305 (no longer valid, fixed)
2327
- Closed #292 (no longer valid, fixed)
2428
- fix(config): `options.darken.floats` is not used (#345)
29+
- Fixed sidebar is not darkened when configured to do so (affects neo-tree, etc.) (#306 fixed-by #343)
2530

2631
## [v1.0.2] - 03 May 2023
2732

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ test: $(PLENARY_DIR)
4040
--headless \
4141
--noplugin \
4242
-u test/minimal_init.vim \
43-
-c "PlenaryBustedDirectory $(TEST_DIR) { minimal_init = './test/minimal_init.vim' }"
43+
-c "PlenaryBustedDirectory $(TEST_DIR) { minimal_init = './test/minimal_init.vim', sequential = true }"
4444

4545
$(PLENARY_DIR):
4646
git clone --depth=1 --no-single-branch $(PLENARY_URL) $(PLENARY_DIR)

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
@@ -3,7 +3,7 @@ local C = require('github-theme.lib.color')
33
local M = {}
44

55
function M.get(spec, config)
6-
local dark_sb = config.darken.sidebars.enabled
6+
local dark_sb = config.darken.sidebars.enable
77
local hide_eof = config.hide_end_of_buffer
88
local inactive = config.dim_inactive
99
local inv = config.inverse

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

+62-7
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,33 @@ local t_util = require('github-theme._test.util')
33
local C = require('github-theme.lib.color')
44
local api = vim.api
55

6-
if not api.nvim_get_hl then
6+
if
7+
(vim.fn.has('nvim-0.10.0') == false or vim.fn.has('nvim-0.10.0') == 0)
8+
and not api.nvim_get_hl
9+
then
710
return
811
end
912

1013
describe('config > options > darken', function()
11-
before_each(function()
14+
after_each(function()
15+
-- Could reset more than just this, but this alone seems to work now that the
16+
-- compiler is fixed.
1217
require('github-theme.config').reset()
1318
end)
1419

1520
describe('> floats', function()
1621
for _, variant in ipairs(require('github-theme.palette').themes) do
1722
-- TODO: see #324
18-
local _it = variant:find('high[-_]*contrast') and pending or it
23+
local it_or_pending = variant:find('high[-_]*contrast') and pending or it
1924

20-
_it(('should be enabled by default (%s)'):format(variant), function()
25+
it_or_pending(('should be enabled by default (%s)'):format(variant), function()
2126
require('github-theme').setup()
2227
vim.cmd.colorscheme({ args = { variant } })
2328
local normal_float = t_util.get_hl('NormalFloat')
2429
local normal = t_util.get_hl('Normal')
2530

2631
assert.is_true(require('github-theme.config').options.darken.floats)
27-
assert.are.not_equal(normal_float.bg, normal.bg)
32+
assert.are.not_equal(normal.bg, normal_float.bg)
2833
assert(
2934
C(('#%x'):format(normal_float.bg)):luminance()
3035
< C(('#%x'):format(normal.bg)):luminance(),
@@ -40,10 +45,60 @@ describe('config > options > darken', function()
4045
vim.cmd.colorscheme({ args = { variant } })
4146
local normal_float = t_util.get_hl('NormalFloat')
4247
local normal = t_util.get_hl('Normal')
43-
4448
assert.is_false(require('github-theme.config').options.darken.floats)
45-
assert.are.equal(normal_float.bg, normal.bg)
49+
assert.are.equal(normal.bg, normal_float.bg)
4650
end)
4751
end
4852
end)
53+
54+
describe('> sidebars', function()
55+
describe('> enable', function()
56+
for _, variant in ipairs(require('github-theme.palette').themes) do
57+
-- TODO: see #324
58+
local it_or_pending = variant:find('high[-_]*contrast') and pending or it
59+
60+
it_or_pending(('should be enabled by default (%s)'):format(variant), function()
61+
require('github-theme').setup()
62+
vim.cmd.colorscheme({ args = { variant } })
63+
local normal_sb = t_util.get_hl('NormalSB')
64+
local normal = t_util.get_hl('Normal')
65+
66+
assert.is_true(require('github-theme.config').options.darken.sidebars.enable)
67+
assert.are.not_equal(normal.bg, normal_sb.bg)
68+
assert(
69+
C(('#%x'):format(normal_sb.bg)):luminance()
70+
< C(('#%x'):format(normal.bg)):luminance(),
71+
('expected `bg` of `NormalFloat` (#%x) to be darker than `bg` of `Normal` (#%x)'):format(
72+
normal_sb.bg,
73+
normal.bg
74+
)
75+
)
76+
end)
77+
78+
it(('should be disabled when set to `false` (%s)'):format(variant), function()
79+
require('github-theme').setup({
80+
options = { darken = { sidebars = { enable = false } } },
81+
})
82+
83+
vim.cmd.colorscheme({ args = { variant } })
84+
local normal_sb = t_util.get_hl('NormalSB')
85+
local normal = t_util.get_hl('Normal')
86+
assert.is_false(require('github-theme.config').options.darken.sidebars.enable)
87+
assert.are.equal(normal.bg, normal_sb.bg)
88+
end)
89+
90+
it(('should also accept `enabled` (%s)'):format(variant), function()
91+
require('github-theme').setup({
92+
options = { darken = { sidebars = { enabled = false } } },
93+
})
94+
95+
vim.cmd.colorscheme({ args = { variant } })
96+
local normal_sb = t_util.get_hl('NormalSB')
97+
local normal = t_util.get_hl('Normal')
98+
assert.is_false(require('github-theme.config').options.darken.sidebars.enable)
99+
assert.are.equal(normal.bg, normal_sb.bg)
100+
end)
101+
end
102+
end)
103+
end)
49104
end)

0 commit comments

Comments
 (0)