mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-02-08 13:00:44 +08:00
Merge branch 'dev'
This commit is contained in:
commit
5dcd1e942c
|
@ -43,6 +43,9 @@ function! airline#switch_theme(name)
|
||||||
let w:airline_lastmode = ''
|
let w:airline_lastmode = ''
|
||||||
call airline#update_statusline()
|
call airline#update_statusline()
|
||||||
call airline#load_theme()
|
call airline#load_theme()
|
||||||
|
|
||||||
|
" this is required to prevent clobbering the startup info message, i don't know why...
|
||||||
|
call airline#check_mode(winnr())
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#switch_matching_theme()
|
function! airline#switch_matching_theme()
|
||||||
|
|
|
@ -62,7 +62,10 @@ function! airline#init#bootstrap()
|
||||||
\ 'space': ' ',
|
\ 'space': ' ',
|
||||||
\ }, 'keep')
|
\ }, 'keep')
|
||||||
|
|
||||||
call airline#parts#define_function('mode', 'airline#parts#mode')
|
call airline#parts#define('mode', {
|
||||||
|
\ 'function': 'airline#parts#mode',
|
||||||
|
\ 'accent': 'bold',
|
||||||
|
\ })
|
||||||
call airline#parts#define_function('iminsert', 'airline#parts#iminsert')
|
call airline#parts#define_function('iminsert', 'airline#parts#iminsert')
|
||||||
call airline#parts#define_function('paste', 'airline#parts#paste')
|
call airline#parts#define_function('paste', 'airline#parts#paste')
|
||||||
call airline#parts#define_function('filetype', 'airline#parts#filetype')
|
call airline#parts#define_function('filetype', 'airline#parts#filetype')
|
||||||
|
|
|
@ -4,15 +4,18 @@
|
||||||
call airline#init#bootstrap()
|
call airline#init#bootstrap()
|
||||||
let s:spc = g:airline_symbols.space
|
let s:spc = g:airline_symbols.space
|
||||||
|
|
||||||
|
function! s:wrap_accent(part, value)
|
||||||
|
if exists('a:part.accent')
|
||||||
|
return '%#__accent_'.(a:part.accent).'#'.a:value.'%#__restore__#'
|
||||||
|
endif
|
||||||
|
return a:value
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:create(parts, append)
|
function! s:create(parts, append)
|
||||||
let _ = ''
|
let _ = ''
|
||||||
for idx in range(len(a:parts))
|
for idx in range(len(a:parts))
|
||||||
let part = airline#parts#get(a:parts[idx])
|
let part = airline#parts#get(a:parts[idx])
|
||||||
|
|
||||||
let val = ''
|
let val = ''
|
||||||
if exists('part.accent')
|
|
||||||
let val .= '%#__accent_'.(part.accent).'#'
|
|
||||||
endif
|
|
||||||
|
|
||||||
if exists('part.function')
|
if exists('part.function')
|
||||||
let func = (part.function).'()'
|
let func = (part.function).'()'
|
||||||
|
@ -26,10 +29,10 @@ function! s:create(parts, append)
|
||||||
let val = s:spc.g:airline_right_alt_sep.s:spc.val
|
let val = s:spc.g:airline_right_alt_sep.s:spc.val
|
||||||
endif
|
endif
|
||||||
if exists('part.raw')
|
if exists('part.raw')
|
||||||
let _ .= val.(part.raw)
|
let _ .= s:wrap_accent(part, val.(part.raw))
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
let _ .= val.a:parts[idx]
|
let _ .= s:wrap_accent(part, val.a:parts[idx])
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
@ -49,10 +52,7 @@ function! s:create(parts, append)
|
||||||
let partval = substitute(partval, '}', ' : ""}', '')
|
let partval = substitute(partval, '}', ' : ""}', '')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let val .= partval
|
let val .= s:wrap_accent(part, partval)
|
||||||
if exists('part.accent')
|
|
||||||
let val .= '%#__restore__#'
|
|
||||||
endif
|
|
||||||
let _ .= val
|
let _ .= val
|
||||||
endfor
|
endfor
|
||||||
return _
|
return _
|
||||||
|
|
|
@ -17,9 +17,9 @@ function! airline#themes#generate_color_map(sect1, sect2, sect3, ...)
|
||||||
\ })
|
\ })
|
||||||
else
|
else
|
||||||
call extend(palette, {
|
call extend(palette, {
|
||||||
\ 'airline_x': [ a:sect3[0] , a:sect3[1] , a:sect3[2] , a:sect3[3] , get(a:sect3 , 4 , '' ) ] ,
|
\ 'airline_x': [ a:sect3[0] , a:sect3[1] , a:sect3[2] , a:sect3[3] , '' ] ,
|
||||||
\ 'airline_y': [ a:sect2[0] , a:sect2[1] , a:sect2[2] , a:sect2[3] , get(a:sect2 , 4 , '' ) ] ,
|
\ 'airline_y': [ a:sect2[0] , a:sect2[1] , a:sect2[2] , a:sect2[3] , '' ] ,
|
||||||
\ 'airline_z': [ a:sect1[0] , a:sect1[1] , a:sect1[2] , a:sect1[3] , get(a:sect1 , 4 , '' ) ] ,
|
\ 'airline_z': [ a:sect1[0] , a:sect1[1] , a:sect1[2] , a:sect1[3] , '' ] ,
|
||||||
\ })
|
\ })
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ describe 'airline'
|
||||||
it 'should allow users to redefine sections'
|
it 'should allow users to redefine sections'
|
||||||
let g:airline_section_a = airline#section#create(['mode', 'mode'])
|
let g:airline_section_a = airline#section#create(['mode', 'mode'])
|
||||||
call airline#update_statusline()
|
call airline#update_statusline()
|
||||||
Expect airline#statusline(1) =~ '%{airline#util#wrap(airline#parts#mode(),0)}%{airline#util#wrap(airline#parts#mode(),0)}'
|
Expect airline#statusline(1) =~ '%{airline#util#wrap(airline#parts#mode(),0)}%#airline_a#%#airline_a_bold#%{airline#util#wrap(airline#parts#mode(),0)}%#airline_a#'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should remove funcrefs properly'
|
it 'should remove funcrefs properly'
|
||||||
|
|
|
@ -26,13 +26,20 @@ describe 'section'
|
||||||
Expect s == '%{airline#util#prepend("text",0)}%{airline#util#wrap("text",0)}'
|
Expect s == '%{airline#util#prepend("text",0)}%{airline#util#wrap("text",0)}'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should prefix with accent group if provided'
|
it 'should prefix with accent group if provided and restore afterwards'
|
||||||
call airline#parts#define('hi', {
|
call airline#parts#define('hi', {
|
||||||
\ 'raw': 'hello',
|
\ 'raw': 'hello',
|
||||||
\ 'accent': 'red',
|
\ 'accent': 'red',
|
||||||
\ })
|
\ })
|
||||||
let s = airline#section#create(['hi'])
|
let s = airline#section#create(['hi'])
|
||||||
Expect s == '%#__accent_red#hello'
|
Expect s == '%#__accent_red#hello%#__restore__#'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should accent functions'
|
||||||
|
call airline#parts#define_function('hi', 'Hello')
|
||||||
|
call airline#parts#define_accent('hi', 'bold')
|
||||||
|
let s = airline#section#create(['hi'])
|
||||||
|
Expect s == '%#__accent_bold#%{airline#util#wrap(Hello(),0)}%#__restore__#'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should parse out a section from the distro'
|
it 'should parse out a section from the distro'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user