populate all modes with accent colors.
This commit is contained in:
parent
0a6b833e7c
commit
6442f01912
|
@ -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
|
||||
|
|
|
@ -94,6 +94,23 @@ function! airline#highlighter#add_separator(from, to, inverse)
|
|||
call <sid>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')
|
||||
|
|
|
@ -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'])
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
let g:airline_theme = 'dark'
|
||||
call airline#init#bootstrap()
|
||||
|
||||
describe 'active builder'
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
let g:airline_theme = 'dark'
|
||||
call airline#init#bootstrap()
|
||||
call airline#init#sections()
|
||||
source plugin/airline.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'
|
||||
|
|
Loading…
Reference in New Issue