allow warning section to collapse away
This commit is contained in:
parent
8b92cae46c
commit
703045a7e6
@ -26,8 +26,12 @@ function! s:create_builder(active)
|
|||||||
call add(self._sections, [a:group, a:contents])
|
call add(self._sections, [a:group, a:contents])
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! builder.add_raw(text)
|
||||||
|
call add(self._sections, ['_', a:text])
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! builder._group(group)
|
function! builder._group(group)
|
||||||
return self._active ? a:group : a:group.'_inactive'
|
return '%#' . (self._active ? a:group : a:group.'_inactive') . '#'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! builder.build()
|
function! builder.build()
|
||||||
@ -37,21 +41,25 @@ function! s:create_builder(active)
|
|||||||
for section in self._sections
|
for section in self._sections
|
||||||
if section[0] == '|'
|
if section[0] == '|'
|
||||||
let side = 1
|
let side = 1
|
||||||
|
let line .= '%#'.prev_group.'#'.section[1]
|
||||||
|
let prev_group = ''
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
if section[0] == '_'
|
||||||
let line .= section[1]
|
let line .= section[1]
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if prev_group != ''
|
if prev_group != ''
|
||||||
let sep_group = side == 0
|
let line .= side == 0
|
||||||
\ ? airline#themes#exec_highlight_separator(section[0], prev_group)
|
\ ? self._group(airline#themes#exec_highlight_separator(section[0], prev_group))
|
||||||
\ : airline#themes#exec_highlight_separator(prev_group, section[0])
|
\ : self._group(airline#themes#exec_highlight_separator(prev_group, section[0]))
|
||||||
let line .= '%#'.self._group(sep_group).'#'
|
|
||||||
let line .= side == 0
|
let line .= side == 0
|
||||||
\ ? self._active ? g:airline_left_sep : g:airline_left_alt_sep
|
\ ? self._active ? g:airline_left_sep : g:airline_left_alt_sep
|
||||||
\ : self._active ? g:airline_right_sep : g:airline_right_alt_sep
|
\ : self._active ? g:airline_right_sep : g:airline_right_alt_sep
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let line .= '%#'.self._group(section[0]).'#'.section[1]
|
let line .= self._group(section[0]).section[1]
|
||||||
let prev_group = section[0]
|
let prev_group = section[0]
|
||||||
endfor
|
endfor
|
||||||
return line
|
return line
|
||||||
@ -121,8 +129,7 @@ function! airline#get_statusline(winnr, active)
|
|||||||
let builder = s:create_builder(a:active)
|
let builder = s:create_builder(a:active)
|
||||||
|
|
||||||
if s:getwinvar(a:winnr, 'airline_render_left', a:active || (!a:active && !g:airline_inactive_collapse))
|
if s:getwinvar(a:winnr, 'airline_render_left', a:active || (!a:active && !g:airline_inactive_collapse))
|
||||||
call builder.add_section('Al2', s:get_section(a:winnr, 'a'))
|
call builder.add_section('Al2', s:get_section(a:winnr, 'a').'%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}')
|
||||||
call builder.add_section('Al7', '%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}')
|
|
||||||
call builder.add_section('Al4', s:get_section(a:winnr, 'b'))
|
call builder.add_section('Al4', s:get_section(a:winnr, 'b'))
|
||||||
call builder.add_section('Al6', s:get_section(a:winnr, 'c').' %#Al7#%{&ro ? g:airline_readonly_symbol : ""}')
|
call builder.add_section('Al6', s:get_section(a:winnr, 'c').' %#Al7#%{&ro ? g:airline_readonly_symbol : ""}')
|
||||||
else
|
else
|
||||||
@ -134,7 +141,9 @@ function! airline#get_statusline(winnr, active)
|
|||||||
call builder.add_section('Al4', s:get_section(a:winnr, 'y'))
|
call builder.add_section('Al4', s:get_section(a:winnr, 'y'))
|
||||||
call builder.add_section('Al2', s:get_section(a:winnr, 'z'))
|
call builder.add_section('Al2', s:get_section(a:winnr, 'z'))
|
||||||
if a:active
|
if a:active
|
||||||
|
call builder.add_raw('%(')
|
||||||
call builder.add_section('warningmsg', s:get_section(a:winnr, 'warning', '', ''))
|
call builder.add_section('warningmsg', s:get_section(a:winnr, 'warning', '', ''))
|
||||||
|
call builder.add_raw('%)')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
return builder.build()
|
return builder.build()
|
||||||
|
@ -57,6 +57,9 @@ function! airline#themes#get_highlight2(fg, bg, ...)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#themes#exec_highlight_separator(from, to)
|
function! airline#themes#exec_highlight_separator(from, to)
|
||||||
|
if a:from == a:to
|
||||||
|
return a:from
|
||||||
|
endif
|
||||||
let l:from = airline#themes#get_highlight(a:from)
|
let l:from = airline#themes#get_highlight(a:from)
|
||||||
let l:to = airline#themes#get_highlight(a:to)
|
let l:to = airline#themes#get_highlight(a:to)
|
||||||
let group = a:from.'_to_'.a:to
|
let group = a:from.'_to_'.a:to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user