2016-01-15 02:38:38 +00:00
|
|
|
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
2015-02-19 02:24:05 +00:00
|
|
|
" vim: et ts=2 sts=2 sw=2
|
|
|
|
|
|
|
|
let s:show_close_button = get(g:, 'airline#extensions#tabline#show_close_button', 1)
|
2016-02-21 20:03:55 +00:00
|
|
|
let s:show_tab_type = get(g:, 'airline#extensions#tabline#show_tab_type', 1)
|
2016-02-15 19:01:34 +00:00
|
|
|
let s:show_tab_nr = get(g:, 'airline#extensions#tabline#show_tab_nr', 1)
|
|
|
|
let s:tab_nr_type = get(g:, 'airline#extensions#tabline#tab_nr_type', 0)
|
2015-02-19 02:24:05 +00:00
|
|
|
let s:close_symbol = get(g:, 'airline#extensions#tabline#close_symbol', 'X')
|
2016-02-22 06:32:36 +00:00
|
|
|
let s:tabs_label = get(g:, 'airline#extensions#tabline#tabs_label', 'tabs')
|
2016-02-21 20:03:55 +00:00
|
|
|
let s:show_splits = get(g:, 'airline#extensions#tabline#show_splits', 1)
|
2016-01-28 04:11:11 +00:00
|
|
|
let s:spc = g:airline_symbols.space
|
2015-02-19 02:24:05 +00:00
|
|
|
|
|
|
|
let s:current_bufnr = -1
|
|
|
|
let s:current_tabnr = -1
|
|
|
|
let s:current_modified = 0
|
|
|
|
|
|
|
|
function! airline#extensions#tabline#tabs#off()
|
|
|
|
augroup airline_tabline_tabs
|
|
|
|
autocmd!
|
|
|
|
augroup END
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! airline#extensions#tabline#tabs#on()
|
|
|
|
augroup airline_tabline_tabs
|
|
|
|
autocmd!
|
2015-02-19 02:37:13 +00:00
|
|
|
autocmd BufDelete * call airline#extensions#tabline#tabs#invalidate()
|
2015-02-19 02:24:05 +00:00
|
|
|
augroup END
|
|
|
|
endfunction
|
|
|
|
|
2015-02-19 02:37:13 +00:00
|
|
|
function! airline#extensions#tabline#tabs#invalidate()
|
|
|
|
let s:current_bufnr = -1
|
|
|
|
endfunction
|
|
|
|
|
2015-02-19 02:24:05 +00:00
|
|
|
function! airline#extensions#tabline#tabs#get()
|
|
|
|
let curbuf = bufnr('%')
|
|
|
|
let curtab = tabpagenr()
|
2016-07-03 19:09:42 +00:00
|
|
|
call airline#extensions#tabline#tabs#map_keys()
|
2015-02-19 02:24:05 +00:00
|
|
|
if curbuf == s:current_bufnr && curtab == s:current_tabnr
|
|
|
|
if !g:airline_detect_modified || getbufvar(curbuf, '&modified') == s:current_modified
|
|
|
|
return s:current_tabline
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
let b = airline#extensions#tabline#new_builder()
|
2016-01-28 04:11:11 +00:00
|
|
|
|
2015-02-19 02:24:05 +00:00
|
|
|
for i in range(1, tabpagenr('$'))
|
|
|
|
if i == curtab
|
2016-04-11 22:22:42 +00:00
|
|
|
let group = 'airline_tabsel'
|
2015-02-19 02:24:05 +00:00
|
|
|
if g:airline_detect_modified
|
|
|
|
for bi in tabpagebuflist(i)
|
|
|
|
if getbufvar(bi, '&modified')
|
2016-04-11 22:22:42 +00:00
|
|
|
let group = 'airline_tabmod'
|
2015-02-19 02:24:05 +00:00
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
endif
|
2016-04-11 22:22:42 +00:00
|
|
|
let s:current_modified = (group == 'airline_tabmod') ? 1 : 0
|
2015-02-19 02:24:05 +00:00
|
|
|
else
|
2016-04-11 22:22:42 +00:00
|
|
|
let group = 'airline_tab'
|
2015-02-19 02:24:05 +00:00
|
|
|
endif
|
2016-02-15 19:01:34 +00:00
|
|
|
let val = '%('
|
|
|
|
if s:show_tab_nr
|
|
|
|
if s:tab_nr_type == 0
|
|
|
|
let val .= (g:airline_symbols.space).'%{len(tabpagebuflist('.i.'))}'
|
|
|
|
elseif s:tab_nr_type == 1
|
|
|
|
let val .= (g:airline_symbols.space).i
|
|
|
|
else "== 2
|
|
|
|
let val .= (g:airline_symbols.space).i.'.%{len(tabpagebuflist('.i.'))}'
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
call b.add_section(group, val.'%'.i.'T %{airline#extensions#tabline#title('.i.')} %)')
|
2015-02-19 02:24:05 +00:00
|
|
|
endfor
|
|
|
|
|
2016-02-21 20:03:55 +00:00
|
|
|
call b.add_section('airline_tabfill', '')
|
|
|
|
call b.split()
|
|
|
|
call b.add_section('airline_tabfill', '')
|
|
|
|
|
|
|
|
if s:show_close_button
|
|
|
|
call b.add_section('airline_tab_right', ' %999X'.s:close_symbol.' ')
|
|
|
|
endif
|
|
|
|
|
|
|
|
if s:show_splits == 1
|
|
|
|
let buffers = tabpagebuflist(curtab)
|
|
|
|
for nr in buffers
|
2016-04-11 22:22:42 +00:00
|
|
|
let group = airline#extensions#tabline#group_of_bufnr(buffers, nr) . "_right"
|
2016-02-21 20:03:55 +00:00
|
|
|
call b.add_section_spaced(group, '%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)')
|
|
|
|
endfor
|
|
|
|
elseif s:show_tab_type == 1
|
2016-02-22 06:32:36 +00:00
|
|
|
call b.add_section_spaced('airline_tabtype', s:tabs_label)
|
2016-02-21 20:03:55 +00:00
|
|
|
endif
|
2015-02-19 02:24:05 +00:00
|
|
|
|
|
|
|
let s:current_bufnr = curbuf
|
|
|
|
let s:current_tabnr = curtab
|
|
|
|
let s:current_tabline = b.build()
|
|
|
|
return s:current_tabline
|
|
|
|
endfunction
|
2016-01-20 19:22:12 +00:00
|
|
|
|
2016-07-03 19:09:42 +00:00
|
|
|
function! airline#extensions#tabline#tabs#map_keys()
|
2016-01-20 19:22:12 +00:00
|
|
|
noremap <silent> <Plug>AirlineSelectTab1 :1tabn<CR>
|
|
|
|
noremap <silent> <Plug>AirlineSelectTab2 :2tabn<CR>
|
|
|
|
noremap <silent> <Plug>AirlineSelectTab3 :3tabn<CR>
|
|
|
|
noremap <silent> <Plug>AirlineSelectTab4 :4tabn<CR>
|
|
|
|
noremap <silent> <Plug>AirlineSelectTab5 :5tabn<CR>
|
|
|
|
noremap <silent> <Plug>AirlineSelectTab6 :6tabn<CR>
|
|
|
|
noremap <silent> <Plug>AirlineSelectTab7 :7tabn<CR>
|
|
|
|
noremap <silent> <Plug>AirlineSelectTab8 :8tabn<CR>
|
|
|
|
noremap <silent> <Plug>AirlineSelectTab9 :9tabn<CR>
|
|
|
|
noremap <silent> <Plug>AirlineSelectPrevTab gT
|
|
|
|
" tabn {count} goes to count tab does not go {count} tab pages forward!
|
2016-02-04 18:03:25 +00:00
|
|
|
noremap <silent> <Plug>AirlineSelectNextTab :<C-U>exe repeat(':tabn\|', v:count1)<cr>
|
2016-01-20 19:22:12 +00:00
|
|
|
endfunction
|