Commit 282aea9 1 parent 796ecdd commit 282aea9 Copy full SHA for 282aea9
File tree 4 files changed +18
-12
lines changed
4 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
18
18
19
19
### Issues Fix
20
20
21
+ - Fixed bug where the current theme gets compiled multiple times instead of compiling all themes
21
22
- Fixed few regex-based/legacy highlight corrections (fixed #285 )
22
23
- Closed #251
23
24
Original file line number Diff line number Diff line change @@ -99,10 +99,10 @@ function M.reset()
99
99
end
100
100
101
101
function M .get_compiled_info (opts )
102
+ opts = opts or {}
102
103
local output_path = opts .output_path or M .options .compile_path
103
104
local file_suffix = opts .file_suffix or M .options .compile_file_suffix
104
- local style = opts .name or M .theme
105
- return output_path , util .join_paths (output_path , style .. file_suffix )
105
+ return output_path , util .join_paths (output_path , (opts .theme or M .theme ) .. file_suffix )
106
106
end
107
107
108
108
function M .hash ()
Original file line number Diff line number Diff line change @@ -24,13 +24,14 @@ function M.reset()
24
24
require (' github-theme.override' ).reset ()
25
25
end
26
26
27
+ --- Compiles all themes/styles with their current settings.
28
+ --- @return nil
27
29
function M .compile ()
28
30
require (' github-theme.lib.log' ).clear ()
29
-
30
31
local compiler = require (' github-theme.lib.compiler' )
31
32
local themes = require (' github-theme.palette' ).themes
32
- for _ , style in ipairs (themes ) do
33
- compiler .compile ({ style = style })
33
+ for _ , theme in ipairs (themes ) do
34
+ compiler .compile ({ theme = theme })
34
35
end
35
36
end
36
37
@@ -94,8 +95,9 @@ M.setup = function(opts)
94
95
local cached_path = util .join_paths (config .options .compile_path , ' cache' )
95
96
local cached = read_file (cached_path )
96
97
97
- local git_path = util .join_paths (debug.getinfo (1 ).source :sub (2 , - 27 ), ' .git' )
98
- local git = vim .fn .getftime (git_path )
98
+ local git_path =
99
+ vim .fn .resolve (vim .fn .fnamemodify (debug.getinfo (1 ).source :sub (2 , - 27 ), ' :p' ))
100
+ local git = vim .fn .getftime (util .join_paths (git_path :gsub (' [\\ /]+$' , ' ' ), ' .git' ))
99
101
local hash = require (' github-theme.lib.hash' )(opts ) .. (git == - 1 and git_path or git )
100
102
101
103
if cached ~= hash then
Original file line number Diff line number Diff line change @@ -22,10 +22,14 @@ local function should_link(link)
22
22
return link and link ~= ' '
23
23
end
24
24
25
+ --- Compiles a single theme/style. `opts.theme` specifies the theme to compile,
26
+ --- otherwise the currently-set theme will be compiled.
27
+ --- @param opts ? { theme : string }
28
+ --- @return nil
25
29
function M .compile (opts )
26
30
opts = opts or {}
27
- local theme = config .theme
28
- local spec = require (' github-theme.spec' ).load (theme )
31
+ opts . theme = opts . theme or config .theme
32
+ local spec = require (' github-theme.spec' ).load (opts . theme )
29
33
local groups = require (' github-theme.group' ).from (spec )
30
34
local background = spec .palette .meta .light and ' light' or ' dark'
31
35
@@ -39,7 +43,7 @@ vim.o.termguicolors = true
39
43
vim.g.colors_name = "%s"
40
44
vim.o.background = "%s"
41
45
]] ,
42
- theme ,
46
+ opts . theme ,
43
47
background
44
48
),
45
49
}
@@ -65,8 +69,6 @@ vim.o.background = "%s"
65
69
end
66
70
67
71
table.insert (lines , ' end)' )
68
-
69
- opts .name = theme
70
72
local output_path , output_file = config .get_compiled_info (opts )
71
73
util .ensure_dir (output_path )
72
74
@@ -94,6 +96,7 @@ Bellow is the error message:
94
96
tmpfile
95
97
)
96
98
)
99
+
97
100
local efile = io.open (tmpfile , ' wb' )
98
101
efile :write (table.concat (lines , ' \n ' ))
99
102
efile :close ()
You can’t perform that action at this time.
0 commit comments