Skip to content

Commit

Permalink
refactor: minify colorscheme files in colors/*.vim
Browse files Browse the repository at this point in the history
Refactor and centralize all of the duplicated logic in each of the vim
files in `colors/*.vim` into `require('github-theme').load()`. This
removes duplication and moves all of the logic to Lua (file) where it is
easier to maintain.

Remove the deprecated 'github_dimmed' theme. This has been deprecated
for over a year now, so it is probably a good idea to remove it. Plus it
just wastes space and pollutes cmdline completion with an erroneous
value/theme.
  • Loading branch information
tmillr committed Aug 7, 2024
1 parent e57805c commit 770d1b5
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 123 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic

## [unreleased]

### Changes

- Minimized colorscheme files in `colors/*.vim` and refactored-out duplicated logic
- Removed the long-since deprecated `github_dimmed` theme (use `github_dark_dimmed` instead)

### Issues Fix

- Fixed JSX/TSX tags are missing highlights with nvim 0.10 (#360)
Expand Down
10 changes: 1 addition & 9 deletions colors/github_dark.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
lua << EOF

if vim.g.github_theme_debug then
require('github-theme.util.reload')()
end
require('github-theme.config').set_theme('github_dark')
require('github-theme').load()

EOF
lua require('github-theme').load({ theme = 'github_dark' })
10 changes: 1 addition & 9 deletions colors/github_dark_colorblind.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
lua << EOF

if vim.g.github_theme_debug then
require('github-theme.util.reload')()
end
require('github-theme.config').set_theme('github_dark_colorblind')
require('github-theme').load()

EOF
lua require('github-theme').load({ theme = 'github_dark_colorblind' })
10 changes: 1 addition & 9 deletions colors/github_dark_default.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
lua << EOF

if vim.g.github_theme_debug then
require('github-theme.util.reload')()
end
require('github-theme.config').set_theme('github_dark_default')
require('github-theme').load()

EOF
lua require('github-theme').load({ theme = 'github_dark_default' })
10 changes: 1 addition & 9 deletions colors/github_dark_dimmed.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
lua << EOF

if vim.g.github_theme_debug then
require('github-theme.util.reload')()
end
require('github-theme.config').set_theme('github_dark_dimmed')
require('github-theme').load()

EOF
lua require('github-theme').load({ theme = 'github_dark_dimmed' })
10 changes: 1 addition & 9 deletions colors/github_dark_high_contrast.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
lua << EOF

if vim.g.github_theme_debug then
require('github-theme.util.reload')()
end
require('github-theme.config').set_theme('github_dark_high_contrast')
require('github-theme').load()

EOF
lua require('github-theme').load({ theme = 'github_dark_high_contrast' })
10 changes: 1 addition & 9 deletions colors/github_dark_tritanopia.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
lua << EOF

if vim.g.github_theme_debug then
require('github-theme.util.reload')()
end
require('github-theme.config').set_theme('github_dark_tritanopia')
require('github-theme').load()

EOF
lua require('github-theme').load({ theme = 'github_dark_tritanopia' })
18 changes: 0 additions & 18 deletions colors/github_dimmed.vim

This file was deleted.

10 changes: 1 addition & 9 deletions colors/github_light.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
lua << EOF

if vim.g.github_theme_debug then
require('github-theme.util.reload')()
end
require('github-theme.config').set_theme('github_light')
require('github-theme').load()

EOF
lua require('github-theme').load({ theme = 'github_light' })
10 changes: 1 addition & 9 deletions colors/github_light_colorblind.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
lua << EOF

if vim.g.github_theme_debug then
require('github-theme.util.reload')()
end
require('github-theme.config').set_theme('github_light_colorblind')
require('github-theme').load()

EOF
lua require('github-theme').load({ theme = 'github_light_colorblind' })
10 changes: 1 addition & 9 deletions colors/github_light_default.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
lua << EOF

if vim.g.github_theme_debug then
require('github-theme.util.reload')()
end
require('github-theme.config').set_theme('github_light_default')
require('github-theme').load()

EOF
lua require('github-theme').load({ theme = 'github_light_default' })
10 changes: 1 addition & 9 deletions colors/github_light_high_contrast.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
lua << EOF

if vim.g.github_theme_debug then
require('github-theme.util.reload')()
end
require('github-theme.config').set_theme('github_light_high_contrast')
require('github-theme').load()

EOF
lua require('github-theme').load({ theme = 'github_light_high_contrast' })
10 changes: 1 addition & 9 deletions colors/github_light_tritanopia.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
lua << EOF

if vim.g.github_theme_debug then
require('github-theme.util.reload')()
end
require('github-theme.config').set_theme('github_light_tritanopia')
require('github-theme').load()

EOF
lua require('github-theme').load({ theme = 'github_light_tritanopia' })
8 changes: 3 additions & 5 deletions lua/github-theme/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ local defaults = {
},
}

M.options = collect.deep_copy(defaults)

M.module_names = {
'cmp',
'coc',
Expand Down Expand Up @@ -193,6 +191,7 @@ end

function M.reset()
M.options = collect.deep_copy(defaults)
return M
end

function M.get_compiled_info(opts)
Expand All @@ -203,8 +202,7 @@ function M.get_compiled_info(opts)
end

function M.hash()
local hash = require('github-theme.lib.hash')(M.options)
return hash or 0
return require('github-theme.lib.hash')(M.options) or 0
end

return M
return M.reset()
9 changes: 9 additions & 0 deletions lua/github-theme/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ end

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

if vim.g.github_theme_debug then
require('github-theme.util.reload')()
end

if opts.theme then
require('github-theme.config').set_theme(opts.theme)
end

local _, compiled_file = config.get_compiled_info(opts)
local f = loadfile(compiled_file)

Expand Down
1 change: 0 additions & 1 deletion lua/lualine/themes/github_dimmed.lua

This file was deleted.

0 comments on commit 770d1b5

Please sign in to comment.