support for prefixing with a highlight group.

This commit is contained in:
Bailey Ling 2013-08-31 03:26:59 +00:00
parent d268744077
commit 500ecf7cd0
2 changed files with 17 additions and 2 deletions

View File

@ -3,17 +3,23 @@
function! s:get_val(key, append)
let part = airline#parts#get(a:key)
let val = ''
if exists('part.highlight')
let val .= '%#'.(part.highlight).'#'
endif
if exists('part.function')
let func = (part.function).'()'
elseif exists('part.text')
let func = '"'.(part.text).'"'
elseif exists('part.raw')
return part.raw
return val.(part.raw)
else
return a:key
endif
let val = ''
if a:append > 0
let val .= '%{airline#util#append('.func.')}'
elseif a:append < 0

View File

@ -8,6 +8,10 @@ describe 'section'
call airline#parts#define_text('text', 'text')
call airline#parts#define_raw('raw', 'raw')
call airline#parts#define_function('func', 'SectionSpec')
call airline#parts#define('hi', {
\ 'raw': 'hello',
\ 'highlight': 'hlgroup',
\ })
end
it 'should create sections with no separators'
@ -24,5 +28,10 @@ describe 'section'
let s = airline#section#create_right(['text', 'text'])
Expect s == '%{airline#util#prepend("text")}%{"text"}'
end
it 'should prefix with highlight group if provided'
let s = airline#section#create(['hi'])
Expect s == '%#hlgroup#hello'
end
end