mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-13 14:59:10 +08:00
Fix random theme functionality of the [colorscheme] layer (#4204)
* Fix random theme functionality of the [colorscheme] layer * Remove debuggging message Co-authored-by: Xudong WANG <xudongw@cse.unsw.edu.au>
This commit is contained in:
parent
e780e67112
commit
d13cf32d4f
@ -87,16 +87,16 @@ function! SpaceVim#layers#colorscheme#config() abort
|
||||
if s:random_colorscheme
|
||||
let ctime = ''
|
||||
" Use local file's save time, the local file is
|
||||
" ~/.cache/SpaceVim/colorscheme_frequence.json
|
||||
" {"fequecnce" : "dalily", "last" : 000000, 'theme' : 'one'}
|
||||
" ~/.cache/SpaceVim/colorscheme_frequency.json
|
||||
" {"frequency" : "dalily", "last" : 000000, 'theme' : 'one'}
|
||||
" FIXME: when global config cache is updated, check the cache also should
|
||||
" be updated
|
||||
if filereadable(expand(g:spacevim_data_dir.'/SpaceVim/colorscheme_frequence.json'))
|
||||
let conf = s:JSON.json_decode(join(readfile(expand(g:spacevim_data_dir.'/SpaceVim/colorscheme_frequence.json'), ''), ''))
|
||||
if filereadable(expand(g:spacevim_data_dir.'/SpaceVim/colorscheme_frequency.json'))
|
||||
let conf = s:JSON.json_decode(join(readfile(expand(g:spacevim_data_dir.'/SpaceVim/colorscheme_frequency.json'), ''), ''))
|
||||
if s:random_frequency !=# '' && !empty(conf)
|
||||
let ctime = localtime()
|
||||
if index(s:random_candidates, get(conf, 'theme', '')) == -1 ||
|
||||
\ ctime - get(conf, 'last', 0) >= get(s:time, get(conf, 'fequecnce', ''), 0)
|
||||
\ ctime - get(conf, 'last', 0) >= get(s:time, get(conf, 'frequency', ''), 0)
|
||||
let id = s:NUMBER.random(0, len(s:random_candidates))
|
||||
let g:spacevim_colorscheme = s:random_candidates[id]
|
||||
call s:update_conf()
|
||||
@ -120,11 +120,11 @@ endfunction
|
||||
|
||||
function! s:update_conf() abort
|
||||
let conf = {
|
||||
\ 'fequecnce' : s:random_frequency,
|
||||
\ 'frequency' : s:random_frequency,
|
||||
\ 'last' : localtime(),
|
||||
\ 'theme' : g:spacevim_colorscheme
|
||||
\ }
|
||||
call writefile([s:JSON.json_encode(conf)], expand(g:spacevim_data_dir.'/SpaceVim/colorscheme_frequence.json'))
|
||||
call writefile([s:JSON.json_encode(conf)], expand(g:spacevim_data_dir.'/SpaceVim/colorscheme_frequency.json'))
|
||||
endfunction
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user