From 45236ba7c7aa3df952702cb05aa53d6fdd86f927 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Thu, 4 Jan 2018 17:27:34 +0100 Subject: [PATCH] ctrlspace: refactor s:variables --- .../airline/extensions/tabline/ctrlspace.vim | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/autoload/airline/extensions/tabline/ctrlspace.vim b/autoload/airline/extensions/tabline/ctrlspace.vim index b509f0d..c2bb87a 100644 --- a/autoload/airline/extensions/tabline/ctrlspace.vim +++ b/autoload/airline/extensions/tabline/ctrlspace.vim @@ -7,12 +7,6 @@ let s:current_bufnr = -1 let s:current_tabnr = -1 let s:current_tabline = '' -let s:buffers_label = get(g:, 'airline#extensions#tabline#buffers_label', 'buffers') -let s:tabs_label = get(g:, 'airline#extensions#tabline#tabs_label', 'tabs') -let s:switch_buffers_and_tabs = get(g:, 'airline#extensions#tabline#switch_buffers_and_tabs', 0) -let s:show_buffers = get(g:, 'airline#extensions#tabline#show_buffers', 1) -let s:show_tabs = get(g:, 'airline#extensions#tabline#show_tabs', 1) - function! airline#extensions#tabline#ctrlspace#off() augroup airline_tabline_ctrlspace autocmd! @@ -107,6 +101,9 @@ endfunction function! airline#extensions#tabline#ctrlspace#get() let cur_buf = bufnr('%') + let buffer_label = get(g:, 'airline#extensions#tabline#buffers_label', 'buffers') + let tab_label = get(g:, 'airline#extensions#tabline#tabs_label', 'tabs') + let switch_buffers_and_tabs = get(g:, 'airline#extensions#tabline#switch_buffers_and_tabs', 0) call airline#extensions#tabline#tabs#map_keys() let s:tab_list = ctrlspace#api#TabList() @@ -123,24 +120,24 @@ function! airline#extensions#tabline#ctrlspace#get() let builder = airline#extensions#tabline#new_builder() " Add left tabline content - if s:show_buffers == 0 + if get(g:, 'airline#extensions#tabline#show_buffers', 1) == 0 call airline#extensions#tabline#ctrlspace#add_tab_section(builder, 0) - elseif s:show_tabs == 0 + elseif get(g:, 'airline#extensions#tabline#show_tabs', 1) == 0 " add by tenfy(tenfyzhong@qq.com) " if current buffer no in the buffer list, does't update tabline if airline#extensions#tabline#ctrlspace#add_buffer_section(builder, cur_tab, cur_buf, 0) == 0 return s:current_tabline endif else - if s:switch_buffers_and_tabs == 0 - call builder.add_section_spaced('airline_tabtype', s:buffers_label) + if switch_buffers_and_tabs == 0 + call builder.add_section_spaced('airline_tabtype', buffer_label) " add by tenfy(tenfyzhong@qq.com) " if current buffer no in the buffer list, does't update tabline if airline#extensions#tabline#ctrlspace#add_buffer_section(builder, cur_tab, cur_buf, 0) == 0 return s:current_tabline endif else - call builder.add_section_spaced('airline_tabtype', s:tabs_label) + call builder.add_section_spaced('airline_tabtype', tab_label) call airline#extensions#tabline#ctrlspace#add_tab_section(builder, 0) endif endif @@ -150,21 +147,21 @@ function! airline#extensions#tabline#ctrlspace#get() call builder.add_section('airline_tabfill', '') " Add right tabline content - if s:show_buffers == 0 - call builder.add_section_spaced('airline_tabtype', s:tabs_label) - elseif s:show_tabs == 0 - call builder.add_section_spaced('airline_tabtype', s:buffers_label) + if get(g:, 'airline#extensions#tabline#show_buffers', 1) == 0 + call builder.add_section_spaced('airline_tabtype', tab_label) + elseif get(g:, 'airline#extensions#tabline#show_tabs', 1) == 0 + call builder.add_section_spaced('airline_tabtype', buffer_label) else - if s:switch_buffers_and_tabs == 0 + if switch_buffers_and_tabs == 0 call airline#extensions#tabline#ctrlspace#add_tab_section(builder, 1) - call builder.add_section_spaced('airline_tabtype', s:tabs_label) + call builder.add_section_spaced('airline_tabtype', tab_label) else " add by tenfy(tenfyzhong@qq.com) " if current buffer no in the buffer list, does't update tabline if airline#extensions#tabline#ctrlspace#add_buffer_section(builder, cur_tab, cur_buf, 0) == 0 return s:current_tabline endif - call builder.add_section_spaced('airline_tabtype', s:buffers_label) + call builder.add_section_spaced('airline_tabtype', buffer_label) endif endif