From 8b92cae46cb8afac86e177ae1a4bb1dc0edf55a3 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Thu, 15 Aug 2013 23:20:29 +0000 Subject: [PATCH 01/18] basic working dynamic statusline builder --- autoload/airline.vim | 93 ++++++++++++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 33 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index b8c074a8..9b557c6e 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -1,4 +1,4 @@ -" MIT license. Copyright (c) 2013 Bailey Ling. +" MIT License. Copyright (c) 2013 Bailey Ling. " vim: ts=2 sts=2 sw=2 fdm=indent let s:is_win32term = (has('win32') || has('win64')) && !has('gui_running') @@ -13,6 +13,53 @@ let s:airline_highlight_map = { \ 'file' : 'Al7', \ } +function! s:create_builder(active) + let builder = {} + let builder._sections = [] + let builder._active = a:active + + function! builder.split(gutter) + call add(self._sections, ['|', a:gutter]) + endfunction + + function! builder.add_section(group, contents) + call add(self._sections, [a:group, a:contents]) + endfunction + + function! builder._group(group) + return self._active ? a:group : a:group.'_inactive' + endfunction + + function! builder.build() + let line = '%{airline#update_highlight()}' + let side = 0 + let prev_group = '' + for section in self._sections + if section[0] == '|' + let side = 1 + let line .= section[1] + continue + endif + + if prev_group != '' + let sep_group = side == 0 + \ ? airline#themes#exec_highlight_separator(section[0], prev_group) + \ : airline#themes#exec_highlight_separator(prev_group, section[0]) + let line .= '%#'.self._group(sep_group).'#' + 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 + + return builder +endfunction + function! airline#exec_highlight(group, colors) let colors = a:colors if s:is_win32term @@ -71,46 +118,26 @@ function! s:get_section(winnr, key, ...) 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 = s:create_builder(a:active) - 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 : ''}%)" + call builder.add_section('Al2', s:get_section(a:winnr, 'a')) + call builder.add_section('Al7', '%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}') + call builder.add_section('Al4', s:get_section(a:winnr, 'b')) + call builder.add_section('Al6', s:get_section(a:winnr, 'c').' %#Al7#%{&ro ? g:airline_readonly_symbol : ""}') else - let sl.=l:status_color.' %f%m' + call builder.add_section('Al6', '%f%m') endif - let sl.=l:status_color.s:get_section(a:winnr, 'gutter', '', '').l:status_color + call builder.split(s:get_section(a:winnr, 'gutter', '', '')) 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.add_section('Al6', s:get_section(a:winnr, 'x')) + call builder.add_section('Al4', s:get_section(a:winnr, 'y')) + call builder.add_section('Al2', 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_section('warningmsg', s:get_section(a:winnr, 'warning', '', '')) endif endif - return sl + return builder.build() endfunction function! airline#exec_funcrefs(list, break_early) From 703045a7e64307a29c54a37ac911960d4e5f3e07 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Fri, 16 Aug 2013 00:36:42 +0000 Subject: [PATCH 02/18] allow warning section to collapse away --- autoload/airline.vim | 25 +++++++++++++++++-------- autoload/airline/themes.vim | 3 +++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 9b557c6e..77de75e3 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -26,8 +26,12 @@ function! s:create_builder(active) call add(self._sections, [a:group, a:contents]) endfunction + function! builder.add_raw(text) + call add(self._sections, ['_', a:text]) + endfunction + function! builder._group(group) - return self._active ? a:group : a:group.'_inactive' + return '%#' . (self._active ? a:group : a:group.'_inactive') . '#' endfunction function! builder.build() @@ -37,21 +41,25 @@ function! s:create_builder(active) for section in self._sections if section[0] == '|' let side = 1 + let line .= '%#'.prev_group.'#'.section[1] + let prev_group = '' + continue + endif + if section[0] == '_' let line .= section[1] continue endif if prev_group != '' - let sep_group = side == 0 - \ ? airline#themes#exec_highlight_separator(section[0], prev_group) - \ : airline#themes#exec_highlight_separator(prev_group, section[0]) - let line .= '%#'.self._group(sep_group).'#' + let line .= side == 0 + \ ? self._group(airline#themes#exec_highlight_separator(section[0], prev_group)) + \ : self._group(airline#themes#exec_highlight_separator(prev_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 line .= self._group(section[0]).section[1] let prev_group = section[0] endfor return line @@ -121,8 +129,7 @@ function! airline#get_statusline(winnr, active) let builder = s:create_builder(a:active) if s:getwinvar(a:winnr, 'airline_render_left', a:active || (!a:active && !g:airline_inactive_collapse)) - call builder.add_section('Al2', s:get_section(a:winnr, 'a')) - call builder.add_section('Al7', '%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}') + call builder.add_section('Al2', s:get_section(a:winnr, 'a').'%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}') call builder.add_section('Al4', s:get_section(a:winnr, 'b')) call builder.add_section('Al6', s:get_section(a:winnr, 'c').' %#Al7#%{&ro ? g:airline_readonly_symbol : ""}') else @@ -134,7 +141,9 @@ function! airline#get_statusline(winnr, active) call builder.add_section('Al4', s:get_section(a:winnr, 'y')) call builder.add_section('Al2', s:get_section(a:winnr, 'z')) if a:active + call builder.add_raw('%(') call builder.add_section('warningmsg', s:get_section(a:winnr, 'warning', '', '')) + call builder.add_raw('%)') endif endif return builder.build() diff --git a/autoload/airline/themes.vim b/autoload/airline/themes.vim index e932185e..5116139f 100644 --- a/autoload/airline/themes.vim +++ b/autoload/airline/themes.vim @@ -57,6 +57,9 @@ function! airline#themes#get_highlight2(fg, bg, ...) endfunction function! airline#themes#exec_highlight_separator(from, to) + if a:from == a:to + return a:from + endif 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 From f477520ba8cd1d7743c5cf5efbd58aaf0b4d1d00 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Fri, 16 Aug 2013 01:12:02 +0000 Subject: [PATCH 03/18] move builder to its own file --- autoload/airline.vim | 57 +----------------------------------- autoload/airline/builder.vim | 57 ++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 56 deletions(-) create mode 100644 autoload/airline/builder.vim diff --git a/autoload/airline.vim b/autoload/airline.vim index 77de75e3..1ce78d56 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -13,61 +13,6 @@ let s:airline_highlight_map = { \ 'file' : 'Al7', \ } -function! s:create_builder(active) - let builder = {} - let builder._sections = [] - let builder._active = a:active - - function! builder.split(gutter) - call add(self._sections, ['|', a:gutter]) - endfunction - - function! builder.add_section(group, contents) - call add(self._sections, [a:group, a:contents]) - endfunction - - function! builder.add_raw(text) - call add(self._sections, ['_', a:text]) - endfunction - - function! builder._group(group) - return '%#' . (self._active ? a:group : a:group.'_inactive') . '#' - endfunction - - function! builder.build() - let line = '%{airline#update_highlight()}' - let side = 0 - let prev_group = '' - for section in self._sections - if section[0] == '|' - let side = 1 - let line .= '%#'.prev_group.'#'.section[1] - let prev_group = '' - continue - endif - if section[0] == '_' - let line .= section[1] - continue - endif - - if prev_group != '' - let line .= side == 0 - \ ? self._group(airline#themes#exec_highlight_separator(section[0], prev_group)) - \ : self._group(airline#themes#exec_highlight_separator(prev_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 - - return builder -endfunction - function! airline#exec_highlight(group, colors) let colors = a:colors if s:is_win32term @@ -126,7 +71,7 @@ function! s:get_section(winnr, key, ...) endfunction function! airline#get_statusline(winnr, active) - let builder = s:create_builder(a:active) + let builder = airline#builder#new(a:active) if s:getwinvar(a:winnr, 'airline_render_left', a:active || (!a:active && !g:airline_inactive_collapse)) call builder.add_section('Al2', s:get_section(a:winnr, 'a').'%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}') diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim new file mode 100644 index 00000000..5b443dd5 --- /dev/null +++ b/autoload/airline/builder.vim @@ -0,0 +1,57 @@ +" MIT license. Copyright (c) 2013 Bailey Ling. +" vim: ts=2 sts=2 sw=2 fdm=indent + +function! airline#builder#new(active) + let builder = {} + let builder._sections = [] + let builder._active = a:active + + function! builder.split(gutter) + call add(self._sections, ['|', a:gutter]) + endfunction + + function! builder.add_section(group, contents) + call add(self._sections, [a:group, a:contents]) + endfunction + + function! builder.add_raw(text) + call add(self._sections, ['_', a:text]) + endfunction + + function! builder._group(group) + return '%#' . (self._active ? a:group : a:group.'_inactive') . '#' + endfunction + + function! builder.build() + let line = '%{airline#update_highlight()}' + let side = 0 + let prev_group = '' + for section in self._sections + if section[0] == '|' + let side = 1 + let line .= '%#'.prev_group.'#'.section[1] + let prev_group = '' + continue + endif + if section[0] == '_' + let line .= section[1] + continue + endif + + if prev_group != '' + let line .= side == 0 + \ ? self._group(airline#themes#exec_highlight_separator(section[0], prev_group)) + \ : self._group(airline#themes#exec_highlight_separator(prev_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 + + return builder +endfunction From 47c80c31da0ae3abc06942d6d970ca6e2dd60d5e Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Fri, 16 Aug 2013 01:24:06 +0000 Subject: [PATCH 04/18] reload separator colors on demand --- autoload/airline.vim | 5 ++++- autoload/airline/builder.vim | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 1ce78d56..7a87cf62 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -55,7 +55,9 @@ function! airline#highlight(modes) endfor endif endfor - call airline#themes#exec_highlight_separator('Al2', 'warningmsg') + if exists('w:airline_current_builder') + call w:airline_current_builder.refresh_separator_highlights() + endif endfunction " for 7.2 compatibility @@ -72,6 +74,7 @@ endfunction function! airline#get_statusline(winnr, active) let builder = airline#builder#new(a:active) + call setwinvar(a:winnr, 'airline_current_builder', builder) if s:getwinvar(a:winnr, 'airline_render_left', a:active || (!a:active && !g:airline_inactive_collapse)) call builder.add_section('Al2', s:get_section(a:winnr, 'a').'%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}') diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index 5b443dd5..ced5f032 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -4,6 +4,7 @@ function! airline#builder#new(active) let builder = {} let builder._sections = [] + let builder._separator_groups = [] let builder._active = a:active function! builder.split(gutter) @@ -18,6 +19,12 @@ function! airline#builder#new(active) call add(self._sections, ['_', a:text]) endfunction + function! builder.refresh_separator_highlights() + for sep in self._separator_groups + call airline#themes#exec_highlight_separator(sep[0], sep[1]) + endfor + endfunction + function! builder._group(group) return '%#' . (self._active ? a:group : a:group.'_inactive') . '#' endfunction @@ -39,9 +46,11 @@ function! airline#builder#new(active) endif if prev_group != '' + let sep = side == 0 ? [section[0], prev_group] : [prev_group, section[0]] + call add(self._separator_groups, sep) let line .= side == 0 - \ ? self._group(airline#themes#exec_highlight_separator(section[0], prev_group)) - \ : self._group(airline#themes#exec_highlight_separator(prev_group, section[0])) + \ ? self._group(section[0].'_to_'.prev_group) + \ : self._group(prev_group.'_to_'.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 @@ -50,6 +59,7 @@ function! airline#builder#new(active) let line .= self._group(section[0]).section[1] let prev_group = section[0] endfor + call self.refresh_separator_highlights() return line endfunction From af7dfc8677c94df3db636a666e2ed8d13e392194 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Fri, 16 Aug 2013 01:42:30 +0000 Subject: [PATCH 05/18] update separator colors when mode changes --- autoload/airline.vim | 13 ++++++++----- autoload/airline/builder.vim | 11 +++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 7a87cf62..5a2dc855 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -39,6 +39,7 @@ function! airline#load_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#update_statusline() call airline#reload_highlight() call airline#update_highlight() endfunction @@ -55,9 +56,9 @@ function! airline#highlight(modes) endfor endif endfor - if exists('w:airline_current_builder') - call w:airline_current_builder.refresh_separator_highlights() - endif + for sep in w:airline_current_info.separator_groups + call airline#themes#exec_highlight_separator(sep[0], sep[1]) + endfor endfunction " for 7.2 compatibility @@ -74,7 +75,6 @@ endfunction function! airline#get_statusline(winnr, active) let builder = airline#builder#new(a:active) - call setwinvar(a:winnr, 'airline_current_builder', builder) if s:getwinvar(a:winnr, 'airline_render_left', a:active || (!a:active && !g:airline_inactive_collapse)) call builder.add_section('Al2', s:get_section(a:winnr, 'a').'%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}') @@ -94,7 +94,10 @@ function! airline#get_statusline(winnr, active) call builder.add_raw('%)') endif endif - return builder.build() + + let info = builder.build() + call setwinvar(a:winnr, 'airline_current_info', info) + return info.statusline endfunction function! airline#exec_funcrefs(list, break_early) diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index ced5f032..0a48e600 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -4,7 +4,6 @@ function! airline#builder#new(active) let builder = {} let builder._sections = [] - let builder._separator_groups = [] let builder._active = a:active function! builder.split(gutter) @@ -33,6 +32,7 @@ function! airline#builder#new(active) let line = '%{airline#update_highlight()}' let side = 0 let prev_group = '' + let separator_groups = [] for section in self._sections if section[0] == '|' let side = 1 @@ -47,7 +47,7 @@ function! airline#builder#new(active) if prev_group != '' let sep = side == 0 ? [section[0], prev_group] : [prev_group, section[0]] - call add(self._separator_groups, sep) + call add(separator_groups, sep) let line .= side == 0 \ ? self._group(section[0].'_to_'.prev_group) \ : self._group(prev_group.'_to_'.section[0]) @@ -59,8 +59,11 @@ function! airline#builder#new(active) let line .= self._group(section[0]).section[1] let prev_group = section[0] endfor - call self.refresh_separator_highlights() - return line + + return { + \ 'statusline': line, + \ 'separator_groups': separator_groups, + \ } endfunction return builder From 0e936d0b9af7533128fb787a13589e2c76c2b15e Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Fri, 16 Aug 2013 01:47:54 +0000 Subject: [PATCH 06/18] introduce util file --- autoload/airline.vim | 20 ++------------------ autoload/airline/extensions.vim | 4 ++-- autoload/airline/util.vim | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 20 deletions(-) create mode 100644 autoload/airline/util.vim diff --git a/autoload/airline.vim b/autoload/airline.vim index 5a2dc855..8be602cd 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -100,24 +100,8 @@ function! airline#get_statusline(winnr, active) return info.statusline 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 -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 @@ -134,7 +118,7 @@ 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 diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 3141dab5..6846eb50 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/util.vim b/autoload/airline/util.vim new file mode 100644 index 00000000..b40b34a2 --- /dev/null +++ b/autoload/airline/util.vim @@ -0,0 +1,18 @@ +" MIT license. Copyright (c) 2013 Bailey Ling. +" vim: ts=2 sts=2 sw=2 fdm=indent + +function! airline#util#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 +endfunction From 30adb973fcba2fba20e34fe910dfa958e52486ea Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Fri, 16 Aug 2013 01:50:24 +0000 Subject: [PATCH 07/18] move getwinvar over --- autoload/airline.vim | 12 +++--------- autoload/airline/util.vim | 6 ++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 8be602cd..53d0d05c 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -61,14 +61,8 @@ function! airline#highlight(modes) endfor endfunction -" for 7.2 compatibility -function! s:getwinvar(winnr, key, ...) - let winvals = getwinvar(a:winnr, '') - return get(winvals, a:key, (a:0 ? a:1 : '')) -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 @@ -76,7 +70,7 @@ endfunction function! airline#get_statusline(winnr, active) let builder = airline#builder#new(a:active) - if s:getwinvar(a:winnr, 'airline_render_left', a:active || (!a:active && !g:airline_inactive_collapse)) + if airline#util#getwinvar(a:winnr, 'airline_render_left', a:active || (!a:active && !g:airline_inactive_collapse)) call builder.add_section('Al2', s:get_section(a:winnr, 'a').'%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}') call builder.add_section('Al4', s:get_section(a:winnr, 'b')) call builder.add_section('Al6', s:get_section(a:winnr, 'c').' %#Al7#%{&ro ? g:airline_readonly_symbol : ""}') @@ -84,7 +78,7 @@ function! airline#get_statusline(winnr, active) call builder.add_section('Al6', '%f%m') endif call builder.split(s:get_section(a:winnr, 'gutter', '', '')) - if s:getwinvar(a:winnr, 'airline_render_right', 1) + if airline#util#getwinvar(a:winnr, 'airline_render_right', 1) call builder.add_section('Al6', s:get_section(a:winnr, 'x')) call builder.add_section('Al4', s:get_section(a:winnr, 'y')) call builder.add_section('Al2', s:get_section(a:winnr, 'z')) diff --git a/autoload/airline/util.vim b/autoload/airline/util.vim index b40b34a2..8372d99d 100644 --- a/autoload/airline/util.vim +++ b/autoload/airline/util.vim @@ -1,6 +1,12 @@ " MIT license. Copyright (c) 2013 Bailey Ling. " vim: ts=2 sts=2 sw=2 fdm=indent +" for 7.2 compatibility +function! airline#util#getwinvar(winnr, key, ...) + let winvals = getwinvar(a:winnr, '') + return get(winvals, a:key, (a:0 ? a:1 : '')) +endfunction + function! airline#util#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 {} From 6e515a462773f3dc5fb7f78b84ea3c3739382949 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Fri, 16 Aug 2013 02:02:32 +0000 Subject: [PATCH 08/18] remove redundancy from the map --- autoload/airline.vim | 25 ++++++++----------------- autoload/airline/builder.vim | 2 +- autoload/airline/extensions/ctrlp.vim | 6 +++--- autoload/airline/themes.vim | 12 +++++------- 4 files changed, 17 insertions(+), 28 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 53d0d05c..5edbbcd3 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -4,15 +4,6 @@ let s:is_win32term = (has('win32') || has('win64')) && !has('gui_running') let s:sections = ['a','b','c','gutter','x','y','z','warning'] -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 @@ -52,7 +43,7 @@ function! airline#highlight(modes) 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) + call airline#exec_highlight(key.suffix, colors) endfor endif endfor @@ -71,17 +62,17 @@ function! airline#get_statusline(winnr, active) let builder = airline#builder#new(a:active) if airline#util#getwinvar(a:winnr, 'airline_render_left', a:active || (!a:active && !g:airline_inactive_collapse)) - call builder.add_section('Al2', s:get_section(a:winnr, 'a').'%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}') - call builder.add_section('Al4', s:get_section(a:winnr, 'b')) - call builder.add_section('Al6', s:get_section(a:winnr, 'c').' %#Al7#%{&ro ? g:airline_readonly_symbol : ""}') + call builder.add_section('a', s:get_section(a:winnr, 'a').'%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}') + call builder.add_section('b', s:get_section(a:winnr, 'b')) + call builder.add_section('c', s:get_section(a:winnr, 'c').' %#airline_file#%{&ro ? g:airline_readonly_symbol : ""}') else - call builder.add_section('Al6', '%f%m') + call builder.add_section('c', '%f%m') endif call builder.split(s:get_section(a:winnr, 'gutter', '', '')) if airline#util#getwinvar(a:winnr, 'airline_render_right', 1) - call builder.add_section('Al6', s:get_section(a:winnr, 'x')) - call builder.add_section('Al4', s:get_section(a:winnr, 'y')) - call builder.add_section('Al2', s:get_section(a:winnr, 'z')) + call builder.add_section('c', s:get_section(a:winnr, 'x')) + call builder.add_section('b', s:get_section(a:winnr, 'y')) + call builder.add_section('a', s:get_section(a:winnr, 'z')) if a:active call builder.add_raw('%(') call builder.add_section('warningmsg', s:get_section(a:winnr, 'warning', '', '')) diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index 0a48e600..89f4002a 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -11,7 +11,7 @@ function! airline#builder#new(active) endfunction function! builder.add_section(group, contents) - call add(self._sections, [a:group, a:contents]) + call add(self._sections, ['airline_'.a:group, a:contents]) endfunction function! builder.add_raw(text) diff --git a/autoload/airline/extensions/ctrlp.vim b/autoload/airline/extensions/ctrlp.vim index d17ce2f9..3b388b31 100644 --- a/autoload/airline/extensions/ctrlp.vim +++ b/autoload/airline/extensions/ctrlp.vim @@ -17,9 +17,9 @@ 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]) diff --git a/autoload/airline/themes.vim b/autoload/airline/themes.vim index 5116139f..5cfa777c 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 From c017c9fbb3d509ae30b3f034f89f88cfa9085746 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Fri, 16 Aug 2013 02:17:59 +0000 Subject: [PATCH 09/18] miscellaneous minor changes --- autoload/airline.vim | 12 ++++++------ autoload/airline/builder.vim | 2 +- autoload/airline/extensions/bufferline.vim | 2 +- autoload/airline/extensions/csv.vim | 4 ++-- plugin/airline.vim | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 5edbbcd3..9e6b3a34 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -21,8 +21,8 @@ function! airline#exec_highlight(group, colors) endfunction function! airline#reload_highlight() - call airline#highlight(['inactive']) - call airline#highlight(['normal']) + call s:highlight(['inactive']) + call s:highlight(['normal']) call airline#extensions#load_theme() endfunction @@ -32,10 +32,10 @@ function! airline#load_theme(name) let w:airline_lastmode = '' call airline#update_statusline() call airline#reload_highlight() - call airline#update_highlight() + call airline#check_mode() endfunction -function! airline#highlight(modes) +function! s: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 @@ -108,7 +108,7 @@ function! airline#update_statusline() 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" @@ -131,7 +131,7 @@ function! airline#update_highlight() let mode_string = join(l:mode) if get(w:, 'airline_lastmode', '') != mode_string - call airline#highlight(l:mode) + call s:highlight(l:mode) let w:airline_lastmode = mode_string endif return '' diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index 89f4002a..d461d3c5 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -29,7 +29,7 @@ function! airline#builder#new(active) endfunction function! builder.build() - let line = '%{airline#update_highlight()}' + let line = '%{airline#check_mode()}' let side = 0 let prev_group = '' let separator_groups = [] diff --git a/autoload/airline/extensions/bufferline.vim b/autoload/airline/extensions/bufferline.vim index 9a863e1a..c95cdf3f 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 c1de708b..b0402a06 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/plugin/airline.vim b/plugin/airline.vim index b514d2bd..6b5965c0 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -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', From 2f92346194efdbe78bfb011a1bbf113a1e696805 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sat, 17 Aug 2013 12:50:07 +0000 Subject: [PATCH 10/18] add highlighter class --- autoload/airline.vim | 54 ++++++++------------------ autoload/airline/builder.vim | 23 +++++------ autoload/airline/extensions/ctrlp.vim | 2 +- autoload/airline/highlighter.vim | 56 +++++++++++++++++++++++++++ autoload/airline/themes.vim | 10 ----- plugin/airline.vim | 2 +- 6 files changed, 84 insertions(+), 63 deletions(-) create mode 100644 autoload/airline/highlighter.vim diff --git a/autoload/airline.vim b/autoload/airline.vim index 9e6b3a34..fb82d110 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -1,28 +1,16 @@ " MIT License. Copyright (c) 2013 Bailey Ling. -" vim: ts=2 sts=2 sw=2 fdm=indent +" vim: et ts=2 sts=2 sw=2 fdm=indent -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() -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] : '') +function! airline#get_highlighter() + return s:highlighter endfunction function! airline#reload_highlight() - call s:highlight(['inactive']) - call s:highlight(['normal']) + call s:highlighter.highlight(['inactive']) + call s:highlighter.highlight(['normal']) call airline#extensions#load_theme() endfunction @@ -35,22 +23,6 @@ function! airline#load_theme(name) call airline#check_mode() endfunction -function! s: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(key.suffix, colors) - endfor - endif - endfor - for sep in w:airline_current_info.separator_groups - call airline#themes#exec_highlight_separator(sep[0], sep[1]) - endfor -endfunction function! s:get_section(winnr, key, ...) let text = airline#util#getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key}) @@ -59,7 +31,7 @@ function! s:get_section(winnr, key, ...) endfunction function! airline#get_statusline(winnr, active) - let builder = airline#builder#new(a:active) + let builder = airline#builder#new(a:active, s:highlighter) if airline#util#getwinvar(a:winnr, 'airline_render_left', a:active || (!a:active && !g:airline_inactive_collapse)) call builder.add_section('a', s:get_section(a:winnr, 'a').'%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}') @@ -68,7 +40,9 @@ function! airline#get_statusline(winnr, active) else call builder.add_section('c', '%f%m') endif + call builder.split(s:get_section(a:winnr, 'gutter', '', '')) + if airline#util#getwinvar(a:winnr, 'airline_render_right', 1) call builder.add_section('c', s:get_section(a:winnr, 'x')) call builder.add_section('b', s:get_section(a:winnr, 'y')) @@ -126,12 +100,16 @@ function! airline#check_mode() 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 s:highlight(l:mode) + call s:highlighter.highlight(l:mode) let w:airline_lastmode = mode_string endif return '' diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index d461d3c5..db590d8a 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -1,10 +1,11 @@ " MIT license. Copyright (c) 2013 Bailey Ling. -" vim: ts=2 sts=2 sw=2 fdm=indent +" vim: et ts=2 sts=2 sw=2 fdm=indent -function! airline#builder#new(active) +function! airline#builder#new(active, highlighter) let builder = {} let builder._sections = [] let builder._active = a:active + let builder._highlighter = a:highlighter function! builder.split(gutter) call add(self._sections, ['|', a:gutter]) @@ -18,14 +19,8 @@ function! airline#builder#new(active) call add(self._sections, ['_', a:text]) endfunction - function! builder.refresh_separator_highlights() - for sep in self._separator_groups - call airline#themes#exec_highlight_separator(sep[0], sep[1]) - endfor - endfunction - function! builder._group(group) - return '%#' . (self._active ? a:group : a:group.'_inactive') . '#' + return self._active ? a:group : a:group.'_inactive' endfunction function! builder.build() @@ -46,17 +41,19 @@ function! airline#builder#new(active) endif if prev_group != '' - let sep = side == 0 ? [section[0], prev_group] : [prev_group, section[0]] + let sep = side == 0 + \ ? [self._group(section[0]), self._group(prev_group)] + \ : [self._group(prev_group), self._group(section[0])] call add(separator_groups, sep) let line .= side == 0 - \ ? self._group(section[0].'_to_'.prev_group) - \ : self._group(prev_group.'_to_'.section[0]) + \ ? '%#'.self._group(section[0].'_to_'.prev_group).'#' + \ : '%#'.self._group(prev_group.'_to_'.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 line .= '%#'.self._group(section[0]).'#'.section[1] let prev_group = section[0] endfor diff --git a/autoload/airline/extensions/ctrlp.vim b/autoload/airline/extensions/ctrlp.vim index 3b388b31..738faff0 100644 --- a/autoload/airline/extensions/ctrlp.vim +++ b/autoload/airline/extensions/ctrlp.vim @@ -22,7 +22,7 @@ function! airline#extensions#ctrlp#load_theme() \ 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 00000000..284ab511 --- /dev/null +++ b/autoload/airline/highlighter.vim @@ -0,0 +1,56 @@ +" MIT license. Copyright (c) 2013 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 fdm=indent + +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, + \ 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#highlighter#exec_separator(from, to) + if a:from == a:to + return a:from + endif + 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#highlighter#exec(group, [ l:to[1], l:from[1], l:to[3], l:from[3] ]) + return group +endfunction + + +function! airline#highlighter#new() + let highlighter = {} + + 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}') + for key in keys(g:airline#themes#{g:airline_theme}#{mode}) + let colors = g:airline#themes#{g:airline_theme}#{mode}[key] + call airline#highlighter#exec(key.suffix, colors) + endfor + endif + endfor + for sep in w:airline_current_info.separator_groups + call airline#highlighter#exec_separator(sep[0].suffix, sep[1].suffix) + endfor + endfunction + + return highlighter +endfunction + diff --git a/autoload/airline/themes.vim b/autoload/airline/themes.vim index 5cfa777c..9f385d9d 100644 --- a/autoload/airline/themes.vim +++ b/autoload/airline/themes.vim @@ -54,13 +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) - if a:from == a:to - return a:from - endif - 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/plugin/airline.vim b/plugin/airline.vim index 6b5965c0..a9eda5ac 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 fdm=indent if &cp || v:version < 702 || (exists('g:loaded_airline') && g:loaded_airline) finish From 47bfeee3ae53f7666cb2e8a0291f52c05ff7fa29 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sat, 17 Aug 2013 15:12:01 +0000 Subject: [PATCH 11/18] fix separator colors for inactive splits --- README.md | 2 +- autoload/airline.vim | 5 ----- autoload/airline/builder.vim | 11 +++-------- autoload/airline/highlighter.vim | 24 +++++++++++++++--------- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index fc21bb75..c1b3ab63 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 fb82d110..013a446a 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -4,10 +4,6 @@ let s:sections = ['a','b','c','gutter','x','y','z','warning'] let s:highlighter = airline#highlighter#new() -function! airline#get_highlighter() - return s:highlighter -endfunction - function! airline#reload_highlight() call s:highlighter.highlight(['inactive']) call s:highlighter.highlight(['normal']) @@ -23,7 +19,6 @@ function! airline#load_theme(name) call airline#check_mode() endfunction - function! s:get_section(winnr, 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, ' %)')] diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index db590d8a..1332b049 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -27,7 +27,6 @@ function! airline#builder#new(active, highlighter) let line = '%{airline#check_mode()}' let side = 0 let prev_group = '' - let separator_groups = [] for section in self._sections if section[0] == '|' let side = 1 @@ -41,13 +40,10 @@ function! airline#builder#new(active, highlighter) endif if prev_group != '' - let sep = side == 0 - \ ? [self._group(section[0]), self._group(prev_group)] - \ : [self._group(prev_group), self._group(section[0])] - call add(separator_groups, sep) + call self._highlighter.add_separator(self._group(prev_group), self._group(section[0])) let line .= side == 0 - \ ? '%#'.self._group(section[0].'_to_'.prev_group).'#' - \ : '%#'.self._group(prev_group.'_to_'.section[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 @@ -59,7 +55,6 @@ function! airline#builder#new(active, highlighter) return { \ 'statusline': line, - \ 'separator_groups': separator_groups, \ } endfunction diff --git a/autoload/airline/highlighter.vim b/autoload/airline/highlighter.vim index 284ab511..016192e1 100644 --- a/autoload/airline/highlighter.vim +++ b/autoload/airline/highlighter.vim @@ -10,13 +10,13 @@ function! airline#highlighter#exec(group, colors) 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] : '') + \ 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! airline#highlighter#exec_separator(from, to) @@ -30,9 +30,13 @@ function! airline#highlighter#exec_separator(from, to) return group endfunction - function! airline#highlighter#new() let highlighter = {} + let highlighter._separators = [] + + function! highlighter.add_separator(from, to) + call add(self._separators, [a:from, a:to]) + endfunction function! highlighter.highlight(modes) " draw the base mode, followed by any overrides @@ -46,7 +50,9 @@ function! airline#highlighter#new() endfor endif endfor - for sep in w:airline_current_info.separator_groups + + " synchronize separator colors + for sep in self._separators call airline#highlighter#exec_separator(sep[0].suffix, sep[1].suffix) endfor endfunction From 3fbdd28e5d41ac89b63609b38012b58e1679a114 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sat, 17 Aug 2013 17:35:06 +0000 Subject: [PATCH 12/18] add profiler. optimize separator highlighting. --- autoload/airline.vim | 12 ++++---- autoload/airline/debug.vim | 15 ++++++++++ autoload/airline/highlighter.vim | 40 ++++++++++++++++----------- autoload/airline/themes/solarized.vim | 2 +- autoload/airline/themes/tomorrow.vim | 2 +- autoload/airline/util.vim | 5 ++-- plugin/airline.vim | 9 +++--- 7 files changed, 55 insertions(+), 30 deletions(-) create mode 100644 autoload/airline/debug.vim diff --git a/autoload/airline.vim b/autoload/airline.vim index 013a446a..14a061e8 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -1,21 +1,20 @@ " MIT License. Copyright (c) 2013 Bailey Ling. -" vim: et ts=2 sts=2 sw=2 fdm=indent +" vim: et ts=2 sts=2 sw=2 let s:sections = ['a','b','c','gutter','x','y','z','warning'] let s:highlighter = airline#highlighter#new() -function! airline#reload_highlight() - call s:highlighter.highlight(['inactive']) - call s:highlighter.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#update_statusline() - call airline#reload_highlight() + call airline#load_theme() call airline#check_mode() endfunction @@ -109,3 +108,4 @@ function! airline#check_mode() endif return '' endfunction + diff --git a/autoload/airline/debug.vim b/autoload/airline/debug.vim new file mode 100644 index 00000000..4e13e9ff --- /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, 50) + wincmd w + redrawstatus + endfor + profile pause + noautocmd qall! +endfunction diff --git a/autoload/airline/highlighter.vim b/autoload/airline/highlighter.vim index 016192e1..f985e8d7 100644 --- a/autoload/airline/highlighter.vim +++ b/autoload/airline/highlighter.vim @@ -1,5 +1,5 @@ -" MIT license. Copyright (c) 2013 Bailey Ling. -" vim: et 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') @@ -19,20 +19,25 @@ function! airline#highlighter#exec(group, colors) \ get(colors, 4, '') != '' ? 'term='.colors[4] : '') endfunction -function! airline#highlighter#exec_separator(from, to) - if a:from == a:to - return a:from - endif +function! airline#highlighter#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 - call airline#highlighter#exec(group, [ l:to[1], l:from[1], l:to[3], l:from[3] ]) - return group + 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._init_separators = {} + + function! highlighter.load_theme() + let self._init_separators = {} + call self.highlight(['inactive']) + call self.highlight(['normal']) + endfunction function! highlighter.add_separator(from, to) call add(self._separators, [a:from, a:to]) @@ -44,16 +49,19 @@ function! airline#highlighter#new() let suffix = a:modes[0] == 'inactive' ? '_inactive' : '' 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] - call airline#highlighter#exec(key.suffix, colors) + let dict = g:airline#themes#{g:airline_theme}#{mode} + for kvp in items(dict) + call airline#highlighter#exec(kvp[0].suffix, kvp[1]) endfor - endif - endfor - " synchronize separator colors - for sep in self._separators - call airline#highlighter#exec_separator(sep[0].suffix, sep[1].suffix) + " initialize separator colors for this mode if necessary + if !has_key(self._init_separators, mode) + let self._init_separators[mode] = 1 + for sep in self._separators + call airline#highlighter#exec_separator(dict, sep[0].suffix, sep[1].suffix) + endfor + endif + endif endfor endfunction diff --git a/autoload/airline/themes/solarized.vim b/autoload/airline/themes/solarized.vim index f6009226..57c82d39 100644 --- a/autoload/airline/themes/solarized.vim +++ b/autoload/airline/themes/solarized.vim @@ -166,5 +166,5 @@ 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 41b90eba..b1f86b8f 100644 --- a/autoload/airline/themes/tomorrow.vim +++ b/autoload/airline/themes/tomorrow.vim @@ -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/util.vim b/autoload/airline/util.vim index 8372d99d..daa3ea85 100644 --- a/autoload/airline/util.vim +++ b/autoload/airline/util.vim @@ -1,5 +1,5 @@ -" 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 " for 7.2 compatibility function! airline#util#getwinvar(winnr, key, ...) @@ -22,3 +22,4 @@ function! airline#util#exec_funcrefs(list, break_early) endfor return 0 endfunction + diff --git a/plugin/airline.vim b/plugin/airline.vim index a9eda5ac..5f8755d8 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -1,5 +1,5 @@ " MIT License. Copyright (c) 2013 Bailey Ling. -" vim: et 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 @@ -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() + From 6bda68e35c5b81af2d0f1bb6869272d5172954fc Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sat, 17 Aug 2013 19:20:40 +0000 Subject: [PATCH 13/18] replace all obsolete color groups in all themes --- autoload/airline/themes/badwolf.vim | 18 ++--- autoload/airline/themes/bubblegum.vim | 16 ++--- autoload/airline/themes/dark.vim | 15 ++-- autoload/airline/themes/jellybeans.vim | 2 +- autoload/airline/themes/laederon.vim | 20 ++---- autoload/airline/themes/light.vim | 15 ++-- autoload/airline/themes/luna.vim | 16 ++--- autoload/airline/themes/molokai.vim | 17 ++--- autoload/airline/themes/powerlineish.vim | 12 ++-- autoload/airline/themes/simple.vim | 90 ++++-------------------- autoload/airline/themes/solarized.vim | 47 +++---------- autoload/airline/themes/tomorrow.vim | 2 +- autoload/airline/themes/ubaryd.vim | 22 +++--- autoload/airline/themes/wombat.vim | 40 ++++------- 14 files changed, 97 insertions(+), 235 deletions(-) diff --git a/autoload/airline/themes/badwolf.vim b/autoload/airline/themes/badwolf.vim index c41c2612..cb82523d 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 8bd9dd8f..ccf6401e 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 af60414c..216299a5 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 792c767e..78c93bab 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 8e18177d..18d72ef5 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 46450f4f..a1e7e985 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 63da2d2b..a945d1a2 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 7fe6feda..1fd480eb 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 93d7ffd9..dcfc0a7c 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 c7c44e06..555b4c4a 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 57c82d39..ca331c02 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,10 +134,8 @@ 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() diff --git a/autoload/airline/themes/tomorrow.vim b/autoload/airline/themes/tomorrow.vim index b1f86b8f..88c38383 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') diff --git a/autoload/airline/themes/ubaryd.vim b/autoload/airline/themes/ubaryd.vim index 608a2f58..8b305532 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 860ccc6e..14365c34 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) From 3814c211251e507bad8da77b406f264c6445f830 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sat, 17 Aug 2013 16:44:53 -0400 Subject: [PATCH 14/18] optimize newing up the builder --- autoload/airline.vim | 4 +- autoload/airline/builder.vim | 108 +++++++++++++++++------------------ 2 files changed, 55 insertions(+), 57 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 14a061e8..14119417 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -48,9 +48,7 @@ function! airline#get_statusline(winnr, active) endif endif - let info = builder.build() - call setwinvar(a:winnr, 'airline_current_info', info) - return info.statusline + return builder.build() endfunction function! airline#update_statusline() diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index 1332b049..d35ae921 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -1,62 +1,62 @@ " MIT license. Copyright (c) 2013 Bailey Ling. -" vim: et ts=2 sts=2 sw=2 fdm=indent +" 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, ['airline_'.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 .= '%#'.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 = {} + let builder = copy(s:prototype) let builder._sections = [] let builder._active = a:active let builder._highlighter = a:highlighter - - function! builder.split(gutter) - call add(self._sections, ['|', a:gutter]) - endfunction - - function! builder.add_section(group, contents) - call add(self._sections, ['airline_'.a:group, a:contents]) - endfunction - - function! builder.add_raw(text) - call add(self._sections, ['_', a:text]) - endfunction - - function! builder._group(group) - return self._active ? a:group : a:group.'_inactive' - endfunction - - function! builder.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 .= '%#'.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 { - \ 'statusline': line, - \ } - endfunction - return builder endfunction + From b19a29675d734eb26e5dc6b990f62cd075f90d3c Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sat, 17 Aug 2013 17:10:06 -0400 Subject: [PATCH 15/18] fix list being unbounded --- autoload/airline/debug.vim | 2 +- autoload/airline/highlighter.vim | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/autoload/airline/debug.vim b/autoload/airline/debug.vim index 4e13e9ff..a1d343fe 100644 --- a/autoload/airline/debug.vim +++ b/autoload/airline/debug.vim @@ -6,7 +6,7 @@ function! airline#debug#profile() profile func * profile file * split - for i in range(1, 50) + for i in range(1, 1000) wincmd w redrawstatus endfor diff --git a/autoload/airline/highlighter.vim b/autoload/airline/highlighter.vim index f985e8d7..b21572eb 100644 --- a/autoload/airline/highlighter.vim +++ b/autoload/airline/highlighter.vim @@ -19,7 +19,7 @@ function! airline#highlighter#exec(group, colors) \ get(colors, 4, '') != '' ? 'term='.colors[4] : '') endfunction -function! airline#highlighter#exec_separator(dict, from, to) +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 @@ -30,17 +30,17 @@ endfunction function! airline#highlighter#new() let highlighter = {} - let highlighter._separators = [] - let highlighter._init_separators = {} + let highlighter._separators = {} + let highlighter._mode_init = {} function! highlighter.load_theme() - let self._init_separators = {} + let self._mode_init = {} call self.highlight(['inactive']) call self.highlight(['normal']) endfunction function! highlighter.add_separator(from, to) - call add(self._separators, [a:from, a:to]) + let self._separators[a:from.a:to] = [a:from, a:to] endfunction function! highlighter.highlight(modes) @@ -55,10 +55,10 @@ function! airline#highlighter#new() endfor " initialize separator colors for this mode if necessary - if !has_key(self._init_separators, mode) - let self._init_separators[mode] = 1 - for sep in self._separators - call airline#highlighter#exec_separator(dict, sep[0].suffix, sep[1].suffix) + 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 From e7c5bbb67178ed8d44537429b43aa42592fdef4e Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sat, 17 Aug 2013 17:39:06 -0400 Subject: [PATCH 16/18] remove auto prefix. optimize getwinvar --- autoload/airline.vim | 16 +++++++++------- autoload/airline/builder.vim | 2 +- autoload/airline/util.vim | 15 ++++++++++----- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 14119417..81e5670f 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -28,19 +28,21 @@ function! airline#get_statusline(winnr, active) let builder = airline#builder#new(a:active, s:highlighter) if airline#util#getwinvar(a:winnr, 'airline_render_left', a:active || (!a:active && !g:airline_inactive_collapse)) - call builder.add_section('a', s:get_section(a:winnr, 'a').'%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}') - call builder.add_section('b', s:get_section(a:winnr, 'b')) - call builder.add_section('c', s:get_section(a:winnr, 'c').' %#airline_file#%{&ro ? g:airline_readonly_symbol : ""}') + 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 - call builder.add_section('c', '%f%m') + call builder.add_section('airline_c', '%f%m') endif call builder.split(s:get_section(a:winnr, 'gutter', '', '')) if airline#util#getwinvar(a:winnr, 'airline_render_right', 1) - call builder.add_section('c', s:get_section(a:winnr, 'x')) - call builder.add_section('b', s:get_section(a:winnr, 'y')) - call builder.add_section('a', s:get_section(a:winnr, 'z')) + 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 call builder.add_raw('%(') call builder.add_section('warningmsg', s:get_section(a:winnr, 'warning', '', '')) diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index d35ae921..2e8226d4 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -8,7 +8,7 @@ function! s:prototype.split(gutter) endfunction function! s:prototype.add_section(group, contents) - call add(self._sections, ['airline_'.a:group, a:contents]) + call add(self._sections, [a:group, a:contents]) endfunction function! s:prototype.add_raw(text) diff --git a/autoload/airline/util.vim b/autoload/airline/util.vim index daa3ea85..483b1e2a 100644 --- a/autoload/airline/util.vim +++ b/autoload/airline/util.vim @@ -1,11 +1,16 @@ " MIT License. Copyright (c) 2013 Bailey Ling. " vim: et ts=2 sts=2 sw=2 -" for 7.2 compatibility -function! airline#util#getwinvar(winnr, key, ...) - let winvals = getwinvar(a:winnr, '') - return get(winvals, a:key, (a:0 ? a:1 : '')) -endfunction +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 function! airline#util#exec_funcrefs(list, break_early) " for 7.2; we cannot iterate list, hence why we use range() From 840f78607ee4bc1f370098e46be6e02985dab007 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sat, 17 Aug 2013 17:50:41 -0400 Subject: [PATCH 17/18] optimize funcrefs for 7.4 --- autoload/airline/util.vim | 42 ++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/autoload/airline/util.vim b/autoload/airline/util.vim index 483b1e2a..9311111b 100644 --- a/autoload/airline/util.vim +++ b/autoload/airline/util.vim @@ -12,19 +12,33 @@ else endfunction endif -function! airline#util#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 +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 - else - call Fn{i}() - endif - endfor - return 0 -endfunction + 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 From f938159d0d5a70461edb242010b8af8cd271b3f2 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sat, 17 Aug 2013 22:03:50 +0000 Subject: [PATCH 18/18] fix inactive responding to modified, fix trimming --- autoload/airline.vim | 2 +- autoload/airline/builder.vim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 81e5670f..777b2d7c 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -31,7 +31,7 @@ function! airline#get_statusline(winnr, active) 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') + call builder.add_section('airline_c', '%<'.s:get_section(a:winnr, 'c') \ .'%#airline_file#%{&ro ? g:airline_readonly_symbol : ""}') else call builder.add_section('airline_c', '%f%m') diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index 2e8226d4..0cba4464 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -26,7 +26,7 @@ function! s:prototype.build() for section in self._sections if section[0] == '|' let side = 1 - let line .= '%#'.prev_group.'#'.section[1] + let line .= '%#'.self._group(prev_group).'#'.section[1] let prev_group = '' continue endif