Skip to content

Commit 8d36475

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: 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`). Continue to accept `options.darken.sidebars.enabled` for backwards-compatibility. Either may be used: `enabled` is now coerced to `enable` in `config.lua`. 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 086b5d6 commit 8d36475

File tree

7 files changed

+24
-10
lines changed

7 files changed

+24
-10
lines changed

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/config.lua

+14
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,20 @@ end
9090

9191
function M.set_options(opts)
9292
opts = opts or {}
93+
94+
-- Allow `enabled` for backwards-compatibility, but `enable` is canonical and
95+
-- has precedence.
96+
if
97+
type(opts.darken) == 'table'
98+
and type(opts.darken.sidebars) == 'table'
99+
and opts.darken.sidebars.enabled ~= nil
100+
then
101+
if opts.darken.sidebars.enable == nil then
102+
opts.darken.sidebars.enable = opts.darken.sidebars.enabled
103+
end
104+
opts.darken.sidebars.enabled = nil
105+
end
106+
93107
M.options = collect.deep_extend(M.options, opts)
94108
M.has_options = true
95109
end

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

0 commit comments

Comments
 (0)