1. arsooy
  2. dotfiles

Commits

arsooy  committed a0db968

Changes to make vim tab more sane.

  • Participants
  • Parent commits d29a099
  • Branches default

Comments (0)

Files changed (1)

File vim/.vimrc

View file
 " -----------
 "
 " Shortcuts:
-"   F1       Toggle paste mode
-"   F4       Show QuickBuf for buffer selection/manipulation
-"   F5       Run 'make' command and show fix window
-"   F8       Show NERDTree
-"   F9       Show tags list
+"   F1    Toggle paste mode
+"   F4    Show QuickBuf for buffer selection/manipulation
+"   F5    Run 'make' command and show fix window
+"   F8    Show NERDTree
+"   F9    Show tags list
 "
-"   :A       Jump to corresponding file (ie. from .c jump to .h)
-"   :AS      Split jump to corresponding file (horizontal)
-"   :AV      Split jump to corresponding file (vertical)
+"   :A    Jump to corresponding file (ie. from .c jump to .h)
+"   :AS   Split jump to corresponding file (horizontal)
+"   :AV   Split jump to corresponding file (vertical)
 "
-"   \cr      Open C reference on keyword with cursor
-"   \fl      Toggle folding
-"   \vo      Open EasyGrep options
-"   \vv      Open EasyGrep searching on current word
-"   \wh      Toggle whitespace visibility
+"   \cr   Open C reference on keyword with cursor
+"   \fl   Toggle folding
+"   \vo   Open EasyGrep options
+"   \vv   Open EasyGrep searching on current word
+"   \wh   Toggle whitespace visibility
 "
 " Commands:
 "  :Vissort         Sort lines using column selected by visual selection
     set statusline+=%{&fileformat}:              " file format
     set statusline+=%{strlen(&ft)?&ft:'none'}>\  " file type
     set statusline+=x%02.4B                      " current char
+
+    set showtabline=2
+    set tabline=%!SaneTabLine()
+    fun SaneTabLine()
+        let sl = ''
+
+        for tabidx in range(tabpagenr('$'))
+            let bufnrlist = tabpagebuflist(tabidx + 1)
+            let sl .= '%#TabLineSel#'
+
+            " start 'selected' highlighting on active tab buffer
+            if tabidx + 1 == tabpagenr()
+                let sl .= '%#TabLine#'
+            else
+                let sl .= '%#TabLineSel#'
+            endif
+
+            " the tab page number
+            let sl .= '%' . (tabidx + 1) . 'T'
+            let sl .= tabidx + 1 . ': '
+
+            let title = ''
+            let modnr = 0
+            let winnr = tabpagewinnr(tabidx + 1, '$')
+
+            " count modified buffer in tab
+            for bufidx in bufnrlist
+                if getbufvar(bufidx, "&modified" )
+                    let modnr += 1
+                endif
+            endfor
+
+            let blid = bufnrlist[tabpagewinnr(tabidx + 1) - 1]
+            if getbufvar(blid, "&buftype" ) == 'help'
+                let title .= '- Hlp ' . fnamemodify( bufname(blid), ':t:s/.txt$//' ) . ' -'
+            elseif getbufvar(blid, "&buftype" ) == 'quickfix'
+                let title .= '- QFix -'
+            else
+                let fname = bufname(blid)
+                if fname == ''
+                    let title .= '- No Name -'
+                else
+                    let title .= fnamemodify(fname, ':t')
+                endif
+            endif
+
+            " add title
+            let sl .= title
+
+            " add modified/total buffer information
+            if modnr > 0
+                let sl .= '[' . modnr . '/' . winnr . ']'
+            endif
+
+            " stop 'selected' highlighting
+            let sl .= ' %#TabLineSel#'
+        endfor
+
+        " fill with TabLineFill and reset tab page nr
+        let sl .= '%#TabLineFill#%T'
+
+        " right-align the close label
+        if tabpagenr('$') > 1
+            let sl .= '%=%#TabLineFill#%999XX'
+        endif
+        return sl
+    endfun
+
 endfun
 call VimConfig_display()
 
 
 " Always do a full syntax refresh
 autocmd BufEnter * syntax sync fromstart
+
+" set et ts=4 sts=4