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

View File

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