File tree Expand file tree Collapse file tree 2 files changed +22
-11
lines changed
Expand file tree Collapse file tree 2 files changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -13,20 +13,32 @@ local M = { config = {} }
1313
1414local util = require " astrotheme.lib.util"
1515
16+ local style_background = {
17+ astrodark = " dark" ,
18+ astrolight = " light" ,
19+ astromars = " dark" ,
20+ astrojupiter = " light" ,
21+ }
22+
23+ local invert_style = {
24+ astrodark = " astrolight" ,
25+ astrolight = " astrodark" ,
26+ astromars = " astrojupiter" ,
27+ astrojupiter = " astromars" ,
28+ }
29+
1630--- Load a specific theme given a palette name
1731--- @param theme ? string
1832function M .load (theme )
19- if
20- not theme
21- or (
22- theme == M .config .palette
23- and vim .o .background ~= (M .config .palette == M .config .background [" light" ] and " light" or " dark" )
24- )
25- then
33+ if not theme then
2634 theme = M .config .background [vim .o .background ]
35+ elseif theme == M .config .palette then
36+ if vim .o .background ~= style_background [theme ] then theme = invert_style [theme ] end
37+ else
38+ vim .o .background = style_background [theme ]
2739 end
2840 M .config .palette = theme
29- util .reload (M .config , theme )
41+ util .reload (M .config )
3042
3143 local colors = util .set_palettes (M .config )
3244
Original file line number Diff line number Diff line change @@ -10,12 +10,11 @@ local M = {}
1010
1111--- Reload a given theme
1212--- @param opts AstroThemeOpts
13- --- @param theme string
14- function M .reload (opts , theme )
13+ function M .reload (opts )
1514 if vim .g .colors_name then vim .cmd .highlight " clear" end
1615 if vim .fn .exists " syntax_on" then vim .cmd .syntax " reset" end
1716 vim .o .termguicolors = opts .termguicolors
18- vim .g .colors_name = theme
17+ vim .g .colors_name = opts . palette
1918end
2019
2120--- Reload a module
You can’t perform that action at this time.
0 commit comments