Skip to content

Commit dc67edc

Browse files
committed
Add variables to allow setting different light/dark colorschemes
Previously this already was accomplishable with the User callbacks LumenLight and LumenDark, but these variables serve as a shortcut for that.
1 parent 145a2fd commit dc67edc

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ au User LumenLight echom 'Entered light mode'
4848
au User LumenDark echom 'Entered dark mode'
4949
```
5050

51+
Note that for the common usecase of switching the colorscheme, there are the `g:lumen_light_colorscheme` and `g:lumen_dark_colorscheme` variables.
52+
5153
## What are some good light colorschemes?
5254

5355
There are not many colorschemes that work well both in light and dark mode.

autoload/lumen.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@ func lumen#init()
2020
augroup END
2121
endfunc
2222

23+
func lumen#apply_colorscheme(mode)
24+
" apply colorscheme from g:lumen_light_colorscheme/g:lumen_dark_colorscheme
25+
let v = get(g:, printf("lumen_%s_colorscheme", a:mode), '')
26+
if len(v) && get(g:, 'colors_name', '') != v
27+
exe printf("colorscheme %s", v)
28+
endif
29+
endfunc
30+
2331
func lumen#light_hook()
32+
call lumen#apply_colorscheme('light')
33+
2434
if s:background == 'light' && &background == s:background
2535
return
2636
endif
@@ -33,6 +43,8 @@ func lumen#light_hook()
3343
endfunc
3444

3545
func lumen#dark_hook()
46+
call lumen#apply_colorscheme('dark')
47+
3648
if s:background == 'dark' && &background == s:background
3749
return
3850
endif

doc/lumen.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ CONFIGURATION *lumen-configure*
5454
will no longer influence vim's internal detection mechanism at
5555
startup.
5656

57+
g:lumen_light_colorscheme *g:lumen_light_colorscheme*
58+
This variable defines the colorscheme to change to (if any),
59+
when the system switches to light mode. For a more generic
60+
callback, consult |User_LumenLight|.
61+
For example `let g:lumen_light_colorscheme = 'retrobox'` is
62+
equivalent to `autocmd User LumenLight colorscheme retrobox`,
63+
also see |g:lumen_dark_colorscheme|.
64+
65+
g:lumen_dark_colorscheme *g:lumen_dark_colorscheme*
66+
This variable defines the colorscheme to change to (if any),
67+
when the system switches to dark mode. For a more generic
68+
callback, consult |User_LumenDark|.
69+
For example `let g:lumen_dark_colorscheme = 'retrobox'` is
70+
equivalent to `autocmd User LumenDark colorscheme retrobox`,
71+
also see |g:lumen_light_colorscheme|.
72+
5773
------------------------------------------------------------------------------
5874
AUTOCOMMANDS *lumen-autocommands*
5975

0 commit comments

Comments
 (0)