diff --git a/README.md b/README.md index fc21bb7..c1b3ab6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Lean & mean statusline for vim that's light as air. # Features -* tiny core (under 200 lines), written with extensibility in mind ([open/closed principle][8]). +* tiny core written with extensibility in mind ([open/closed principle][8]). * integrates with a variety of plugins, including: [vim-bufferline][6], [fugitive][4], [unite][9], [ctrlp][10], [minibufexpl][15], [gundo][16], [undotree][17], [nerdtree][18], [tagbar][19], [syntastic][5] and [lawrencium][21]. * looks good with regular fonts and provides configuration points so you can use unicode or powerline symbols. * optimized for speed; it loads in under a millisecond. diff --git a/autoload/airline.vim b/autoload/airline.vim index b8c074a..777b2d7 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -1,136 +1,60 @@ -" MIT license. Copyright (c) 2013 Bailey Ling. -" vim: ts=2 sts=2 sw=2 fdm=indent +" MIT License. Copyright (c) 2013 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 -let s:is_win32term = (has('win32') || has('win64')) && !has('gui_running') let s:sections = ['a','b','c','gutter','x','y','z','warning'] +let s:highlighter = airline#highlighter#new() -let s:airline_highlight_map = { - \ 'mode' : 'Al2', - \ 'mode_separator' : 'Al3', - \ 'info' : 'Al4', - \ 'info_separator' : 'Al5', - \ 'statusline' : 'Al6', - \ 'file' : 'Al7', - \ } - -function! airline#exec_highlight(group, colors) - let colors = a:colors - if s:is_win32term - let colors = map(a:colors, 'v:val != "" && v:val > 128 ? v:val - 128 : v:val') - endif - exec printf('hi %s %s %s %s %s %s %s %s', - \ a:group, - \ colors[0] != '' ? 'guifg='.colors[0] : '', - \ colors[1] != '' ? 'guibg='.colors[1] : '', - \ colors[2] != '' ? 'ctermfg='.colors[2] : '', - \ colors[3] != '' ? 'ctermbg='.colors[3] : '', - \ len(colors) > 4 && colors[4] != '' ? 'gui='.colors[4] : '', - \ len(colors) > 4 && colors[4] != '' ? 'cterm='.colors[4] : '', - \ len(colors) > 4 && colors[4] != '' ? 'term='.colors[4] : '') -endfunction - -function! airline#reload_highlight() - call airline#highlight(['inactive']) - call airline#highlight(['normal']) +function! airline#load_theme() + call s:highlighter.load_theme() call airline#extensions#load_theme() endfunction -function! airline#load_theme(name) +function! airline#switch_theme(name) let g:airline_theme = a:name let inactive_colors = g:airline#themes#{g:airline_theme}#inactive "also lazy loads the theme let w:airline_lastmode = '' - call airline#reload_highlight() - call airline#update_highlight() -endfunction - -function! airline#highlight(modes) - " draw the base mode, followed by any overrides - let mapped = map(a:modes, 'v:val == a:modes[0] ? v:val : a:modes[0]."_".v:val') - for mode in mapped - if exists('g:airline#themes#{g:airline_theme}#{mode}') - for key in keys(g:airline#themes#{g:airline_theme}#{mode}) - let colors = g:airline#themes#{g:airline_theme}#{mode}[key] - let suffix = a:modes[0] == 'inactive' ? '_inactive' : '' - call airline#exec_highlight(s:airline_highlight_map[key].suffix, colors) - endfor - endif - endfor - call airline#themes#exec_highlight_separator('Al2', 'warningmsg') -endfunction - -" for 7.2 compatibility -function! s:getwinvar(winnr, key, ...) - let winvals = getwinvar(a:winnr, '') - return get(winvals, a:key, (a:0 ? a:1 : '')) + call airline#update_statusline() + call airline#load_theme() + call airline#check_mode() endfunction function! s:get_section(winnr, key, ...) - let text = s:getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key}) + let text = airline#util#getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key}) let [prefix, suffix] = [get(a:000, 0, '%( '), get(a:000, 1, ' %)')] return empty(text) ? '' : prefix.text.suffix endfunction function! airline#get_statusline(winnr, active) - let l:mode_color = a:active ? "%#Al2#" : "%#Al2_inactive#" - let l:mode_sep_color = a:active ? "%#Al3#" : "%#Al3_inactive#" - let l:info_color = a:active ? "%#Al4#" : "%#Al4_inactive#" - let l:info_sep_color = a:active ? "%#Al5#" : "%#Al5_inactive#" - let l:status_color = a:active ? "%#Al6#" : "%#Al6_inactive#" - let l:file_flag_color = a:active ? "%#Al7#" : "%#Al7_inactive#" + let builder = airline#builder#new(a:active, s:highlighter) - let sl = '%{airline#update_highlight()}' - if s:getwinvar(a:winnr, 'airline_render_left', a:active || (!a:active && !g:airline_inactive_collapse)) - let sl.=l:mode_color.s:get_section(a:winnr, 'a') - let sl.='%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}' - let sl.=l:mode_sep_color - let sl.=a:active ? g:airline_left_sep : g:airline_left_alt_sep - let sl.=l:info_color - let sl.=s:get_section(a:winnr, 'b') - let sl.=l:info_sep_color - let sl.=g:airline_left_sep - let sl.=l:status_color.'%<'.s:get_section(a:winnr, 'c') - let sl.=' '.l:file_flag_color."%(%{&ro ? g:airline_readonly_symbol : ''}%)" + if airline#util#getwinvar(a:winnr, 'airline_render_left', a:active || (!a:active && !g:airline_inactive_collapse)) + call builder.add_section('airline_a', s:get_section(a:winnr, 'a') + \ .'%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}') + call builder.add_section('airline_b', s:get_section(a:winnr, 'b')) + call builder.add_section('airline_c', '%<'.s:get_section(a:winnr, 'c') + \ .'%#airline_file#%{&ro ? g:airline_readonly_symbol : ""}') else - let sl.=l:status_color.' %f%m' + call builder.add_section('airline_c', '%f%m') endif - let sl.=l:status_color.s:get_section(a:winnr, 'gutter', '', '').l:status_color - if s:getwinvar(a:winnr, 'airline_render_right', 1) - let sl.=s:get_section(a:winnr, 'x') - let sl.=l:info_sep_color - let sl.=a:active ? g:airline_right_sep : g:airline_right_alt_sep - let sl.=l:info_color - let sl.=s:get_section(a:winnr, 'y') - let sl.=l:mode_sep_color - let sl.=a:active ? g:airline_right_sep : g:airline_right_alt_sep - let sl.=l:mode_color - let sl.=s:get_section(a:winnr, 'z') + call builder.split(s:get_section(a:winnr, 'gutter', '', '')) + + if airline#util#getwinvar(a:winnr, 'airline_render_right', 1) + call builder.add_section('airline_c', s:get_section(a:winnr, 'x')) + call builder.add_section('airline_b', s:get_section(a:winnr, 'y')) + call builder.add_section('airline_a', s:get_section(a:winnr, 'z')) if a:active - let sl.='%(%#Al2_to_warningmsg#'.g:airline_right_sep - let sl.='%#warningmsg#'.s:get_section(a:winnr, 'warning', '', '').'%)' + call builder.add_raw('%(') + call builder.add_section('warningmsg', s:get_section(a:winnr, 'warning', '', '')) + call builder.add_raw('%)') endif endif - return sl -endfunction -function! airline#exec_funcrefs(list, break_early) - " for 7.2; we cannot iterate list, hence why we use range() - " for 7.3-[97, 328]; we cannot reuse the variable, hence the {} - for i in range(0, len(a:list) - 1) - let Fn{i} = a:list[i] - if a:break_early - if Fn{i}() - return 1 - endif - else - call Fn{i}() - endif - endfor - return 0 + return builder.build() endfunction function! airline#update_statusline() - if airline#exec_funcrefs(g:airline_exclude_funcrefs, 1) + if airline#util#exec_funcrefs(g:airline_exclude_funcrefs, 1) call setwinvar(winnr(), '&statusline', '') return endif @@ -147,12 +71,12 @@ function! airline#update_statusline() for section in s:sections unlet! w:airline_section_{section} endfor - call airline#exec_funcrefs(g:airline_statusline_funcrefs, 0) + call airline#util#exec_funcrefs(g:airline_statusline_funcrefs, 0) call setwinvar(winnr(), '&statusline', airline#get_statusline(winnr(), 1)) endfunction -function! airline#update_highlight() +function! airline#check_mode() if get(w:, 'airline_active', 1) let l:m = mode() if l:m ==# "i" @@ -170,13 +94,18 @@ function! airline#update_highlight() let w:airline_current_mode = get(g:airline_mode_map, '__') endif - if g:airline_detect_modified && &modified | call add(l:mode, 'modified') | endif - if g:airline_detect_paste && &paste | call add(l:mode, 'paste') | endif + if g:airline_detect_modified && &modified + call add(l:mode, 'modified') + endif + if g:airline_detect_paste && &paste + call add(l:mode, 'paste') + endif let mode_string = join(l:mode) if get(w:, 'airline_lastmode', '') != mode_string - call airline#highlight(l:mode) + call s:highlighter.highlight(l:mode) let w:airline_lastmode = mode_string endif return '' endfunction + diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim new file mode 100644 index 0000000..0cba446 --- /dev/null +++ b/autoload/airline/builder.vim @@ -0,0 +1,62 @@ +" MIT license. Copyright (c) 2013 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +let s:prototype = {} + +function! s:prototype.split(gutter) + call add(self._sections, ['|', a:gutter]) +endfunction + +function! s:prototype.add_section(group, contents) + call add(self._sections, [a:group, a:contents]) +endfunction + +function! s:prototype.add_raw(text) + call add(self._sections, ['_', a:text]) +endfunction + +function! s:prototype._group(group) + return self._active ? a:group : a:group.'_inactive' +endfunction + +function! s:prototype.build() + let line = '%{airline#check_mode()}' + let side = 0 + let prev_group = '' + for section in self._sections + if section[0] == '|' + let side = 1 + let line .= '%#'.self._group(prev_group).'#'.section[1] + let prev_group = '' + continue + endif + if section[0] == '_' + let line .= section[1] + continue + endif + + if prev_group != '' + call self._highlighter.add_separator(self._group(prev_group), self._group(section[0])) + let line .= side == 0 + \ ? '%#'.self._group(section[0]).'_to_'.self._group(prev_group).'#' + \ : '%#'.self._group(prev_group).'_to_'.self._group(section[0]).'#' + let line .= side == 0 + \ ? self._active ? g:airline_left_sep : g:airline_left_alt_sep + \ : self._active ? g:airline_right_sep : g:airline_right_alt_sep + endif + + let line .= '%#'.self._group(section[0]).'#'.section[1] + let prev_group = section[0] + endfor + + return line +endfunction + +function! airline#builder#new(active, highlighter) + let builder = copy(s:prototype) + let builder._sections = [] + let builder._active = a:active + let builder._highlighter = a:highlighter + return builder +endfunction + diff --git a/autoload/airline/debug.vim b/autoload/airline/debug.vim new file mode 100644 index 0000000..a1d343f --- /dev/null +++ b/autoload/airline/debug.vim @@ -0,0 +1,15 @@ +" MIT License. Copyright (c) 2013 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +function! airline#debug#profile() + profile start airline-profile.log + profile func * + profile file * + split + for i in range(1, 1000) + wincmd w + redrawstatus + endfor + profile pause + noautocmd qall! +endfunction diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 3141dab..6846eb5 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -94,7 +94,7 @@ endfunction function! s:sync_active_winnr() if exists('#airline') && winnr() != s:active_winnr - if airline#exec_funcrefs(s:ext._cursormove_funcrefs, 1) + if airline#util#exec_funcrefs(s:ext._cursormove_funcrefs, 1) return endif call airline#update_statusline() @@ -158,6 +158,6 @@ function! airline#extensions#load() call airline#extensions#iminsert#init() endif - call airline#exec_funcrefs(g:airline_statusline_funcrefs, 0) + call airline#util#exec_funcrefs(g:airline_statusline_funcrefs, 0) endfunction diff --git a/autoload/airline/extensions/bufferline.vim b/autoload/airline/extensions/bufferline.vim index 9a863e1..c95cdf3 100644 --- a/autoload/airline/extensions/bufferline.vim +++ b/autoload/airline/extensions/bufferline.vim @@ -18,7 +18,7 @@ endfunction function! airline#extensions#bufferline#init(ext) highlight AlBl_active gui=bold cterm=bold term=bold - highlight link AlBl_inactive Al6 + highlight link AlBl_inactive airline_c let g:bufferline_inactive_highlight = 'AlBl_inactive' let g:bufferline_active_highlight = 'AlBl_active' let g:bufferline_active_buffer_left = '' diff --git a/autoload/airline/extensions/csv.vim b/autoload/airline/extensions/csv.vim index c1de708..b0402a0 100644 --- a/autoload/airline/extensions/csv.vim +++ b/autoload/airline/extensions/csv.vim @@ -5,7 +5,7 @@ if !exists('g:airline#extensions#csv#column_display') let g:airline#extensions#csv#column_display = 'Number' endif -function! airline#extensions#csv#get_statusline() +function! airline#extensions#csv#get_column() if exists('*CSV_WCol') if g:airline#extensions#csv#column_display ==# 'Name' return '['.CSV_WCol('Name').CSV_WCol().']' @@ -23,7 +23,7 @@ function! airline#extensions#csv#apply() endif let w:airline_section_gutter = \ g:airline_left_alt_sep - \ .' %{airline#extensions#csv#get_statusline()}' + \ .' %{airline#extensions#csv#get_column()}' \ .w:airline_section_gutter endif endfunction diff --git a/autoload/airline/extensions/ctrlp.vim b/autoload/airline/extensions/ctrlp.vim index d17ce2f..738faff 100644 --- a/autoload/airline/extensions/ctrlp.vim +++ b/autoload/airline/extensions/ctrlp.vim @@ -17,12 +17,12 @@ function! airline#extensions#ctrlp#load_theme() let theme = g:airline#themes#{g:airline_theme}#ctrlp else let theme = airline#extensions#ctrlp#generate_color_map( - \ g:airline#themes#{g:airline_theme}#insert['statusline'], - \ g:airline#themes#{g:airline_theme}#insert['info'], - \ g:airline#themes#{g:airline_theme}#insert['mode']) + \ g:airline#themes#{g:airline_theme}#insert['airline_c'], + \ g:airline#themes#{g:airline_theme}#insert['airline_b'], + \ g:airline#themes#{g:airline_theme}#insert['airline_a']) endif for key in keys(theme) - call airline#exec_highlight(key, theme[key]) + call airline#highlighter#exec(key, theme[key]) endfor endfunction diff --git a/autoload/airline/highlighter.vim b/autoload/airline/highlighter.vim new file mode 100644 index 0000000..b21572e --- /dev/null +++ b/autoload/airline/highlighter.vim @@ -0,0 +1,70 @@ +" MIT License. Copyright (c) 2013 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +let s:is_win32term = (has('win32') || has('win64')) && !has('gui_running') + +function! airline#highlighter#exec(group, colors) + let colors = a:colors + if s:is_win32term + let colors = map(a:colors, 'v:val != "" && v:val > 128 ? v:val - 128 : v:val') + endif + exec printf('hi %s %s %s %s %s %s %s %s', + \ a:group, + \ get(colors, 0, '') != '' ? 'guifg='.colors[0] : '', + \ get(colors, 1, '') != '' ? 'guibg='.colors[1] : '', + \ get(colors, 2, '') != '' ? 'ctermfg='.colors[2] : '', + \ get(colors, 3, '') != '' ? 'ctermbg='.colors[3] : '', + \ get(colors, 4, '') != '' ? 'gui='.colors[4] : '', + \ get(colors, 4, '') != '' ? 'cterm='.colors[4] : '', + \ get(colors, 4, '') != '' ? 'term='.colors[4] : '') +endfunction + +function! s:exec_separator(dict, from, to) + let l:from = airline#themes#get_highlight(a:from) + let l:to = airline#themes#get_highlight(a:to) + let group = a:from.'_to_'.a:to + let colors = [ l:to[1], l:from[1], l:to[3], l:from[3] ] + let a:dict[group] = colors + call airline#highlighter#exec(group, colors) +endfunction + +function! airline#highlighter#new() + let highlighter = {} + let highlighter._separators = {} + let highlighter._mode_init = {} + + function! highlighter.load_theme() + let self._mode_init = {} + call self.highlight(['inactive']) + call self.highlight(['normal']) + endfunction + + function! highlighter.add_separator(from, to) + let self._separators[a:from.a:to] = [a:from, a:to] + endfunction + + function! highlighter.highlight(modes) + " draw the base mode, followed by any overrides + let mapped = map(a:modes, 'v:val == a:modes[0] ? v:val : a:modes[0]."_".v:val') + let suffix = a:modes[0] == 'inactive' ? '_inactive' : '' + for mode in mapped + if exists('g:airline#themes#{g:airline_theme}#{mode}') + let dict = g:airline#themes#{g:airline_theme}#{mode} + for kvp in items(dict) + call airline#highlighter#exec(kvp[0].suffix, kvp[1]) + endfor + + " initialize separator colors for this mode if necessary + if !has_key(self._mode_init, mode) + let self._mode_init[mode] = 1 + for sep in items(self._separators) + call exec_separator(dict, sep[1][0].suffix, sep[1][1].suffix) + endfor + endif + endif + endfor + endfunction + + return highlighter +endfunction + diff --git a/autoload/airline/themes.vim b/autoload/airline/themes.vim index e932185..9f385d9 100644 --- a/autoload/airline/themes.vim +++ b/autoload/airline/themes.vim @@ -8,14 +8,12 @@ function! airline#themes#generate_color_map(section1, section2, section3, file) if file[1] == '' | let file[1] = a:section3[1] | endif if file[3] == '' | let file[3] = a:section3[3] | endif - " guifg guibg ctermfg ctermbg gui/term + " guifg guibg ctermfg ctermbg gui/term return { - \ 'mode': [ a:section1[0] , a:section1[1] , a:section1[2] , a:section1[3] , get(a:section1, 4, 'bold') ] , - \ 'mode_separator': [ a:section1[1] , a:section2[1] , a:section1[3] , a:section2[3] , '' ] , - \ 'info': [ a:section2[0] , a:section2[1] , a:section2[2] , a:section2[3] , get(a:section2, 4, '' ) ] , - \ 'info_separator': [ a:section2[1] , a:section3[1] , a:section2[3] , a:section3[3] , '' ] , - \ 'statusline': [ a:section3[0] , a:section3[1] , a:section3[2] , a:section3[3] , get(a:section3 , 4 , '' ) ] , - \ 'file': [ file[0] , file[1] , file[2] , file[3] , get(file , 4 , '' ) ] , + \ 'airline_a': [ a:section1[0] , a:section1[1] , a:section1[2] , a:section1[3] , get(a:section1, 4, 'bold') ] , + \ 'airline_b': [ a:section2[0] , a:section2[1] , a:section2[2] , a:section2[3] , get(a:section2, 4, '' ) ] , + \ 'airline_c': [ a:section3[0] , a:section3[1] , a:section3[2] , a:section3[3] , get(a:section3, 4, '' ) ] , + \ 'airline_file': [ file[0] , file[1] , file[2] , file[3] , get(file , 4, '' ) ] , \ } endfunction @@ -56,10 +54,3 @@ function! airline#themes#get_highlight2(fg, bg, ...) return s:get_array(fg, bg, a:000) endfunction -function! airline#themes#exec_highlight_separator(from, to) - let l:from = airline#themes#get_highlight(a:from) - let l:to = airline#themes#get_highlight(a:to) - let group = a:from.'_to_'.a:to - call airline#exec_highlight(group, [ l:to[1], l:from[1], l:to[3], l:from[3] ]) - return group -endfunction diff --git a/autoload/airline/themes/badwolf.vim b/autoload/airline/themes/badwolf.vim index c41c261..cb82523 100644 --- a/autoload/airline/themes/badwolf.vim +++ b/autoload/airline/themes/badwolf.vim @@ -21,31 +21,25 @@ let s:IA = [ s:N2[1] , s:N3[1] , s:N2[3] , s:N3[3] , '' ] let g:airline#themes#badwolf#normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3, s:file) let g:airline#themes#badwolf#normal_modified = { - \ 'mode_separator' : [ s:N1[1] , s:N4[0] , s:N1[3] , s:N4[1] , 'bold' ] , - \ 'info' : [ s:N2[0] , s:N4[0] , s:N2[2] , s:N4[1] , '' ] , - \ 'info_separator' : [ s:N4[0] , s:N2[1] , s:N4[1] , s:N2[3] , 'bold' ] , - \ 'statusline' : [ s:V1[1] , s:N2[1] , s:V1[3] , s:N2[3] , '' ] } + \ 'airline_b': [ s:N2[0] , s:N4[0] , s:N2[2] , s:N4[1] , '' ] , + \ 'airline_c': [ s:V1[1] , s:N2[1] , s:V1[3] , s:N2[3] , '' ] } let g:airline#themes#badwolf#insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3, s:file) let g:airline#themes#badwolf#insert_modified = { - \ 'info_separator' : [ s:I2[1] , s:N2[1] , s:I2[3] , s:N2[3] , 'bold' ] , - \ 'statusline' : [ s:V1[1] , s:N2[1] , s:V1[3] , s:N2[3] , '' ] } + \ 'airline_c': [ s:V1[1] , s:N2[1] , s:V1[3] , s:N2[3] , '' ] } let g:airline#themes#badwolf#insert_paste = { - \ 'mode' : [ s:I1[0] , s:PA[0] , s:I1[2] , s:PA[1] , '' ] , - \ 'mode_separator' : [ s:PA[0] , s:I2[1] , s:PA[1] , s:I2[3] , '' ] } + \ 'airline_a': [ s:I1[0] , s:PA[0] , s:I1[2] , s:PA[1] , '' ] } let g:airline#themes#badwolf#replace = copy(airline#themes#badwolf#insert) -let g:airline#themes#badwolf#replace.mode = [ s:I1[0] , s:RE[0] , s:I1[2] , s:RE[1] , '' ] -let g:airline#themes#badwolf#replace.mode_separator = [ s:RE[0] , s:I2[1] , s:RE[1] , s:I2[3] , '' ] +let g:airline#themes#badwolf#replace.airline_a = [ s:I1[0] , s:RE[0] , s:I1[2] , s:RE[1] , '' ] let g:airline#themes#badwolf#replace_modified = g:airline#themes#badwolf#insert_modified let g:airline#themes#badwolf#visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3, s:file) let g:airline#themes#badwolf#visual_modified = { - \ 'info_separator' : [ s:V2[1] , s:V4[0] , s:V2[3] , s:V4[1] , 'bold' ] , - \ 'statusline' : [ s:V3[0] , s:V4[0] , s:V3[2] , s:V4[1] , '' ] } + \ 'airline_c': [ s:V3[0] , s:V4[0] , s:V3[2] , s:V4[1] , '' ] } let g:airline#themes#badwolf#inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA, s:file) diff --git a/autoload/airline/themes/bubblegum.vim b/autoload/airline/themes/bubblegum.vim index 8bd9dd8..ccf6401 100644 --- a/autoload/airline/themes/bubblegum.vim +++ b/autoload/airline/themes/bubblegum.vim @@ -23,12 +23,12 @@ let s:cterm_pink = 182 let s:file = ['#ff0000', '', 160, '', ''] " Normal mode -let s:N1 = [s:gui_dark_gray, s:gui_green, s:cterm_dark_gray, s:cterm_green] -let s:N2 = [s:gui_light_gray, s:gui_med_gray_lo, s:cterm_light_gray, s:cterm_med_gray_lo] -let s:N3 = [s:gui_green, s:gui_med_gray_hi, s:cterm_green, s:cterm_med_gray_hi] +let s:N1 = [s:gui_dark_gray, s:gui_green, s:cterm_dark_gray, s:cterm_green] +let s:N2 = [s:gui_light_gray, s:gui_med_gray_lo, s:cterm_light_gray, s:cterm_med_gray_lo] +let s:N3 = [s:gui_green, s:gui_med_gray_hi, s:cterm_green, s:cterm_med_gray_hi] let g:airline#themes#bubblegum#normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3, s:file) let g:airline#themes#bubblegum#normal_modified = { - \ 'statusline': [s:gui_orange, s:gui_med_gray_hi, s:cterm_orange, s:cterm_med_gray_hi, ''], + \ 'airline_c': [s:gui_orange, s:gui_med_gray_hi, s:cterm_orange, s:cterm_med_gray_hi, ''], \ } " Insert mode @@ -37,15 +37,13 @@ let s:I3 = [s:gui_blue, s:gui_med_gray_hi, s:cterm_blue, s:cterm_med_gray_hi] let g:airline#themes#bubblegum#insert = airline#themes#generate_color_map(s:I1, s:N2, s:I3, s:file) let g:airline#themes#bubblegum#insert_modified = copy(g:airline#themes#bubblegum#normal_modified) let g:airline#themes#bubblegum#insert_paste = { - \ 'mode': [s:gui_dark_gray, s:gui_orange, s:cterm_dark_gray, s:cterm_orange, ''], - \ 'mode_separator': [s:gui_orange, s:gui_med_gray_lo, s:cterm_orange, s:cterm_med_gray_lo, ''], + \ 'airline_a': [s:gui_dark_gray, s:gui_orange, s:cterm_dark_gray, s:cterm_orange, ''], \ } " Replace mode let g:airline#themes#bubblegum#replace = { - \ 'mode': [s:gui_dark_gray, s:gui_red, s:cterm_dark_gray, s:cterm_red, ''], - \ 'mode_separator': [s:gui_red, s:N2[1], s:cterm_red, s:N2[3], ''], - \ 'statusline': [s:gui_red, s:gui_med_gray_hi, s:cterm_red, s:cterm_med_gray_hi, ''], + \ 'airline_a': [s:gui_dark_gray, s:gui_red, s:cterm_dark_gray, s:cterm_red, ''], + \ 'airline_c': [s:gui_red, s:gui_med_gray_hi, s:cterm_red, s:cterm_med_gray_hi, ''], \ } let g:airline#themes#bubblegum#replace_modified = copy(g:airline#themes#bubblegum#insert_modified) diff --git a/autoload/airline/themes/dark.vim b/autoload/airline/themes/dark.vim index af60414..216299a 100644 --- a/autoload/airline/themes/dark.vim +++ b/autoload/airline/themes/dark.vim @@ -44,8 +44,7 @@ let g:airline#themes#dark#normal = airline#themes#generate_color_map(s:N1, s:N2, " applied after g:airline#themes#dark#normal, hence why only certain keys are " declared. let g:airline#themes#dark#normal_modified = { - \ 'info_separator': [ '#444444' , '#5f005f' , 238 , 53 , '' ] , - \ 'statusline': [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] , + \ 'airline_c': [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] , \ } @@ -54,18 +53,15 @@ let s:I2 = [ '#ffffff' , '#005fff' , 255 , 27 ] let s:I3 = [ '#ffffff' , '#000080' , 15 , 17 ] let g:airline#themes#dark#insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3, s:file) let g:airline#themes#dark#insert_modified = { - \ 'info_separator': [ '#005fff' , '#5f005f' , 27 , 53 , '' ] , - \ 'statusline': [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] , + \ 'airline_c': [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] , \ } let g:airline#themes#dark#insert_paste = { - \ 'mode': [ s:I1[0] , '#d78700' , s:I1[2] , 172 , '' ] , - \ 'mode_separator': [ '#d78700' , s:I2[1] , 172 , s:I2[3] , '' ] , + \ 'airline_a': [ s:I1[0] , '#d78700' , s:I1[2] , 172 , '' ] , \ } let g:airline#themes#dark#replace = copy(g:airline#themes#dark#insert) -let g:airline#themes#dark#replace.mode = [ s:I2[0] , '#af0000' , s:I2[2] , 124 , '' ] -let g:airline#themes#dark#replace.mode_separator = [ '#af0000' , s:I2[1] , 124 , s:I2[3] , '' ] +let g:airline#themes#dark#replace.airline_a = [ s:I2[0] , '#af0000' , s:I2[2] , 124 , '' ] let g:airline#themes#dark#replace_modified = g:airline#themes#dark#insert_modified @@ -74,8 +70,7 @@ let s:V2 = [ '#000000' , '#ff5f00' , 232 , 202 ] let s:V3 = [ '#ffffff' , '#5f0000' , 15 , 52 ] let g:airline#themes#dark#visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3, s:file) let g:airline#themes#dark#visual_modified = { - \ 'info_separator': [ '#ff5f00' , '#5f005f' , 202 , 53 , '' ] , - \ 'statusline': [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] , + \ 'airline_c': [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] , \ } diff --git a/autoload/airline/themes/jellybeans.vim b/autoload/airline/themes/jellybeans.vim index 792c767..78c93ba 100644 --- a/autoload/airline/themes/jellybeans.vim +++ b/autoload/airline/themes/jellybeans.vim @@ -18,7 +18,7 @@ function! s:generate() let g:airline#themes#jellybeans#normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3, s:file) let g:airline#themes#jellybeans#normal_modified = { - \ 'statusline': [ '#ffb964', '', 215, '', '' ] + \ 'airline_c': [ '#ffb964', '', 215, '', '' ] \ } let s:I1 = airline#themes#get_highlight('DiffAdd', 'bold') diff --git a/autoload/airline/themes/laederon.vim b/autoload/airline/themes/laederon.vim index 8e18177..18d72ef 100644 --- a/autoload/airline/themes/laederon.vim +++ b/autoload/airline/themes/laederon.vim @@ -25,36 +25,30 @@ let s:RE = [ '#233e09' , 22 ] " oakleaf let s:PA = [ '#ab3e5d' , 161 ] " raspberry let s:file = [ '#ef393d' , '' , 196 , '' , '' ] -let s:IA = [ s:N2[1] , s:N3[1] , s:N2[3], s:N3[3] , '' ] +let s:IA = [ s:N2[1] , s:N3[1] , s:N2[3], s:N3[3] , '' ] let g:airline#themes#laederon#normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3, s:file) let g:airline#themes#laederon#normal_modified = { - \ 'mode_separator' : [ s:N1[1] , s:N4[0] , s:N1[3] , s:N4[1] , 'bold' ] , - \ 'info' : [ s:N2[0] , s:N4[0] , s:N2[2] , s:N4[1] , '' ] , - \ 'info_separator' : [ s:N4[0] , s:N2[1] , s:N4[1] , s:N2[3] , 'bold' ] , - \ 'statusline' : [ s:V1[1] , s:N2[1] , s:V1[3] , s:N2[3] , '' ] } + \ 'airline_a' : [ s:N2[0] , s:N4[0] , s:N2[2] , s:N4[1] , '' ] , + \ 'airline_c' : [ s:V1[1] , s:N2[1] , s:V1[3] , s:N2[3] , '' ] } let g:airline#themes#laederon#insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3, s:file) let g:airline#themes#laederon#insert_modified = { - \ 'info_separator' : [ s:I2[1] , s:N2[1] , s:I2[3] , s:N2[3] , 'bold' ] , - \ 'statusline' : [ s:V2[1] , s:N2[1] , s:V2[3] , s:N2[3] , '' ] } + \ 'airline_c' : [ s:V2[1] , s:N2[1] , s:V2[3] , s:N2[3] , '' ] } let g:airline#themes#laederon#insert_paste = { - \ 'mode' : [ s:I1[0] , s:PA[0] , s:I1[2] , s:PA[1] , '' ] , - \ 'mode_separator' : [ s:PA[0] , s:I2[1] , s:PA[1] , s:I2[3] , '' ] } + \ 'airline_a' : [ s:I1[0] , s:PA[0] , s:I1[2] , s:PA[1] , '' ] } let g:airline#themes#laederon#replace = copy(airline#themes#laederon#insert) -let g:airline#themes#laederon#replace.mode = [ s:I1[0] , s:RE[0] , s:I1[2] , s:RE[1] , '' ] -let g:airline#themes#laederon#replace.mode_separator = [ s:RE[0] , s:I2[1] , s:RE[1] , s:I2[3] , '' ] +let g:airline#themes#laederon#replace.airline_a = [ s:I1[0] , s:RE[0] , s:I1[2] , s:RE[1] , '' ] let g:airline#themes#laederon#replace_modified = g:airline#themes#laederon#insert_modified let g:airline#themes#laederon#visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3, s:file) let g:airline#themes#laederon#visual_modified = { - \ 'info_separator' : [ s:V2[1] , s:V4[0] , s:V2[3] , s:V4[1] , 'bold' ] , - \ 'statusline' : [ s:V3[0] , s:V4[0] , s:V3[2] , s:V4[1] , '' ] } + \ 'airline_c' : [ s:V3[0] , s:V4[0] , s:V3[2] , s:V4[1] , '' ] } let g:airline#themes#laederon#inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA, s:file) diff --git a/autoload/airline/themes/light.vim b/autoload/airline/themes/light.vim index 46450f4..a1e7e98 100644 --- a/autoload/airline/themes/light.vim +++ b/autoload/airline/themes/light.vim @@ -4,8 +4,7 @@ let s:N2 = [ '#000087' , '#00dfff' , 18 , 45 ] let s:N3 = [ '#005fff' , '#afffff' , 27 , 159 ] let g:airline#themes#light#normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3, s:file) let g:airline#themes#light#normal_modified = { - \ 'info_separator': [ '#00dfff' , '#ffdfdf' , 45 , 224 , '' ] , - \ 'statusline': [ '#df0000' , '#ffdfdf' , 160 , 224 , '' ] , + \ 'airline_c': [ '#df0000' , '#ffdfdf' , 160 , 224 , '' ] , \ } @@ -14,18 +13,15 @@ let s:I2 = [ '#005f00' , '#00df87' , 22 , 42 ] let s:I3 = [ '#005f5f' , '#afff87' , 23 , 156 ] let g:airline#themes#light#insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3, s:file) let g:airline#themes#light#insert_modified = { - \ 'info_separator': [ '#00df87' , '#ffdfdf' , 42 , 224 , '' ] , - \ 'statusline': [ '#df0000' , '#ffdfdf' , 160 , 224 , '' ] , + \ 'airline_c': [ '#df0000' , '#ffdfdf' , 160 , 224 , '' ] , \ } let g:airline#themes#light#insert_paste = { - \ 'mode': [ s:I1[0] , '#d78700' , s:I1[2] , 172 , '' ] , - \ 'mode_separator': [ '#d78700' , s:I2[1] , 172 , s:I2[3] , '' ] , + \ 'airline_a': [ s:I1[0] , '#d78700' , s:I1[2] , 172 , '' ] , \ } let g:airline#themes#light#replace = copy(g:airline#themes#light#insert) -let g:airline#themes#light#replace.mode = [ s:I2[0] , '#ff0000' , s:I1[2] , 196 , '' ] -let g:airline#themes#light#replace.mode_separator = [ '#ff0000' , s:I2[1] , 196 , s:I2[3] , '' ] +let g:airline#themes#light#replace.airline_a = [ s:I2[0] , '#ff0000' , s:I1[2] , 196 , '' ] let g:airline#themes#light#replace_modified = g:airline#themes#light#insert_modified @@ -34,8 +30,7 @@ let s:V2 = [ '#5f0000' , '#ffaf00' , 52 , 214 ] let s:V3 = [ '#df5f00' , '#ffff87' , 166 , 228 ] let g:airline#themes#light#visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3, s:file) let g:airline#themes#light#visual_modified = { - \ 'info_separator': [ '#ffaf00' , '#ffdfdf' , 214 , 224 , '' ] , - \ 'statusline': [ '#df0000' , '#ffdfdf' , 160 , 224 , '' ] , + \ 'airline_c': [ '#df0000' , '#ffdfdf' , 160 , 224 , '' ] , \ } diff --git a/autoload/airline/themes/luna.vim b/autoload/airline/themes/luna.vim index 63da2d2..a945d1a 100644 --- a/autoload/airline/themes/luna.vim +++ b/autoload/airline/themes/luna.vim @@ -7,10 +7,8 @@ let s:N2 = [ '#ffffff' , '#003f3f' , 231 , 29 ] let s:N3 = [ '#ffffff' , '#002b2b' , 231 , 23 ] let g:airline#themes#luna#normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3, s:file) - let g:airline#themes#luna#normal_modified = { - \ 'info_separator': [ '#003f3f' , '#450000' , 29 , 52 , '' ] , - \ 'statusline': [ '#ffffff' , '#450000' , 231 , 52 , '' ] , + \ 'airline_c': [ '#ffffff' , '#450000' , 231 , 52 , '' ] , \ } @@ -19,18 +17,15 @@ let s:I2 = [ '#ffffff' , '#003f3f' , 231 , 29 ] let s:I3 = [ '#ffffff' , '#002b2b' , 231 , 23 ] let g:airline#themes#luna#insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3, s:file) let g:airline#themes#luna#insert_modified = { - \ 'info_separator': [ '#003f3f' , '#005e5e' , 29 , 52 , '' ] , - \ 'statusline': [ '#ffffff' , '#005e5e' , 255 , 52 , '' ] , + \ 'airline_c': [ '#ffffff' , '#005e5e' , 255 , 52 , '' ] , \ } let g:airline#themes#luna#insert_paste = { - \ 'mode': [ s:I1[0] , '#789f00' , s:I1[2] , 106 , '' ] , - \ 'mode_separator': [ '#789f00' , s:I2[1] , 106 , s:I2[3] , '' ] , + \ 'airline_a': [ s:I1[0] , '#789f00' , s:I1[2] , 106 , '' ] , \ } let g:airline#themes#luna#replace = copy(g:airline#themes#luna#insert) -let g:airline#themes#luna#replace.mode = [ s:I2[0] , '#920000' , s:I2[2] , 88 , '' ] -let g:airline#themes#luna#replace.mode_separator = [ '#920000' , s:I2[1] , 88 , s:I2[3] , '' ] +let g:airline#themes#luna#replace.airline_a = [ s:I2[0] , '#920000' , s:I2[2] , 88 , '' ] let g:airline#themes#luna#replace_modified = g:airline#themes#luna#insert_modified let s:V1 = [ '#ffff9a' , '#ff8036' , 222 , 208 ] @@ -38,8 +33,7 @@ let s:V2 = [ '#ffffff' , '#003f3f' , 231 , 29 ] let s:V3 = [ '#ffffff' , '#002b2b' , 231 , 23 ] let g:airline#themes#luna#visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3, s:file) let g:airline#themes#luna#visual_modified = { - \ 'info_separator': [ '#003f3f' , '#450000' , 29 , 52 , '' ] , - \ 'statusline': [ '#ffffff' , '#450000' , 231 , 52 , '' ] , + \ 'airline_c': [ '#ffffff' , '#450000' , 231 , 52 , '' ] , \ } let s:IA = [ '#4e4e4e' , '#002b2b' , 59 , 23 , '' ] diff --git a/autoload/airline/themes/molokai.vim b/autoload/airline/themes/molokai.vim index 7fe6fed..1fd480e 100644 --- a/autoload/airline/themes/molokai.vim +++ b/autoload/airline/themes/molokai.vim @@ -7,8 +7,7 @@ let s:N3 = [ '#f8f8f0' , '#465457' , 253 , 67 ] " statusline let g:airline#themes#molokai#normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3, s:file) let g:airline#themes#molokai#normal_modified = { - \ 'info_separator': [ '#232526' , '#e6db74' , 16 , 144 , '' ] , - \ 'statusline': [ '#080808' , '#e6db74' , 232 , 144 , '' ] , + \ 'airline_c': [ '#080808' , '#e6db74' , 232 , 144 , '' ] , \ } @@ -19,18 +18,15 @@ let s:I3 = [ '#f8f8f0' , '#465457' , 253 , 67 ] let g:airline#themes#molokai#insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3, s:file) let g:airline#themes#molokai#insert_modified = { - \ 'info_separator': [ '#232526' , '#66d9ef' , 16 , 81 , '' ] , - \ 'statusline': [ '#080808' , '#66d9ef' , 232 , 81 , '' ] , + \ 'airline_c': [ '#080808' , '#66d9ef' , 232 , 81 , '' ] , \ } " Replace mode let g:airline#themes#molokai#replace = copy(g:airline#themes#molokai#insert) -let g:airline#themes#molokai#replace.mode = [ s:I1[0] , '#ef5939' , s:I1[2] , 166 , '' ] -let g:airline#themes#molokai#replace.mode_separator = [ '#ef5939' , s:I2[1] , 166 , s:I2[3] , '' ] -let g:airline#themes#molokai#replace_modified = { - \ 'info_separator': [ '#232526' , '#ef5939' , 16 , 166 , '' ] , - \ 'statusline': [ '#080808' , '#ef5939' , 232 , 166 , '' ] , +let g:airline#themes#molokai#replace.airline_a = [ s:I1[0] , '#ef5939' , s:I1[2] , 166 , '' ] +let g:airline#themes#molokai#replace_modified = { + \ 'airline_c': [ '#080808' , '#ef5939' , 232 , 166 , '' ] , \ } @@ -41,8 +37,7 @@ let s:V3 = [ '#f8f8f0' , '#465457' , 253 , 67 ] let g:airline#themes#molokai#visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3, s:file) let g:airline#themes#molokai#visual_modified = { - \ 'info_separator': [ '#232526' , '#fd971f' , 16 , 208 , '' ] , - \ 'statusline': [ '#080808' , '#fd971f' , 232 , 208 , '' ] , + \ 'airline_c': [ '#080808' , '#fd971f' , 232 , 208 , '' ] , \ } diff --git a/autoload/airline/themes/powerlineish.vim b/autoload/airline/themes/powerlineish.vim index 93d7ffd..dcfc0a7 100644 --- a/autoload/airline/themes/powerlineish.vim +++ b/autoload/airline/themes/powerlineish.vim @@ -32,17 +32,15 @@ let g:airline#themes#powerlineish#normal = airline#themes#generate_color_map(s:N let g:airline#themes#powerlineish#insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3, s:file) let g:airline#themes#powerlineish#insert_replace = { - \ 'mode' : [ s:RE[0] , s:I1[1] , s:RE[1] , s:I1[3] , '' ] , - \ 'mode_separator' : [ s:I1[1] , s:I2[1] , s:I1[3] , s:I2[3] , '' ] } + \ 'airline_a': [ s:RE[0] , s:I1[1] , s:RE[1] , s:I1[3] , '' ] } let g:airline#themes#powerlineish#visual = { - \ 'mode' : [ s:V1[0] , s:V1[1] , s:V1[2] , s:V1[3] , '' ] , - \ 'mode_separator' : [ s:V1[1] , s:N2[1] , s:V1[3] , s:N2[3] , '' ] } + \ 'airline_a': [ s:V1[0] , s:V1[1] , s:V1[2] , s:V1[3] , '' ] } let g:airline#themes#powerlineish#replace = copy(airline#themes#powerlineish#normal) -let g:airline#themes#powerlineish#replace.mode = [ s:RE[0] , s:RE[1] , s:RE[2] , s:RE[3] , '' ] -let g:airline#themes#powerlineish#replace.mode_separator = [ s:RE[1] , s:N2[1] , s:RE[3] , s:N2[3] , '' ] +let g:airline#themes#powerlineish#replace.airline_a = [ s:RE[0] , s:RE[1] , s:RE[2] , s:RE[3] , '' ] -let s:IA = [ s:N2[1] , s:N3[1] , s:N2[3] , s:N3[3] , '' ] +let s:IA = [ s:N2[1] , s:N3[1] , s:N2[3] , s:N3[3] , '' ] let g:airline#themes#powerlineish#inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA, s:file) + diff --git a/autoload/airline/themes/simple.vim b/autoload/airline/themes/simple.vim index c7c44e0..555b4c4 100644 --- a/autoload/airline/themes/simple.vim +++ b/autoload/airline/themes/simple.vim @@ -1,98 +1,38 @@ -let s:swap = 0 -if exists('g:airline_powerline_fonts') && g:airline_powerline_fonts - let s:swap = 1 - - let s:left = 0 - function! airline#themes#simple#left() - if s:left == 1 - let s:left = 0 - return '' - else - let s:left = 1 - return '' - endif - endfunction - let g:airline_left_sep = '%{airline#themes#simple#left()}' - - let s:right = 0 - function! airline#themes#simple#right() - if s:right == 1 - let s:right = 0 - return '' - else - let s:right = 1 - return '' - endif - endfunction - let g:airline_right_sep = '%{airline#themes#simple#right()}' -endif - -if g:airline_left_sep == '' && g:airline_right_sep == '' - let s:swap = 1 -endif - let s:guibg = '#080808' +let s:guibg2 = '#1c1c1c' let s:termbg = 232 -let s:termsep = 236 -let s:guisep = '#303030' +let s:termbg2= 234 let s:file = [ '#ff0000' , '' , 160 , '' , '' ] -let s:N1 = s:swap ? [ s:guibg , '#00dfff' , s:termbg , 45 ] : [ '#00dfff' , s:guibg , 45 , s:termbg ] -let s:N2 = [ '#ff5f00' , s:guibg, 202 , s:termbg ] -let s:N3 = [ '#767676' , s:guibg, 243 , s:termbg ] -let g:airline#themes#simple#normal = { - \ 'mode': [ s:N1[0] , s:N1[1] , s:N1[2] , s:N1[3] , 'bold' ] , - \ 'mode_separator': s:swap - \ ? [ '#00dfff' , s:N2[1] , 45 , s:N2[3] , 'bold' ] - \ : [ s:guisep , s:N2[1] , s:termsep , s:N2[3] , 'bold' ] , - \ 'info': [ s:N2[0] , s:N2[1] , s:N2[2] , s:N2[3] , '' ] , - \ 'info_separator': [ s:guisep , s:N3[1] , s:termsep , s:N3[3] , 'bold' ] , - \ 'statusline': [ s:N3[0] , s:N3[1] , s:N3[2] , s:N3[3] , '' ] , - \ 'file': s:file, - \ } +let s:N1 = [ s:guibg , '#00dfff' , s:termbg , 45 ] +let s:N2 = [ '#ff5f00' , s:guibg2, 202 , s:termbg2 ] +let s:N3 = [ '#767676' , s:guibg, 243 , s:termbg] +let g:airline#themes#simple#normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3, s:file) let g:airline#themes#simple#normal_modified = { - \ 'statusline': [ '#df0000' , s:guibg, 160 , s:termbg , '' ] , + \ 'airline_c': [ '#df0000' , s:guibg, 160 , s:termbg , '' ] , \ } -let s:I1 = s:swap ? [ s:guibg, '#5fff00' , s:termbg , 82 ] : [ '#5fff00' , s:guibg, 82 , s:termbg ] -let s:I2 = [ '#ff5f00' , s:guibg, 202 , s:termbg ] +let s:I1 = [ s:guibg, '#5fff00' , s:termbg , 82 ] +let s:I2 = [ '#ff5f00' , s:guibg2, 202 , s:termbg2 ] let s:I3 = [ '#767676' , s:guibg, 243 , s:termbg ] -let g:airline#themes#simple#insert = { - \ 'mode': [ s:I1[0] , s:I1[1] , s:I1[2] , s:I1[3] , 'bold' ] , - \ 'mode_separator': s:swap - \ ? [ '#5fff00' , s:I2[1] , 82 , s:I2[3] , 'bold' ] - \ : [ s:guisep , s:I2[1] , s:termsep , s:I2[3] , 'bold' ] , - \ 'info': [ s:I2[0] , s:I2[1] , s:I2[2] , s:I2[3] , '' ] , - \ 'info_separator': [ s:guisep , s:I3[1] , s:termsep , s:I3[3] , 'bold' ] , - \ 'statusline': [ s:I3[0] , s:I3[1] , s:I3[2] , s:I3[3] , '' ] , - \ } +let g:airline#themes#simple#insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3, s:file) let g:airline#themes#simple#insert_modified = copy(g:airline#themes#simple#normal_modified) let g:airline#themes#simple#insert_paste = { - \ 'mode': [ s:I1[0] , '#d78700' , s:I1[2] , 172 , '' ] , - \ 'mode_separator': [ '#d78700' , s:I2[1] , 172 , s:I2[3] , '' ] , + \ 'airline_a': [ s:I1[0] , '#d78700' , s:I1[2] , 172 , '' ] , \ } let g:airline#themes#simple#replace = { - \ 'mode': [ s:I1[0] , '#af0000' , s:I1[2] , 124 , '' ] , - \ 'mode_separator': [ '#af0000' , s:I2[1] , 124 , s:I2[3] , '' ] , + \ 'airline_a': [ s:I1[0] , '#af0000' , s:I1[2] , 124 , '' ] , \ } let g:airline#themes#simple#replace_modified = copy(g:airline#themes#simple#normal_modified) -let s:V1 = s:swap ? [ s:guibg, '#dfdf00' , s:termbg , 184 ] : [ '#dfdf00' , s:guibg, 184 , s:termbg ] -let s:V2 = [ '#ff5f00' , s:guibg, 202 , s:termbg ] +let s:V1 = [ s:guibg, '#dfdf00' , s:termbg , 184 ] +let s:V2 = [ '#ff5f00' , s:guibg2, 202 , s:termbg2 ] let s:V3 = [ '#767676' , s:guibg, 243 , s:termbg ] -let g:airline#themes#simple#visual = { - \ 'mode': [ s:V1[0] , s:V1[1] , s:V1[2] , s:V1[3] , 'bold' ] , - \ 'mode_separator': s:swap - \ ? [ '#dfdf00' , s:V2[1] , 184 , s:V2[3] , 'bold' ] - \ : [ s:guisep , s:V2[1] , s:termsep , s:V2[3] , 'bold' ] , - \ 'info': [ s:V2[0] , s:V2[1] , s:V2[2] , s:V2[3] , '' ] , - \ 'info_separator': [ s:guisep , s:V3[1] , s:termsep , s:V3[3] , 'bold' ] , - \ 'statusline': [ s:V3[0] , s:V3[1] , s:V3[2] , s:V3[3] , '' ] , - \ } +let g:airline#themes#simple#visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3, s:file) let g:airline#themes#simple#visual_modified = copy(g:airline#themes#simple#normal_modified) diff --git a/autoload/airline/themes/solarized.vim b/autoload/airline/themes/solarized.vim index f600922..ca331c0 100644 --- a/autoload/airline/themes/solarized.vim +++ b/autoload/airline/themes/solarized.vim @@ -46,27 +46,15 @@ function! s:generate() let s:NF = [s:orange, s:N3[1], ''] if s:reduced if s:background == 'dark' - let s:NM = { - \ 'info_separator': [s:N2[1], s:N3[1], ''], - \ 'statusline': [s:magenta, s:N3[1], ''], - \ } + let s:NM = [s:magenta, s:N3[1], ''] else - let s:NM = { - \ 'info_separator': [s:N2[1], s:N3[1], ''], - \ 'statusline': [s:magenta, s:N3[1], ''], - \ } + let s:NM = [s:magenta, s:N3[1], ''] endif else if s:background == 'dark' - let s:NM = { - \ 'info_separator': [s:N2[1], s:c52, ''], - \ 'statusline': [s:c218, s:c52, ''] - \ } + let s:NM = [s:c218, s:c52, ''] else - let s:NM = { - \ 'info_separator': [s:N2[1], s:c218, ''], - \ 'statusline': [s:red, s:c218, ''] - \ } + let s:NM = [s:red, s:c218, ''] endif endif @@ -80,14 +68,7 @@ function! s:generate() endif let s:I3 = s:N3 let s:IF = s:NF - if s:reduced - let s:IM = s:NM - else - let s:IM = { - \ 'info_separator': [s:I2[1], s:NM.statusline[1], ''], - \ 'statusline': s:NM.statusline - \ } - endif + let s:IM = s:NM " Visual mode let s:V1 = [s:N1[0], s:orange, 'bold'] @@ -133,10 +114,8 @@ function! s:generate() \ s:NFa) let g:airline#themes#solarized#normal_modified = { - \ 'info_separator': [s:NM.info_separator[0].g, s:NM.info_separator[1].g, - \ s:NM.info_separator[0].t, s:NM.info_separator[1].t, s:NM.info_separator[2]], - \ 'statusline': [s:NM.statusline[0].g, s:NM.statusline[1].g, - \ s:NM.statusline[0].t, s:NM.statusline[1].t, s:NM.statusline[2]]} + \ 'airline_c': [s:NM[0].g, s:NM[1].g, + \ s:NM[0].t, s:NM[1].t, s:NM[2]]} let g:airline#themes#solarized#insert = airline#themes#generate_color_map( \ [s:I1[0].g, s:I1[1].g, s:I1[0].t, s:I1[1].t, s:I1[2]], @@ -145,10 +124,8 @@ function! s:generate() \ s:IFa) let g:airline#themes#solarized#insert_modified = { - \ 'info_separator': [s:IM.info_separator[0].g, s:IM.info_separator[1].g, - \ s:IM.info_separator[0].t, s:IM.info_separator[1].t, s:IM.info_separator[2]], - \ 'statusline': [s:IM.statusline[0].g, s:IM.statusline[1].g, - \ s:IM.statusline[0].t, s:IM.statusline[1].t, s:IM.statusline[2]]} + \ 'airline_c': [s:IM[0].g, s:IM[1].g, + \ s:IM[0].t, s:IM[1].t, s:IM[2]]} let g:airline#themes#solarized#visual = airline#themes#generate_color_map( \ [s:V1[0].g, s:V1[1].g, s:V1[0].t, s:V1[1].t, s:V1[2]], @@ -157,14 +134,12 @@ function! s:generate() \ s:VFa) let g:airline#themes#solarized#visual_modified = { - \ 'info_separator': [s:VM.info_separator[0].g, s:VM.info_separator[1].g, - \ s:VM.info_separator[0].t, s:VM.info_separator[1].t, s:VM.info_separator[2]], - \ 'statusline': [s:VM.statusline[0].g, s:VM.statusline[1].g, - \ s:VM.statusline[0].t, s:VM.statusline[1].t, s:VM.statusline[2]]} + \ 'airline_c': [s:VM[0].g, s:VM[1].g, + \ s:VM[0].t, s:VM[1].t, s:VM[2]]} endfunction call s:generate() augroup airline_solarized autocmd! - autocmd ColorScheme * call generate() | call airline#reload_highlight() + autocmd ColorScheme * call generate() | call airline#load_theme() augroup END diff --git a/autoload/airline/themes/tomorrow.vim b/autoload/airline/themes/tomorrow.vim index 41b90eb..88c3838 100644 --- a/autoload/airline/themes/tomorrow.vim +++ b/autoload/airline/themes/tomorrow.vim @@ -11,7 +11,7 @@ function! s:generate() let group = airline#themes#get_highlight('vimCommand') let g:airline#themes#tomorrow#normal_modified = { - \ 'statusline': [ group[0], '', group[2], '', '' ] + \ 'airline_c': [ group[0], '', group[2], '', '' ] \ } let s:I1 = airline#themes#get_highlight2(['Normal', 'bg'], ['MoreMsg', 'fg'], 'bold') @@ -39,5 +39,5 @@ endfunction call s:generate() augroup airline_tomorrow autocmd! - autocmd ColorScheme * call generate() | call airline#reload_highlight() + autocmd ColorScheme * call generate() | call airline#load_theme() augroup END diff --git a/autoload/airline/themes/ubaryd.vim b/autoload/airline/themes/ubaryd.vim index 608a2f5..8b30553 100644 --- a/autoload/airline/themes/ubaryd.vim +++ b/autoload/airline/themes/ubaryd.vim @@ -25,38 +25,32 @@ let s:RE = [ '#c7915b' , 173 ] " nut let s:PA = [ '#f9ef6d' , 154 ] " bleaklemon let s:file = [ '#ff7400' , '' , 196 , '' , '' ] -let s:IA = [ s:N2[1] , s:N3[1] , s:N2[3], s:N3[3] , '' ] +let s:IA = [ s:N2[1], s:N3[1], s:N2[3], s:N3[3], '' ] let g:airline#themes#ubaryd#normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3, s:file) let g:airline#themes#ubaryd#normal_modified = { - \ 'mode_separator' : [ s:N1[1] , s:N4[0] , s:N1[3] , s:N4[1] , 'bold' ] , - \ 'info' : [ s:N2[0] , s:N4[0] , s:N2[2] , s:N4[1] , '' ] , - \ 'info_separator' : [ s:N4[0] , s:N2[1] , s:N4[1] , s:N2[3] , 'bold' ] , - \ 'statusline' : [ s:V1[1] , s:N2[1] , s:V1[3] , s:N2[3] , '' ] } + \ 'airline_a' : [ s:N2[0] , s:N4[0] , s:N2[2] , s:N4[1] , '' ] , + \ 'airline_c' : [ s:V1[1] , s:N2[1] , s:V1[3] , s:N2[3] , '' ] } let g:airline#themes#ubaryd#inactive = { - \ 'mode' : [ s:N2[1] , s:N3[1] , s:N2[3] , s:N3[3] , '' ] } + \ 'airline_a' : [ s:N2[1] , s:N3[1] , s:N2[3] , s:N3[3] , '' ] } let g:airline#themes#ubaryd#insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3, s:file) let g:airline#themes#ubaryd#insert_modified = { - \ 'info_separator' : [ s:I2[1] , s:N2[1] , s:I2[3] , s:N2[3] , 'bold' ] , - \ 'statusline' : [ s:V2[1] , s:N2[1] , s:V2[3] , s:N2[3] , '' ] } + \ 'airline_c' : [ s:V2[1] , s:N2[1] , s:V2[3] , s:N2[3] , '' ] } let g:airline#themes#ubaryd#insert_paste = { - \ 'mode' : [ s:I1[0] , s:PA[0] , s:I1[2] , s:PA[1] , '' ] , - \ 'mode_separator' : [ s:PA[0] , s:I2[1] , s:PA[1] , s:I2[3] , '' ] } + \ 'airline_a' : [ s:I1[0] , s:PA[0] , s:I1[2] , s:PA[1] , '' ] } let g:airline#themes#ubaryd#replace = copy(airline#themes#ubaryd#insert) -let g:airline#themes#ubaryd#replace.mode = [ s:I1[0] , s:RE[0] , s:I1[2] , s:RE[1] , '' ] -let g:airline#themes#ubaryd#replace.mode_separator = [ s:RE[0] , s:I2[1] , s:RE[1] , s:I2[3] , '' ] +let g:airline#themes#ubaryd#replace.airline_a = [ s:I1[0] , s:RE[0] , s:I1[2] , s:RE[1] , '' ] let g:airline#themes#ubaryd#replace_modified = g:airline#themes#ubaryd#insert_modified let g:airline#themes#ubaryd#visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3, s:file) let g:airline#themes#ubaryd#visual_modified = { - \ 'info_separator' : [ s:V2[1] , s:V4[0] , s:V2[3] , s:V4[1] , 'bold' ] , - \ 'statusline' : [ s:V3[0] , s:V4[0] , s:V3[2] , s:V4[1] , '' ] } + \ 'airline_c' : [ s:V3[0] , s:V4[0] , s:V3[2] , s:V4[1] , '' ] } let g:airline#themes#ubaryd#inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA, s:file) diff --git a/autoload/airline/themes/wombat.vim b/autoload/airline/themes/wombat.vim index 860ccc6..14365c3 100644 --- a/autoload/airline/themes/wombat.vim +++ b/autoload/airline/themes/wombat.vim @@ -41,46 +41,36 @@ let s:IA = [ '#767676' , s:N3[1] , 243 , s:N3[3] , '' ] let g:airline#themes#wombat#normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3, s:file) let g:airline#themes#wombat#normal_modified = { - \ 'mode' : [ s:N1[0] , s:N4[0] , s:N1[2] , s:N4[1] , '' ] , - \ 'mode_separator' : [ s:N4[0] , s:IM[0] , s:N4[1] , s:IM[1] , 'bold' ] , - \ 'info' : [ s:N4[0] , s:IM[0] , s:N4[1] , s:IM[1] , '' ] , - \ 'info_separator' : [ s:IM[0] , s:N3[1] , s:IM[1] , s:N3[3] , 'bold' ] , - \ 'statusline' : [ s:N4[0] , s:N3[1] , s:N4[1] , s:N3[3] , '' ] } + \ 'airline_a': [ s:N1[0] , s:N4[0] , s:N1[2] , s:N4[1] , '' ] , + \ 'airline_b': [ s:N4[0] , s:IM[0] , s:N4[1] , s:IM[1] , '' ] , + \ 'airline_c': [ s:N4[0] , s:N3[1] , s:N4[1] , s:N3[3] , '' ] } let g:airline#themes#wombat#insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3, s:file) let g:airline#themes#wombat#insert_modified = { - \ 'mode' : [ s:I1[0] , s:I4[0] , s:I1[2] , s:I4[1] , '' ] , - \ 'mode_separator' : [ s:I4[0] , s:IM[0] , s:I4[1] , s:IM[1] , 'bold' ] , - \ 'info' : [ s:I4[0] , s:IM[0] , s:I4[1] , s:IM[1] , '' ] , - \ 'info_separator' : [ s:IM[0] , s:N3[1] , s:IM[1] , s:N3[3] , 'bold' ] , - \ 'statusline' : [ s:I4[0] , s:N3[1] , s:I4[1] , s:N3[3] , '' ] } + \ 'airline_a': [ s:I1[0] , s:I4[0] , s:I1[2] , s:I4[1] , '' ] , + \ 'airline_b': [ s:I4[0] , s:IM[0] , s:I4[1] , s:IM[1] , '' ] , + \ 'airline_c': [ s:I4[0] , s:N3[1] , s:I4[1] , s:N3[3] , '' ] } let g:airline#themes#wombat#visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3, s:file) let g:airline#themes#wombat#visual_modified = { - \ 'mode' : [ s:V1[0] , s:V4[0] , s:V1[2] , s:V4[1] , '' ] , - \ 'mode_separator' : [ s:V4[0] , s:IM[0] , s:V4[1] , s:IM[1] , 'bold' ] , - \ 'info' : [ s:V4[0] , s:IM[0] , s:V4[1] , s:IM[1] , '' ] , - \ 'info_separator' : [ s:IM[0] , s:N3[1] , s:IM[1] , s:N3[3] , 'bold' ] , - \ 'statusline' : [ s:V4[0] , s:N3[1] , s:V4[1] , s:N3[3] , '' ] } + \ 'airline_a': [ s:V1[0] , s:V4[0] , s:V1[2] , s:V4[1] , '' ] , + \ 'airline_b': [ s:V4[0] , s:IM[0] , s:V4[1] , s:IM[1] , '' ] , + \ 'airline_c': [ s:V4[0] , s:N3[1] , s:V4[1] , s:N3[3] , '' ] } let g:airline#themes#wombat#replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3, s:file) let g:airline#themes#wombat#replace_modified = { - \ 'mode' : [ s:R1[0] , s:R4[0] , s:R1[2] , s:R4[1] , '' ] , - \ 'mode_separator' : [ s:R4[0] , s:IM[0] , s:R4[1] , s:IM[1] , 'bold' ] , - \ 'info' : [ s:R4[0] , s:IM[0] , s:R4[1] , s:IM[1] , '' ] , - \ 'info_separator' : [ s:IM[0] , s:N3[1] , s:IM[1] , s:N3[3] , 'bold' ] , - \ 'statusline' : [ s:R4[0] , s:N3[1] , s:R4[1] , s:N3[3] , '' ] } + \ 'airline_a': [ s:R1[0] , s:R4[0] , s:R1[2] , s:R4[1] , '' ] , + \ 'airline_b': [ s:R4[0] , s:IM[0] , s:R4[1] , s:IM[1] , '' ] , + \ 'airline_c': [ s:R4[0] , s:N3[1] , s:R4[1] , s:N3[3] , '' ] } let g:airline#themes#wombat#insert_paste = { - \ 'mode' : [ s:I1[0] , s:PA[0] , s:I1[2] , s:PA[1] , '' ] , - \ 'mode_separator' : [ s:PA[0] , s:IM[0] , s:PA[1] , s:IM[1] , 'bold' ] , - \ 'info' : [ s:PA[0] , s:IM[0] , s:PA[1] , s:IM[1] , '' ] , - \ 'info_separator' : [ s:IM[0] , s:N3[1] , s:IM[1] , s:N3[3] , 'bold' ] , - \ 'statusline' : [ s:PA[0] , s:N3[1] , s:PA[1] , s:N3[3] , '' ] } + \ 'airline_a': [ s:I1[0] , s:PA[0] , s:I1[2] , s:PA[1] , '' ] , + \ 'airline_b': [ s:PA[0] , s:IM[0] , s:PA[1] , s:IM[1] , '' ] , + \ 'airline_c': [ s:PA[0] , s:N3[1] , s:PA[1] , s:N3[3] , '' ] } let g:airline#themes#wombat#inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA, s:file) diff --git a/autoload/airline/util.vim b/autoload/airline/util.vim new file mode 100644 index 0000000..9311111 --- /dev/null +++ b/autoload/airline/util.vim @@ -0,0 +1,44 @@ +" MIT License. Copyright (c) 2013 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if v:version >= 703 + function! airline#util#getwinvar(winnr, key, def) + return getwinvar(a:winnr, a:key, a:def) + endfunction +else + function! airline#util#getwinvar(winnr, key, def) + let winvals = getwinvar(a:winnr, '') + return get(winvals, a:key, def) + endfunction +endif + +if v:version >= 704 + function! airline#util#exec_funcrefs(list, break_early) + for Fn in a:list + if a:break_early + if Fn() + return 1 + endif + else + call Fn() + endif + endfor + endfunction +else + function! airline#util#exec_funcrefs(list, break_early) + " for 7.2; we cannot iterate the list, hence why we use range() + " for 7.3-[97, 328]; we cannot reuse the variable, hence the {} + for i in range(0, len(a:list) - 1) + let Fn{i} = a:list[i] + if a:break_early + if Fn{i}() + return 1 + endif + else + call Fn{i}() + endif + endfor + return 0 + endfunction +endif + diff --git a/plugin/airline.vim b/plugin/airline.vim index b514d2b..5f8755d 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -1,5 +1,5 @@ " MIT License. Copyright (c) 2013 Bailey Ling. -" vim: ts=2 sts=2 sw=2 fdm=indent +" vim: et ts=2 sts=2 sw=2 if &cp || v:version < 702 || (exists('g:loaded_airline') && g:loaded_airline) finish @@ -46,7 +46,7 @@ call s:check_defined('g:airline_mode_map', { \ 'R' : 'REPLACE', \ 'v' : 'VISUAL', \ 'V' : 'V-LINE', - \ 'c' : 'CMD ', + \ 'c' : 'COMMAND', \ '' : 'V-BLOCK', \ 's' : 'SELECT', \ 'S' : 'S-LINE', @@ -66,7 +66,7 @@ let s:airline_initialized = 0 function! s:on_window_changed() if !s:airline_initialized call airline#extensions#load() - call airline#load_theme(g:airline_theme) + call airline#switch_theme(g:airline_theme) let s:airline_initialized = 1 endif call airline#update_statusline() @@ -95,7 +95,7 @@ function! s:airline_toggle() \ | call on_window_changed() autocmd CmdwinLeave * call remove(g:airline_statusline_funcrefs, -1) - autocmd ColorScheme * call airline#reload_highlight() + autocmd ColorScheme * call airline#load_theme() autocmd WinEnter,BufWinEnter,FileType,BufUnload,ShellCmdPost * \ call on_window_changed() augroup END @@ -111,7 +111,7 @@ function! s:get_airline_themes(a, l, p) endfunction function! s:airline_theme(...) if a:0 - call airline#load_theme(a:1) + call airline#switch_theme(a:1) else echo g:airline_theme endif @@ -121,3 +121,4 @@ command! AirlineToggleWhitespace call airline#extensions#whitespace#toggle() command! AirlineToggle call airline_toggle() call airline_toggle() +