2018-05-01 21:53:07 +00:00
|
|
|
if exists('+showtabline')
|
2018-04-17 17:18:15 +00:00
|
|
|
|
2018-04-17 19:44:45 +00:00
|
|
|
" Rename tabs to show tab number.
|
|
|
|
" based on:
|
|
|
|
" http://stackoverflow.com/questions/5927952/whats-implementation-of-vims-default-tabline-function
|
2018-04-17 17:18:15 +00:00
|
|
|
|
2018-04-17 19:44:45 +00:00
|
|
|
function! MyTabLine()
|
2018-05-01 21:53:07 +00:00
|
|
|
let l:customtabline = ''
|
|
|
|
let l:currenttabnum = tabpagenr()
|
|
|
|
let l:lasttabnumber = tabpagenr('$')
|
|
|
|
let l:tabnumber = 1
|
|
|
|
while l:tabnumber <= l:lasttabnumber
|
|
|
|
let l:buflist = tabpagebuflist(l:tabnumber)
|
|
|
|
let l:winnr = tabpagewinnr(l:tabnumber)
|
|
|
|
|
|
|
|
if l:lasttabnumber > 1
|
|
|
|
let l:customtabline .= '%' . l:tabnumber . 'T'
|
|
|
|
let l:customtabline .= (l:tabnumber == l:currenttabnum ? '%1*' : '%2*')
|
|
|
|
|
|
|
|
let l:customtabline .= (l:tabnumber == l:currenttabnum ? '%#TabNumSel#' : '%#TabNum#')
|
|
|
|
let l:customtabline .= ' ' . l:tabnumber
|
|
|
|
let l:customtabline .= '%#TabSeparator#:'
|
|
|
|
let l:customtabline .= (l:tabnumber == l:currenttabnum ? '%#TabLineItemSel#' : '%#TabLineItem#')
|
|
|
|
endif
|
|
|
|
|
|
|
|
let l:bufnr = l:buflist[l:winnr - 1]
|
|
|
|
let l:file = bufname(l:bufnr)
|
|
|
|
let l:buftype = getbufvar(l:bufnr, '&buftype')
|
|
|
|
|
|
|
|
if l:buftype ==# 'help'
|
|
|
|
let l:file = 'help:' . fnamemodify(l:file, ':t:r')
|
|
|
|
|
|
|
|
elseif l:buftype ==# 'quickfix'
|
|
|
|
let l:file = 'quickfix'
|
|
|
|
|
|
|
|
elseif l:buftype ==# 'nofile'
|
|
|
|
if l:file =~# '\/.'
|
|
|
|
let l:file = substitute(l:file, '.*\/\ze.', '', '')
|
2018-04-17 19:44:45 +00:00
|
|
|
endif
|
2018-04-17 17:18:15 +00:00
|
|
|
|
2018-04-17 19:44:45 +00:00
|
|
|
else
|
2018-05-01 21:53:07 +00:00
|
|
|
let l:file = fnamemodify(l:file, ':p:t')
|
2018-04-17 17:18:15 +00:00
|
|
|
|
2018-04-17 19:44:45 +00:00
|
|
|
endif
|
2018-04-17 17:18:15 +00:00
|
|
|
|
2018-05-01 21:53:07 +00:00
|
|
|
if l:file ==# ''
|
|
|
|
let l:file = "''"
|
2018-04-17 19:44:45 +00:00
|
|
|
endif
|
2018-04-17 17:18:15 +00:00
|
|
|
|
2018-05-07 22:49:02 +00:00
|
|
|
let l:customtabline .= l:file . ' %#TabLineNoise# '
|
2018-04-17 17:18:15 +00:00
|
|
|
|
2018-05-01 21:53:07 +00:00
|
|
|
let l:tabnumber = l:tabnumber + 1
|
2018-04-17 17:18:15 +00:00
|
|
|
|
|
|
|
endwhile
|
|
|
|
|
2018-05-01 21:53:07 +00:00
|
|
|
let l:customtabline .= '%T%#TabLineFill#%='
|
2018-05-20 15:30:48 +00:00
|
|
|
let l:customtabline .= '%#TabLineItemSel# %{fugitive#statusline()}%#TabSeparator# '
|
|
|
|
let l:customtabline .= '%#TabLineNoise# '
|
2018-05-07 22:49:02 +00:00
|
|
|
let l:customtabline .= '%#TabLineNoise# '
|
2018-05-20 15:46:30 +00:00
|
|
|
" let l:customtabline .= '%#TabSeparator# "%#TabLineItemSel#%{v:register}%#TabSeparator#" '
|
|
|
|
" let l:customtabline .= '%#TabLineNoise# '
|
2018-05-01 21:53:07 +00:00
|
|
|
let l:customtabline .= "%#TabLineItemSel# %{ObsessionStatus(fnamemodify(v:this_session,':t'),'---')} %*"
|
2018-04-17 17:18:15 +00:00
|
|
|
|
2018-05-01 21:53:07 +00:00
|
|
|
return l:customtabline
|
2018-04-17 17:18:15 +00:00
|
|
|
|
2018-04-17 19:44:45 +00:00
|
|
|
endfunction
|
2018-04-17 17:18:15 +00:00
|
|
|
|
2018-04-17 19:44:45 +00:00
|
|
|
set showtabline=2
|
|
|
|
set tabline=%!MyTabLine()
|
2018-04-17 17:18:15 +00:00
|
|
|
|
|
|
|
endif " exists("+showtabline")
|