From 30bcbfc7e6b72cf3936ffcf38e2138e3914e51d0 Mon Sep 17 00:00:00 2001 From: ManjaroOne666 Date: Tue, 17 Apr 2018 18:18:15 +0100 Subject: [PATCH] initial commit - custom tabline --- vimrc.d/tabline.vim | 69 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 vimrc.d/tabline.vim diff --git a/vimrc.d/tabline.vim b/vimrc.d/tabline.vim new file mode 100644 index 0000000..3027250 --- /dev/null +++ b/vimrc.d/tabline.vim @@ -0,0 +1,69 @@ +if exists("+showtabline") + +" Rename tabs to show tab number. +" based on: +" http://stackoverflow.com/questions/5927952/whats-implementation-of-vims-default-tabline-function + +function! MyTabLine() + let s = '' + let t = tabpagenr() + let i = 1 + while i <= tabpagenr('$') + let buflist = tabpagebuflist(i) + let winnr = tabpagewinnr(i) + let s .= '%' . i . 'T' + let s .= (i == t ? '%1*' : '%2*') + + let s .= (i == t ? '%#TabNumSel#' : '%#TabNum#') + let s .= i + let s .= '%#TabSeparator#:' + let s .= (i == t ? '%#TabLineItemSel#' : '%#TabLineItem#') + + let bufnr = buflist[winnr - 1] + let file = bufname(bufnr) + let buftype = getbufvar(bufnr, '&buftype') + + if buftype == 'help' + let file = 'help:' . fnamemodify(file, ':t:r') + + elseif buftype == 'quickfix' + let file = 'quickfix' + + elseif buftype == 'nofile' + if file =~ '\/.' + let file = substitute(file, '.*\/\ze.', '', '') + endif + + else + let file = pathshorten(fnamemodify(file, ':p:~:.')) + + endif + + if file == '' + let file = '[]' + endif + + let s .= file . ' ' + + let i = i + 1 + + endwhile + + let s .= '%T%#TabLineFill#%=' + let s .= '%#TabSeparator#"%#TabLineItemSel#%{v:register}%#TabSeparator#" ' + let s .= " %#TabLineItemSel#%{ObsessionStatus(fnamemodify(v:this_session,':t'),'---')} %*" + + return s + +endfunction + +highlight def link TabNum Comment +highlight def link TabNumSel String +highlight def link TabSeparator Comment +highlight def link TabLineItem Comment +highlight def link TabLineItemSel String + +set showtabline=2 +set tabline=%!MyTabLine() + +endif " exists("+showtabline")