mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-23 07:59:33 +08:00
ctrlspace: refactor s:variables
This commit is contained in:
parent
a25757ac64
commit
45236ba7c7
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user