diff --git a/autoload/airline/section.vim b/autoload/airline/section.vim index d14a828..3df4bbe 100644 --- a/autoload/airline/section.vim +++ b/autoload/airline/section.vim @@ -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 diff --git a/t/section.vim b/t/section.vim index 0a16105..433dc0a 100644 --- a/t/section.vim +++ b/t/section.vim @@ -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