70 lines
1.8 KiB
VimL
70 lines
1.8 KiB
VimL
" Rename tabs to show tab number.
|
|
" based on:
|
|
" http://stackoverflow.com/questions/5927952/whats-implementation-of-vims-default-tabline-function
|
|
|
|
function! MyTabLine() "{{{
|
|
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 ? '%#TabLineNumSel#' : '%#TabLineNum#')
|
|
let l:customtabline .= ' ' . l:tabnumber . ' '
|
|
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.', '', '')
|
|
endif
|
|
|
|
else
|
|
let l:file = fnamemodify(l:file, ':p:t')
|
|
|
|
endif
|
|
|
|
if l:file ==# ''
|
|
let l:file = "''"
|
|
endif
|
|
|
|
let l:customtabline .= l:file . ' '
|
|
|
|
let l:tabnumber = l:tabnumber + 1
|
|
|
|
endwhile
|
|
|
|
let l:customtabline .= '%T%#TabLineFill#%='
|
|
|
|
let l:customtabline .= '%#TabLineItem# %{getcwd()}% '
|
|
if exists('*ObsessionStatus')
|
|
let l:customtabline .= "%#TabLineItem# %{ObsessionStatus(fnamemodify(v:this_session,':t'),'---')} %*"
|
|
endif
|
|
|
|
return l:customtabline
|
|
|
|
endfunction
|
|
"}}}
|
|
|
|
set tabline=%!MyTabLine()
|
|
set showtabline=2
|
|
|
|
|
|
" vim: set foldmethod=marker:
|