@@ -72,38 +72,44 @@ function M.load(opts)
7272end
7373
7474M .setup = function (opts )
75+ local override = require (' github-theme.override' )
76+ local keys = { ' palettes' , ' specs' , ' groups' }
7577 did_setup = true
7678 opts = opts or {}
7779
78- local override = require (' github-theme.override' )
79-
8080 -- New configs
8181 if opts .options then
8282 config .set_options (opts .options )
8383 end
8484
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
9590 end
9691
9792 local util = require (' github-theme.util' )
9893 util .ensure_dir (config .options .compile_path )
9994
10095 local cached_path = util .join_paths (config .options .compile_path , ' cache' )
10196 local cached = read_file (cached_path )
102-
10397 local git_path =
10498 vim .fn .fnamemodify (vim .fn .resolve (debug.getinfo (1 ).source :sub (2 )), ' :p:h:h:h' )
10599 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 )
107113
108114 if cached ~= hash then
109115 M .compile ()
0 commit comments