mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-24 03:00:06 +08:00
Fix statusline can't response to custom config (#4328)
Co-authored-by: xushaodong <xushaodong@bytedance.com>
This commit is contained in:
parent
d5020d8195
commit
3f3a4912df
@ -98,12 +98,6 @@ let s:modes = {
|
|||||||
\ },
|
\ },
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
" TODO This can not be deleted, it is used for toggle section
|
|
||||||
let s:loaded_sections = ['syntax checking', 'major mode', 'minor mode lighters', 'version control info', 'cursorpos']
|
|
||||||
|
|
||||||
let s:loaded_sections_r = g:spacevim_statusline_right_sections
|
|
||||||
let s:loaded_sections_l = g:spacevim_statusline_left_sections
|
|
||||||
|
|
||||||
if SpaceVim#layers#isLoaded('checkers')
|
if SpaceVim#layers#isLoaded('checkers')
|
||||||
call add(s:loaded_modes, 'syntax-checking')
|
call add(s:loaded_modes, 'syntax-checking')
|
||||||
endif
|
endif
|
||||||
@ -113,7 +107,7 @@ endif
|
|||||||
if &cc ==# '80'
|
if &cc ==# '80'
|
||||||
call add(s:loaded_modes, 'fill-column-indicator')
|
call add(s:loaded_modes, 'fill-column-indicator')
|
||||||
endif
|
endif
|
||||||
if index(s:loaded_sections_r, 'whitespace') != -1
|
if index(g:spacevim_statusline_right_sections, 'whitespace') != -1
|
||||||
call add(s:loaded_modes, 'whitespace')
|
call add(s:loaded_modes, 'whitespace')
|
||||||
endif
|
endif
|
||||||
" build in sections for SpaceVim statusline
|
" build in sections for SpaceVim statusline
|
||||||
@ -583,13 +577,13 @@ endfunction
|
|||||||
|
|
||||||
function! s:active() abort
|
function! s:active() abort
|
||||||
let lsec = []
|
let lsec = []
|
||||||
for section in s:loaded_sections_l
|
for section in g:spacevim_statusline_left_sections
|
||||||
if has_key(s:registed_sections, section)
|
if has_key(s:registed_sections, section)
|
||||||
call add(lsec, call(s:registed_sections[section], []))
|
call add(lsec, call(s:registed_sections[section], []))
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
let rsec = []
|
let rsec = []
|
||||||
for section in s:loaded_sections_r
|
for section in g:spacevim_statusline_right_sections
|
||||||
if has_key(s:registed_sections, section)
|
if has_key(s:registed_sections, section)
|
||||||
call add(rsec, call(s:registed_sections[section], []))
|
call add(rsec, call(s:registed_sections[section], []))
|
||||||
endif
|
endif
|
||||||
@ -709,25 +703,25 @@ let s:section_old_pos = {
|
|||||||
\ }
|
\ }
|
||||||
|
|
||||||
function! SpaceVim#layers#core#statusline#toggle_section(name) abort
|
function! SpaceVim#layers#core#statusline#toggle_section(name) abort
|
||||||
if index(s:loaded_sections_l, a:name) == -1
|
if index(g:spacevim_statusline_left_sections, a:name) == -1
|
||||||
\ && index(s:loaded_sections_r, a:name) == -1
|
\ && index(g:spacevim_statusline_right_sections, a:name) == -1
|
||||||
\ && !has_key(s:section_old_pos, a:name)
|
\ && !has_key(s:section_old_pos, a:name)
|
||||||
if a:name ==# 'search status'
|
if a:name ==# 'search status'
|
||||||
call insert(s:loaded_sections_l, a:name, 2)
|
call insert(g:spacevim_statusline_left_sections, a:name, 2)
|
||||||
else
|
else
|
||||||
call add(s:loaded_sections_r, a:name)
|
call add(g:spacevim_statusline_right_sections, a:name)
|
||||||
endif
|
endif
|
||||||
elseif index(s:loaded_sections_r, a:name) != -1
|
elseif index(g:spacevim_statusline_right_sections, a:name) != -1
|
||||||
let s:section_old_pos[a:name] = ['r', index(s:loaded_sections_r, a:name)]
|
let s:section_old_pos[a:name] = ['r', index(g:spacevim_statusline_right_sections, a:name)]
|
||||||
call remove(s:loaded_sections_r, index(s:loaded_sections_r, a:name))
|
call remove(g:spacevim_statusline_right_sections, index(g:spacevim_statusline_right_sections, a:name))
|
||||||
elseif index(s:loaded_sections_l, a:name) != -1
|
elseif index(g:spacevim_statusline_left_sections, a:name) != -1
|
||||||
let s:section_old_pos[a:name] = ['l', index(s:loaded_sections_l, a:name)]
|
let s:section_old_pos[a:name] = ['l', index(g:spacevim_statusline_left_sections, a:name)]
|
||||||
call remove(s:loaded_sections_l, index(s:loaded_sections_l, a:name))
|
call remove(g:spacevim_statusline_left_sections, index(g:spacevim_statusline_left_sections, a:name))
|
||||||
elseif has_key(s:section_old_pos, a:name)
|
elseif has_key(s:section_old_pos, a:name)
|
||||||
if s:section_old_pos[a:name][0] ==# 'r'
|
if s:section_old_pos[a:name][0] ==# 'r'
|
||||||
call insert(s:loaded_sections_r, a:name, s:section_old_pos[a:name][1])
|
call insert(g:spacevim_statusline_right_sections, a:name, s:section_old_pos[a:name][1])
|
||||||
else
|
else
|
||||||
call insert(s:loaded_sections_l, a:name, s:section_old_pos[a:name][1])
|
call insert(g:spacevim_statusline_left_sections, a:name, s:section_old_pos[a:name][1])
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
let &l:statusline = SpaceVim#layers#core#statusline#get(1)
|
let &l:statusline = SpaceVim#layers#core#statusline#get(1)
|
||||||
@ -956,16 +950,16 @@ function! SpaceVim#layers#core#statusline#register_sections(name, func) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SpaceVim#layers#core#statusline#check_section(name) abort
|
function! SpaceVim#layers#core#statusline#check_section(name) abort
|
||||||
return (index(s:loaded_sections_l, a:name) != -1
|
return (index(g:spacevim_statusline_left_sections, a:name) != -1
|
||||||
\ || index(s:loaded_sections_r, a:name) != -1)
|
\ || index(g:spacevim_statusline_right_sections, a:name) != -1)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SpaceVim#layers#core#statusline#remove_section(name) abort
|
function! SpaceVim#layers#core#statusline#remove_section(name) abort
|
||||||
if index(s:loaded_sections_l, a:name) != -1
|
if index(g:spacevim_statusline_left_sections, a:name) != -1
|
||||||
call remove(s:loaded_sections_l, index(s:loaded_sections_l, a:name))
|
call remove(g:spacevim_statusline_left_sections, index(g:spacevim_statusline_left_sections, a:name))
|
||||||
endif
|
endif
|
||||||
if index(s:loaded_sections_r, a:name) != -1
|
if index(g:spacevim_statusline_right_sections, a:name) != -1
|
||||||
call remove(s:loaded_sections_r, index(s:loaded_sections_l, a:name))
|
call remove(g:spacevim_statusline_right_sections, index(g:spacevim_statusline_left_sections, a:name))
|
||||||
endif
|
endif
|
||||||
let &l:statusline = SpaceVim#layers#core#statusline#get(1)
|
let &l:statusline = SpaceVim#layers#core#statusline#get(1)
|
||||||
endfunction
|
endfunction
|
||||||
|
Loading…
Reference in New Issue
Block a user