From 02aa620a924eb251317368ad90f758a3b7eae6e3 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sun, 15 Sep 2013 22:47:13 -0400 Subject: [PATCH] correctly inject the accent highlight groups. --- autoload/airline/builder.vim | 3 ++- autoload/airline/section.vim | 4 ++-- t/builder.vim | 6 ++++++ t/section.vim | 6 +++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index 4048d72..bba239e 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -23,7 +23,8 @@ function! s:prototype.add_section(group, contents) let self._line .= '%#'.a:group.'#' endif - let self._line .= a:contents + let contents = substitute(a:contents, 'airline_accent', a:group, 'g') + let self._line .= contents let self._curgroup = a:group endfunction diff --git a/autoload/airline/section.vim b/autoload/airline/section.vim index 516d000..e56b09a 100644 --- a/autoload/airline/section.vim +++ b/autoload/airline/section.vim @@ -9,8 +9,8 @@ function! s:create(parts, append) let part = airline#parts#get(a:parts[idx]) let val = '' - if exists('part.highlight') - let val .= '%#'.(part.highlight).'#' + if exists('part.accent') + let val .= '%#airline_accent_'.(part.accent).'#' endif if exists('part.function') diff --git a/t/builder.vim b/t/builder.vim index 2ba9981..ca38a79 100644 --- a/t/builder.vim +++ b/t/builder.vim @@ -37,6 +37,12 @@ describe 'active builder' let stl = s:builder.build() Expect stl == '%#Normal#hello>hello' end + + it 'should replace accent groups with the specified group' + call s:builder.add_section('Normal', '%#airline_accent_foo#hello') + let stl = s:builder.build() + Expect stl == '%#Normal#%#Normal_foo#hello' + end end describe 'inactive builder' diff --git a/t/section.vim b/t/section.vim index de9f208..8d3a4fc 100644 --- a/t/section.vim +++ b/t/section.vim @@ -26,13 +26,13 @@ describe 'section' Expect s == '%{airline#util#prepend("text",0)}%{airline#util#wrap("text",0)}' end - it 'should prefix with highlight group if provided' + it 'should prefix with accent group if provided' call airline#parts#define('hi', { \ 'raw': 'hello', - \ 'highlight': 'hlgroup', + \ 'accent': 'red', \ }) let s = airline#section#create(['hi']) - Expect s == '%#hlgroup#hello' + Expect s == '%#airline_accent_red#hello' end it 'should parse out a section from the distro'