aboutsummaryrefslogtreecommitdiff
path: root/.vimrc
diff options
context:
space:
mode:
Diffstat (limited to '.vimrc')
-rw-r--r--.vimrc42
1 files changed, 42 insertions, 0 deletions
diff --git a/.vimrc b/.vimrc
index 7d4127d..72bbdb7 100644
--- a/.vimrc
+++ b/.vimrc
@@ -184,3 +184,45 @@ augroup vimrc
" restore statusline highlights on colorscheme update
au Colorscheme * call <SID>StatusLineHighlights()
augroup END
+
+" Setup BufferLine with Tabs
+set showtabline=2
+
+function! SpawnBufferLine()
+ let s = ''
+
+ " Get the list of buffers. Use bufexists() to include hidden buffers
+ let bufferNums = filter(range(1, bufnr('$')), 'buflisted(v:val)')
+ " Making a buffer list on the left side
+ for i in bufferNums
+ " Highlight with yellow if it's the current buffer
+ let s .= (i == bufnr()) ? ('%#TabLineSel#') : ('%#TabLine#')
+ let s .= i . ' ' " Append the buffer number
+ if bufname(i) == ''
+ let s .= '[No Name]' " Give a name to a new buffer
+ endif
+ if getbufvar(i, "&modifiable")
+ let s .= fnamemodify(bufname(i), ':t') " Append the file name
+ " let s .= pathshorten(bufname(i)) " Use this if you want a trimmed path
+ " If the buffer is modified, add + and separator. Else, add separator
+ let s .= (getbufvar(i, "&modified")) ? (' [+] | ') : (' | ')
+ else
+ let s .= fnamemodify(bufname(i), ':t') . ' [RO] | ' " Add read only flag
+ endif
+ endfor
+ let s .= '%#TabLineFill#%T' " Reset highlight
+
+ let s .= '%=' " Spacer
+
+ " Making a tab list on the right side
+ for i in range(1, tabpagenr('$')) " Loop through the number of tabs
+ " Highlight with yellow if it's the current tab
+ let s .= (i == tabpagenr()) ? ('%#TabLineSel#') : ('%#TabLine#')
+ let s .= '%' . i . 'T ' " set the tab page number
+ let s .= i . '' " set page number string
+ endfor
+ let s .= '%#TabLineFill#%T' " Reset highlight
+ return s
+endfunction
+
+set tabline=%!SpawnBufferLine() " Assign the tabline