diff --git a/CHANGELOG.md b/CHANGELOG.md index 05369255..75f1be59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] +### Configuration Deprecation and Migration + +- Reverted/renamed `options.darken.sidebars.enabled` back to `options.darken.sidebars.enable` (see #343) + ### What's New? - 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 ### Issues Fix -- Fixed `punctuation.delimiter` treesitter group nearly invisible (#329 fixed by #331) +- Fixed `punctuation.delimiter` treesitter group nearly invisible (#329 fixed-by #331) - Closed #305 (no longer valid, fixed) - Closed #292 (no longer valid, fixed) - fix(config): `options.darken.floats` is not used (#345) +- Fixed sidebar is not darkened when configured to do so (affects neo-tree, etc.) (#306 fixed-by #343) ## [v1.0.2] - 03 May 2023 diff --git a/Makefile b/Makefile index f8d96d34..a7433a3a 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ test: $(PLENARY_DIR) --headless \ --noplugin \ -u test/minimal_init.vim \ - -c "PlenaryBustedDirectory $(TEST_DIR) { minimal_init = './test/minimal_init.vim' }" + -c "PlenaryBustedDirectory $(TEST_DIR) { minimal_init = './test/minimal_init.vim', sequential = true }" $(PLENARY_DIR): git clone --depth=1 --no-single-branch $(PLENARY_URL) $(PLENARY_DIR) diff --git a/README.md b/README.md index 56e9b168..94fcce57 100644 --- a/README.md +++ b/README.md @@ -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 }, }, diff --git a/Usage.md b/Usage.md index 62092fab..3bf88173 100644 --- a/Usage.md +++ b/Usage.md @@ -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: @@ -259,7 +259,7 @@ local options = { darken = { floats = false, sidebars = { - enabled = true, + enable = true, list = {'qf', 'netrw'} -- default is {} } } diff --git a/doc/github-nvim-theme.txt b/doc/github-nvim-theme.txt index ee71ea4a..a1cf6d32 100644 --- a/doc/github-nvim-theme.txt +++ b/doc/github-nvim-theme.txt @@ -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: @@ -342,7 +342,7 @@ Example: darken = { floats = false, sidebars = { - enabled = true, + enable = true, list = {'qf', 'netrw'} -- default is {} } } diff --git a/lua/github-theme/group/editor.lua b/lua/github-theme/group/editor.lua index 060d9234..7b192a7d 100644 --- a/lua/github-theme/group/editor.lua +++ b/lua/github-theme/group/editor.lua @@ -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 diff --git a/lua/github-theme/group/modules/neotree.lua b/lua/github-theme/group/modules/neotree.lua index ead411db..cfd149a5 100644 --- a/lua/github-theme/group/modules/neotree.lua +++ b/lua/github-theme/group/modules/neotree.lua @@ -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) diff --git a/lua/github-theme/group/modules/nvimtree.lua b/lua/github-theme/group/modules/nvimtree.lua index 9bfb7535..04279a8b 100644 --- a/lua/github-theme/group/modules/nvimtree.lua +++ b/lua/github-theme/group/modules/nvimtree.lua @@ -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 diff --git a/lua/github-theme/util/deprecation.lua b/lua/github-theme/util/deprecation.lua index 6365c08e..538ec850 100644 --- a/lua/github-theme/util/deprecation.lua +++ b/lua/github-theme/util/deprecation.lua @@ -157,6 +157,16 @@ M.check_deprecation = function(opts) ' for more info.' ) end + + if (((opts.options or {}).darken or {}).sidebars or {}).enabled ~= nil then + dep.write( + ' ', + { 'options.darken.sidebars.enabled', 'WarningMsg' }, + ' has been renamed/reverted back to ', + { 'options.darken.sidebars.enable', 'WarningMsg' } + ) + end + M.checked_deprecation = true end diff --git a/test/github-theme/config/darken_spec.lua b/test/github-theme/config/darken_spec.lua index 063a3289..b804e651 100644 --- a/test/github-theme/config/darken_spec.lua +++ b/test/github-theme/config/darken_spec.lua @@ -3,28 +3,33 @@ local t_util = require('github-theme._test.util') local C = require('github-theme.lib.color') local api = vim.api -if not api.nvim_get_hl then +if + (vim.fn.has('nvim-0.10.0') == false or vim.fn.has('nvim-0.10.0') == 0) + and not api.nvim_get_hl +then return end describe('config > options > darken', function() - before_each(function() + after_each(function() + -- Could reset more than just this, but this alone seems to work now that the + -- compiler is fixed. require('github-theme.config').reset() end) describe('> floats', function() for _, variant in ipairs(require('github-theme.palette').themes) do -- TODO: see #324 - local _it = variant:find('high[-_]*contrast') and pending or it + local it_or_pending = variant:find('high[-_]*contrast') and pending or it - _it(('should be enabled by default (%s)'):format(variant), function() + it_or_pending(('should be enabled by default (%s)'):format(variant), function() require('github-theme').setup() vim.cmd.colorscheme({ args = { variant } }) local normal_float = t_util.get_hl('NormalFloat') local normal = t_util.get_hl('Normal') assert.is_true(require('github-theme.config').options.darken.floats) - assert.are.not_equal(normal_float.bg, normal.bg) + assert.are.not_equal(normal.bg, normal_float.bg) assert( C(('#%x'):format(normal_float.bg)):luminance() < C(('#%x'):format(normal.bg)):luminance(), @@ -40,10 +45,77 @@ describe('config > options > darken', function() vim.cmd.colorscheme({ args = { variant } }) local normal_float = t_util.get_hl('NormalFloat') local normal = t_util.get_hl('Normal') - assert.is_false(require('github-theme.config').options.darken.floats) - assert.are.equal(normal_float.bg, normal.bg) + assert.are.equal(normal.bg, normal_float.bg) end) end end) + + describe('> sidebars', function() + describe('> enable', function() + for _, variant in ipairs(require('github-theme.palette').themes) do + -- TODO: see #324 + local it_or_pending = variant:find('high[-_]*contrast') and pending or it + + it_or_pending(('should be enabled by default (%s)'):format(variant), function() + require('github-theme').setup() + vim.cmd.colorscheme({ args = { variant } }) + local normal_sb = t_util.get_hl('NormalSB') + local normal = t_util.get_hl('Normal') + + assert.is_true(require('github-theme.config').options.darken.sidebars.enable) + assert.are.not_equal(normal.bg, normal_sb.bg) + assert( + C(('#%x'):format(normal_sb.bg)):luminance() + < C(('#%x'):format(normal.bg)):luminance(), + ('expected `bg` of `NormalFloat` (#%x) to be darker than `bg` of `Normal` (#%x)'):format( + normal_sb.bg, + normal.bg + ) + ) + end) + + it(('should be disabled when set to `false` (%s)'):format(variant), function() + require('github-theme').setup({ + options = { darken = { sidebars = { enable = false } } }, + }) + + vim.cmd.colorscheme({ args = { variant } }) + local normal_sb = t_util.get_hl('NormalSB') + local normal = t_util.get_hl('Normal') + assert.is_false(require('github-theme.config').options.darken.sidebars.enable) + assert.are.equal(normal.bg, normal_sb.bg) + end) + + it(('should also accept `enabled` (%s)'):format(variant), function() + require('github-theme').setup({ + options = { darken = { sidebars = { enabled = false } } }, + }) + + vim.cmd.colorscheme({ args = { variant } }) + local normal_sb = t_util.get_hl('NormalSB') + local normal = t_util.get_hl('Normal') + assert.is_false(require('github-theme.config').options.darken.sidebars.enable) + assert.are.equal(normal.bg, normal_sb.bg) + end) + + it( + ('should accept both `enable` and `enabled` but prefer `enable` (%s)'):format( + variant + ), + function() + require('github-theme').setup({ + options = { darken = { sidebars = { enable = false, enabled = true } } }, + }) + + vim.cmd.colorscheme({ args = { variant } }) + local normal_sb = t_util.get_hl('NormalSB') + local normal = t_util.get_hl('Normal') + assert.is_false(require('github-theme.config').options.darken.sidebars.enable) + assert.are.equal(normal.bg, normal_sb.bg) + end + ) + end + end) + end) end)