ctrlspace: refactor s:variables

This commit is contained in:
Christian Brabandt 2018-01-04 17:27:34 +01:00
parent a25757ac64
commit 45236ba7c7
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09

View File

@ -7,12 +7,6 @@ let s:current_bufnr = -1
let s:current_tabnr = -1 let s:current_tabnr = -1
let s:current_tabline = '' 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() function! airline#extensions#tabline#ctrlspace#off()
augroup airline_tabline_ctrlspace augroup airline_tabline_ctrlspace
autocmd! autocmd!
@ -107,6 +101,9 @@ endfunction
function! airline#extensions#tabline#ctrlspace#get() function! airline#extensions#tabline#ctrlspace#get()
let cur_buf = bufnr('%') 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() call airline#extensions#tabline#tabs#map_keys()
let s:tab_list = ctrlspace#api#TabList() let s:tab_list = ctrlspace#api#TabList()
@ -123,24 +120,24 @@ function! airline#extensions#tabline#ctrlspace#get()
let builder = airline#extensions#tabline#new_builder() let builder = airline#extensions#tabline#new_builder()
" Add left tabline content " 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) 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) " add by tenfy(tenfyzhong@qq.com)
" if current buffer no in the buffer list, does't update tabline " 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 if airline#extensions#tabline#ctrlspace#add_buffer_section(builder, cur_tab, cur_buf, 0) == 0
return s:current_tabline return s:current_tabline
endif endif
else else
if s:switch_buffers_and_tabs == 0 if switch_buffers_and_tabs == 0
call builder.add_section_spaced('airline_tabtype', s:buffers_label) call builder.add_section_spaced('airline_tabtype', buffer_label)
" add by tenfy(tenfyzhong@qq.com) " add by tenfy(tenfyzhong@qq.com)
" if current buffer no in the buffer list, does't update tabline " 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 if airline#extensions#tabline#ctrlspace#add_buffer_section(builder, cur_tab, cur_buf, 0) == 0
return s:current_tabline return s:current_tabline
endif endif
else 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) call airline#extensions#tabline#ctrlspace#add_tab_section(builder, 0)
endif endif
endif endif
@ -150,21 +147,21 @@ function! airline#extensions#tabline#ctrlspace#get()
call builder.add_section('airline_tabfill', '') call builder.add_section('airline_tabfill', '')
" Add right tabline content " Add right tabline content
if s:show_buffers == 0 if get(g:, 'airline#extensions#tabline#show_buffers', 1) == 0
call builder.add_section_spaced('airline_tabtype', s:tabs_label) call builder.add_section_spaced('airline_tabtype', tab_label)
elseif s:show_tabs == 0 elseif get(g:, 'airline#extensions#tabline#show_tabs', 1) == 0
call builder.add_section_spaced('airline_tabtype', s:buffers_label) call builder.add_section_spaced('airline_tabtype', buffer_label)
else 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 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 else
" add by tenfy(tenfyzhong@qq.com) " add by tenfy(tenfyzhong@qq.com)
" if current buffer no in the buffer list, does't update tabline " 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 if airline#extensions#tabline#ctrlspace#add_buffer_section(builder, cur_tab, cur_buf, 0) == 0
return s:current_tabline return s:current_tabline
endif endif
call builder.add_section_spaced('airline_tabtype', s:buffers_label) call builder.add_section_spaced('airline_tabtype', buffer_label)
endif endif
endif endif