@@ -72,38 +72,44 @@ function M.load(opts)
72
72
end
73
73
74
74
M .setup = function (opts )
75
+ local override = require (' github-theme.override' )
76
+ local keys = { ' palettes' , ' specs' , ' groups' }
75
77
did_setup = true
76
78
opts = opts or {}
77
79
78
- local override = require (' github-theme.override' )
79
-
80
80
-- New configs
81
81
if opts .options then
82
82
config .set_options (opts .options )
83
83
end
84
84
85
- if opts .palettes ~= nil then
86
- override .palettes = opts .palettes
87
- end
88
-
89
- if opts .specs ~= nil then
90
- override .specs = opts .specs
91
- end
92
-
93
- if opts .groups ~= nil then
94
- override .groups = opts .groups
85
+ for _ , k in ipairs (keys ) do
86
+ local v = opts [k ]
87
+ if v ~= nil then
88
+ override [k ] = v
89
+ end
95
90
end
96
91
97
92
local util = require (' github-theme.util' )
98
93
util .ensure_dir (config .options .compile_path )
99
94
100
95
local cached_path = util .join_paths (config .options .compile_path , ' cache' )
101
96
local cached = read_file (cached_path )
102
-
103
97
local git_path =
104
98
vim .fn .fnamemodify (vim .fn .resolve (debug.getinfo (1 ).source :sub (2 )), ' :p:h:h:h' )
105
99
local git = vim .fn .getftime (util .join_paths (git_path , ' .git' ))
106
- local hash = require (' github-theme.lib.hash' )(opts ) .. (git == - 1 and git_path or git )
100
+
101
+ -- This is needed because neither `opts` nor `config` necessarily contain
102
+ -- everything we need to hash. For example, `opts` may not contain all
103
+ -- overrides and config currently in use (`setup()` might have been called
104
+ -- before, or maybe overrides were set directly and outside of `setup()`), and
105
+ -- `config` does not contain any of the overrides in use. Therefore, we need
106
+ -- to create a new table which contains everything in-use.
107
+ local dummy = { options = config .options }
108
+ for _ , k in ipairs (keys ) do
109
+ dummy [k ] = override [k ]
110
+ end
111
+
112
+ local hash = require (' github-theme.lib.hash' )(dummy ) .. (git == - 1 and git_path or git )
107
113
108
114
if cached ~= hash then
109
115
M .compile ()
0 commit comments