diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index bba239e8..5f1d8e4a 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -23,7 +23,11 @@ function! s:prototype.add_section(group, contents) let self._line .= '%#'.a:group.'#' endif + let accent = matchstr(a:contents, 'airline_accent_\zs[^#]*\ze') let contents = substitute(a:contents, 'airline_accent', a:group, 'g') + if contents != a:contents + call airline#highlighter#add_accent(a:group, accent) + endif let self._line .= contents let self._curgroup = a:group endfunction diff --git a/autoload/airline/highlighter.vim b/autoload/airline/highlighter.vim index 38e05c4a..b60182c2 100644 --- a/autoload/airline/highlighter.vim +++ b/autoload/airline/highlighter.vim @@ -94,6 +94,23 @@ function! airline#highlighter#add_separator(from, to, inverse) call exec_separator({}, a:from, a:to, a:inverse, '') endfunction +function! airline#highlighter#add_accent(group, accent) + let p = g:airline#themes#{g:airline_theme}#palette + if exists('p.accents') + if has_key(p.accents, a:accent) + for kvp in items(p) + let mode_colors = kvp[1] + if has_key(mode_colors, a:group) + let colors = copy(mode_colors[a:group]) + let colors[0] = p.accents[a:accent][0] + let colors[2] = p.accents[a:accent][2] + let mode_colors[a:group.'_'.a:accent] = colors + endif + endfor + endif + endif +endfunction + function! airline#highlighter#highlight_modified_inactive(bufnr) if getbufvar(a:bufnr, '&modified') let colors = exists('g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c') diff --git a/autoload/airline/init.vim b/autoload/airline/init.vim index ffe5d572..c245f032 100644 --- a/autoload/airline/init.vim +++ b/autoload/airline/init.vim @@ -79,10 +79,10 @@ function! airline#init#sections() let g:airline_section_b = airline#section#create(['hunks', 'branch']) endif if !exists('g:airline_section_c') - let g:airline_section_c = airline#section#create(['%<', 'file']) + let g:airline_section_c = airline#section#create(['%<', 'file', ' ', 'readonly']) endif if !exists('g:airline_section_gutter') - let g:airline_section_gutter = airline#section#create([' ', 'readonly', '%=']) + let g:airline_section_gutter = airline#section#create(['%=']) endif if !exists('g:airline_section_x') let g:airline_section_x = airline#section#create_right(['tagbar', 'filetype']) diff --git a/autoload/airline/themes.vim b/autoload/airline/themes.vim index 879d8c01..7d1f7183 100644 --- a/autoload/airline/themes.vim +++ b/autoload/airline/themes.vim @@ -40,26 +40,5 @@ function! airline#themes#patch(palette) let a:palette[mode]['airline_warning'] = [ '#000000', '#df5f00', 232, 166 ] endif endfor - - " this is a pretty heavy handed, but it works... - " basically, look for the 'airline_file' group and copy the bg - " colors from 'airline_c' into it. - for mode in keys(a:palette) - let overrides = split(mode, '_') - let mode_colors = a:palette[overrides[0]] - if exists('mode_colors.airline_file') - let file_colors = mode_colors.airline_file - let file_colors[1] = mode_colors.airline_c[1] - let file_colors[3] = mode_colors.airline_c[3] - - if len(overrides) > 1 - let override_colors = a:palette[overrides[0].'_'.overrides[1]] - let override_colors.airline_file = copy(file_colors) - let override_status_colors = get(override_colors, 'airline_c', mode_colors.airline_c) - let override_colors.airline_file[1] = override_status_colors[1] - let override_colors.airline_file[3] = override_status_colors[3] - endif - endif - endfor endfunction diff --git a/t/builder.vim b/t/builder.vim index ca38a793..705abfb8 100644 --- a/t/builder.vim +++ b/t/builder.vim @@ -1,3 +1,4 @@ +let g:airline_theme = 'dark' call airline#init#bootstrap() describe 'active builder' diff --git a/t/extensions_default.vim b/t/extensions_default.vim index 475884a1..b98e8166 100644 --- a/t/extensions_default.vim +++ b/t/extensions_default.vim @@ -1,3 +1,4 @@ +let g:airline_theme = 'dark' call airline#init#bootstrap() call airline#init#sections() source plugin/airline.vim diff --git a/t/init.vim b/t/init.vim index e937de0a..a20bc334 100644 --- a/t/init.vim +++ b/t/init.vim @@ -28,7 +28,7 @@ describe 'init' end it 'section c should be file' - Expect g:airline_section_c == '%<%f%m' + Expect g:airline_section_c == '%<%f%m %#airline_accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}' end it 'section x should be filetype'