Skip to content

Commit

Permalink
breaking-change: method of setting colorscheme changed
Browse files Browse the repository at this point in the history
The `theme_style` option has been removed from the `setup` and the
method of setting the colorscheme has changed. To set the colorscheme,
use the `:colorscheme` command after calling setup.

Refer to ':h github-theme.changelog-11042023' for more information, and
README has also been updated.
  • Loading branch information
ful1e5 committed Apr 11, 2023
1 parent 79be3b5 commit 33369e9
Show file tree
Hide file tree
Showing 31 changed files with 213 additions and 118 deletions.
15 changes: 7 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

### What's New?
### Deprecation & Breaking Changes

- Added a Deprecation library to print Deprecation Messages.
- The Method of setting and loading colorscheme is changed. Refer to `:h github-theme.changelog-10042023`
- The `config.vim_config` and `config.default` modules are now deprecated.
- The `config.apply_configuration()` function is also deprecated.
- The `theme_style` option is deprecated and use `:colorscheme` command instead.

### Changes
### What's New?

- Added a Deprecation library to print Deprecation Messages.

This comment has been minimized.

Copy link
@tmillr

tmillr Apr 25, 2023

Member

@ful1e5 you may be interested in nvim's vim.deprecate() function

This comment has been minimized.

Copy link
@ful1e5

ful1e5 Apr 25, 2023

Author Member

It's usually recommended to use built-in functions to notify changes, but I found the message a bit confusing and felt like I didn't have full control over deprecation messages. That's why I decided to use a custom module from nightfox instead.

- The `config.default` module has been changed to a variable and moved inside the `config` module.

### Deprecation

- The `config.vim_config` and `config.default` modules are now deprecated.
- The `config.apply_configuration()` function is also deprecated.

### Issues Fix

- #238 fixed
Expand Down
49 changes: 32 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,26 @@ use({
require('github-theme').setup({
-- ...
})

vim.cmd('colorscheme github_dark')
end
})
```

## Usage

Enable the colorscheme:
Setting the colorscheme:

```lua
require('github-theme').setup()
```

Enable the colorscheme:

```lua
vim.cmd('colorscheme github_dark')
```

## Configuration

| Option | Default | Description |
Expand All @@ -98,14 +106,12 @@ require('github-theme').setup()
| msg_area_style | `NONE` | Highlight style for messages and cmdline (check `:help highlight-args` for options) |
| overrides | `function` | Override specific highlight groups. The function accpet colors as argument. You can also add a non-exists highlight by enabling the `dev` mode. |
| sidebars | `{}` | Set a darker background on sidebar-like windows. For example: `{"qf", "vista_kind", "terminal", "packer"}` |
| theme_style | `dark` | Set theme variant (options: `dark`/`dimmed`/`dark_default`/`dark_colorblind`/`light`/`light_default`/`light_colorblind`) |
| transparent | `false` | Enable this to disable setting the background color |
| variable_style | `NONE` | Highlight style for variables and identifiers (check `:help highlight-args` for options) |

```lua
-- Example config in Lua
require("github-theme").setup({
theme_style = "dark",
function_style = "italic",
sidebars = {"qf", "vista_kind", "terminal", "packer"},

Expand All @@ -122,6 +128,8 @@ require("github-theme").setup({
}
end
})

vim.cmd('colorscheme github_dark')
```

## Features
Expand Down Expand Up @@ -196,9 +204,10 @@ set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{25

```lua
require("github-theme").setup({
theme_style = "dark",
-- other config
-- ...
})

vim.cmd('colorscheme github_dark')
```

![github_dark](https://imgur.com/XWxKWc8.png)
Expand All @@ -207,9 +216,10 @@ require("github-theme").setup({

```lua
require("github-theme").setup({
theme_style = "dimmed",
-- other config
-- ...
})

vim.cmd('colorscheme github_dimmed')
```

![github_dimmed](https://imgur.com/lMk4ifs.png)
Expand All @@ -218,9 +228,10 @@ require("github-theme").setup({

```lua
require("github-theme").setup({
theme_style = "dark_default",
-- other config
-- ...
})

vim.cmd('colorscheme github_dark_default')
```

![github_dark_default](https://imgur.com/ZfZcBGN.png)
Expand All @@ -229,9 +240,10 @@ require("github-theme").setup({

```lua
require("github-theme").setup({
theme_style = "dark_colorblind",
-- other config
-- ...
})

vim.cmd('colorscheme github_dark_colorblind')
```

![github_dark_colorblind](https://imgur.com/OIXgRL4.png)
Expand All @@ -240,9 +252,10 @@ require("github-theme").setup({

```lua
require("github-theme").setup({
theme_style = "light",
-- other config
-- ...
})

vim.cmd('colorscheme github_light')
```

![github_light](https://imgur.com/OPwBDI4.png)
Expand All @@ -251,9 +264,10 @@ require("github-theme").setup({

```lua
require("github-theme").setup({
theme_style = "light_default",
-- other config
-- ...
})

vim.cmd('colorscheme github_light_default')
```

![github_light_default](https://imgur.com/r9uPo5B.png)
Expand All @@ -262,9 +276,10 @@ require("github-theme").setup({

```lua
require("github-theme").setup({
theme_style = "light_colorblind",
-- other config
-- ...
})

vim.cmd('colorscheme github_light_colorblind')
```

![github_light_colorblind](https://imgur.com/fL4ZOUg.png)
Expand Down
4 changes: 3 additions & 1 deletion colors/github_dark.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
lua << EOF
require("github-theme").setup({theme_style = "dark"})

-- require("github-theme.config").set_theme('github_dark')
require("github-theme").load()
EOF
4 changes: 3 additions & 1 deletion colors/github_dark_colorblind.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
lua << EOF
require("github-theme").setup({theme_style = "dark_colorblind"})

require("github-theme.config").set_theme('github_dark_colorblind')
require("github-theme").load()
EOF
4 changes: 3 additions & 1 deletion colors/github_dark_default.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
lua << EOF
require("github-theme").setup({theme_style = "dark_default"})

require("github-theme.config").set_theme('github_dark_default')
require("github-theme").load()
EOF
4 changes: 3 additions & 1 deletion colors/github_dimmed.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
lua << EOF
require("github-theme").setup({theme_style = "dimmed"})

require("github-theme.config").set_theme('github_dimmed')
require("github-theme").load()
EOF
4 changes: 3 additions & 1 deletion colors/github_light.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
lua << EOF
require("github-theme").setup({theme_style = "light"})

require("github-theme.config").set_theme('github_light')
require("github-theme").load()
EOF
4 changes: 3 additions & 1 deletion colors/github_light_colorblind.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
lua << EOF
require("github-theme").setup({theme_style = "light_colorblind"})

require("github-theme.config").set_theme('github_light_colorblind')
require("github-theme").load()
EOF
4 changes: 3 additions & 1 deletion colors/github_light_default.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
lua << EOF
require("github-theme").setup({theme_style = "light_default"})

require("github-theme.config").set_theme('github_light_default')
require("github-theme").load()
EOF
31 changes: 31 additions & 0 deletions doc/gt_changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,37 @@

# Changelog

*github-theme.changelog-11042023*
Date: April 11, 2023

In the |setup| function, the |theme_style| option has been removed, and the
process of setting the colorscheme has been changed, It is important to note
that the configuration may undergo further changes in the future, and will be
described in the latest changelogs and documentation.

Additionally, the currently used colorscheme palettes within the *palette*
module have been given the prefix |'github_'|.

Old approach for setting the theme:
>
require('github-theme').setup({
theme_style = 'dark',
--- ...
})
<
New approach for setting the theme:
>
require('github-theme').setup({
--- ...
})
vim.cmd('colorscheme github_dark')
-- or
-- vim.cmd.colorscheme('github_dark')
<



*github-theme.changelog-06042023*

Date: April 06, 2023
Expand Down
27 changes: 20 additions & 7 deletions doc/gt_deprecated.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ They should not be used in new scripts, and old scripts should be updated.
==============================================================================
Deprecated features


MODULES
- *'colors'* Moved to |'github-theme.palette'|
- *'config.vim_config'* Deprecated.
- *'config.default'* Moved to |'github-theme.config'|
module and accessed with |'default'| variable.
SETUP OPTIONS
- *'theme_style'* Removed. Use 'colorscheme'
command to set colorscheme. Refer `':h github-theme.changelog-11042023'`

GLOBAL OPTIONS
- *'vim.g.github_theme_style'* Use |setup| Lua function instead.
Expand All @@ -34,8 +31,24 @@ GLOBAL OPTIONS
- *'vim.g.github_variable_style'* Use |setup| Lua function instead.
- *'vim.g.github_dev'* Use |setup| Lua function instead.

MODULES
- *'palette.dark'* Moved to |'github-theme.palette.github_dark'|
- *'palette.dark_colorblind'* Moved to |'github-theme.palette.github_dark_colorblind'|
- *'palette.dark_default'* Moved to |'github-theme.palette.github_dark_default'|
- *'palette.dimmed'* Moved to |'github-theme.palette.github_dimmed'|
- *'palette.light'* Moved to |'github-theme.palette.github_light'|
- *'palette.light_colorblind'* Moved to |'github-theme.palette.github_light_colorblind'|
- *'palette.light_default'* Moved to |'github-theme.palette.github_light_default'|
- *'colors'* Moved to |'github-theme.palette'|
- *'config.vim_config'* Removed.
- *'config.default'* Moved to |'github-theme.config'|
module and accessed with |'default'| variable.

FUNCTIONS
- *'config.apply_configuration()'* Deprecated.
- *'config.apply_configuration()'* Removed.
- *'util.load()'* Use |require('github-theme').load()|
function instead.



vim:noet:tw=78:ts=8:ft=help:norl:
35 changes: 16 additions & 19 deletions lua/github-theme/autocmds.lua
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
local config = require('github-theme.config')
local cfg = config.options

---@class gt.Autocmds
local M = {
colors_name = 'github_' .. cfg.theme_style,
}
local M = {}

---Delete the autocmds when the theme changes to something else
M.on_colorscheme = function()
if vim.g.colors_name ~= M.colors_name then
vim.cmd('silent! autocmd! ' .. M.colors_name)
vim.cmd('silent! augroup!' .. M.colors_name)
if vim.g.colors_name ~= config.theme then
vim.cmd('silent! autocmd! ' .. config.theme)
vim.cmd('silent! augroup!' .. config.theme)
end
end

M.viml_cmds = function()
vim.cmd(string.format('augroup %s ', M.colors_name))
vim.cmd(string.format('augroup %s ', config.theme))
vim.cmd('autocmd!')
vim.cmd('autocmd ColorScheme * lua require("github-theme.autocmds").on_colorscheme()')
if cfg.dev then
if config.options.dev then
vim.cmd(
string.format(
'autocmd BufWritePost */lua/github-theme/** nested colorscheme %s',
M.colors_name
config.theme
)
)
end
for _, sidebar in ipairs(cfg.sidebars) do
for _, sidebar in ipairs(config.options.sidebars) do
if sidebar == 'terminal' then
vim.cmd(
'autocmd TermOpen * setlocal winhighlight=Normal:NormalSB,SignColumn:SignColumnSB'
Expand All @@ -44,27 +41,27 @@ M.viml_cmds = function()
end

M.native_cmds = function()
local group = vim.api.nvim_create_augroup(M.colors_name, { clear = false })
local group = vim.api.nvim_create_augroup(config.theme, { clear = false })

-- Delete the github-theme autocmds when the theme changes to something else
vim.api.nvim_create_autocmd('ColorScheme', {
pattern = '*',
group = group,
callback = function()
if vim.g.colors_name ~= M.colors_name then
if vim.g.colors_name ~= config.theme then
pcall(vim.api.nvim_del_augroup_by_id, group)
end
end,
})

if cfg.dev then
if config.options.dev then
-- Enables hot-reloading in github-nvim-theme.
vim.api.nvim_create_autocmd('BufWritePost', {
pattern = '*/lua/github-theme/**',
nested = true,
group = group,
callback = function()
vim.cmd(string.format('colorscheme %s', M.colors_name))
vim.cmd(string.format('colorscheme %s', config.theme))
end,
})
end
Expand All @@ -73,7 +70,7 @@ M.native_cmds = function()
vim.wo.winhighlight = 'Normal:NormalSB,SignColumn:SignColumnSB'
end

for _, sidebar in ipairs(cfg.sidebars) do
for _, sidebar in ipairs(config.options.sidebars) do
if sidebar == 'terminal' then
-- Set dark color for terminal background.,
vim.api.nvim_create_autocmd('TermOpen', {
Expand All @@ -98,11 +95,11 @@ end

M.set = function()
if vim.fn.has('nvim-0.7') == 1 then
if not pcall(M.native_cmds, config, colors_name) then
M.viml_cmds(config, colors_name)
if not pcall(M.native_cmds) then
M.viml_cmds()
end
else
M.viml_cmds(config, colors_name)
M.viml_cmds()
end
end

Expand Down
Loading

0 comments on commit 33369e9

Please sign in to comment.