Skip to content

Commit

Permalink
fix(config): options.darken.sidebars.enabled
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tmillr committed Jul 12, 2024
1 parent da7281e commit 0db0915
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ require('github-theme').setup({
darken = { -- Darken floating windows and sidebar-like windows
floats = true,
sidebars = {
enabled = true,
enable = true,
list = {}, -- Apply dark background to specific windows
},
},
Expand Down
6 changes: 3 additions & 3 deletions Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ Another setting is for sidebars, which is configured in the `sidebars` sub-table

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

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

Example:

Expand All @@ -259,7 +259,7 @@ local options = {
darken = {
floats = false,
sidebars = {
enabled = true,
enable = true,
list = {'qf', 'netrw'} -- default is {}
}
}
Expand Down
6 changes: 3 additions & 3 deletions doc/github-nvim-theme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ sub-table.
options.darken.sidebars {table} *github-nvim-theme-options.darken.sidebars*

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

Example:

Expand All @@ -342,7 +342,7 @@ Example:
darken = {
floats = false,
sidebars = {
enabled = true,
enable = true,
list = {'qf', 'netrw'} -- default is {}
}
}
Expand Down
14 changes: 14 additions & 0 deletions lua/github-theme/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ end

function M.set_options(opts)
opts = opts or {}

-- Allow `enabled` for backwards-compatibility, but `enable` is canonical and
-- has precedence.
if
type(opts.darken) == 'table'
and type(opts.darken.sidebars) == 'table'
and opts.darken.sidebars.enabled ~= nil
then
if opts.darken.sidebars.enable == nil then
opts.darken.sidebars.enable = opts.darken.sidebars.enabled
end
opts.darken.sidebars.enabled = nil
end

M.options = collect.deep_extend(M.options, opts)
M.has_options = true
end
Expand Down
2 changes: 1 addition & 1 deletion lua/github-theme/group/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local C = require('github-theme.lib.color')
local M = {}

function M.get(spec, config)
local dark_sb = config.darken.sidebars.enabled
local dark_sb = config.darken.sidebars.enable
local hide_eof = config.hide_end_of_buffer
local inactive = config.dim_inactive
local inv = config.inverse
Expand Down
2 changes: 1 addition & 1 deletion lua/github-theme/group/modules/neotree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local M = {}

function M.get(spec, config, opts)
local hide_eof = config.hide_end_of_buffer
local dark_sb = config.darken.sidebars
local dark_sb = config.darken.sidebars.enable
local c = spec.palette

local function blend(color, a)
Expand Down
2 changes: 1 addition & 1 deletion lua/github-theme/group/modules/nvimtree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local M = {}

function M.get(spec, config, opts)
local hide_eof = config.hide_end_of_buffer
local dark_sb = config.darken.sidebars
local dark_sb = config.darken.sidebars.enable
local c = spec.palette

-- stylua: ignore
Expand Down

0 comments on commit 0db0915

Please sign in to comment.