44" Author: Jan Larres <jan@majutsushi.net>
55" Licence: Vim licence
66" Website: http://majutsushi.github.com/tagbar/
7- " Version: 1.0
7+ " Version: 1.1
88" Note: This plugin was heavily inspired by the 'Taglist' plugin by
99" Yegappan Lakshmanan and uses a small amount of code from it.
1010"
@@ -62,9 +62,14 @@ if !exists('g:tagbar_compact')
6262 let g: tagbar_compact = 0
6363endif
6464
65+ if ! exists (' g:tagbar_expand' )
66+ let g: tagbar_expand = 0
67+ endif
68+
6569let s: type_init_done = 0
6670let s: key_mapping_done = 0
6771let s: autocommands_done = 0
72+ let s: window_expanded = 0
6873
6974" s:InitTypes() {{{2
7075function ! s: InitTypes ()
@@ -837,6 +842,12 @@ function! s:OpenWindow(autoclose)
837842 return
838843 endif
839844
845+ " Expand the Vim window to accomodate for the Tagbar window if requested
846+ if g: tagbar_expand && ! s: window_expanded && has (' gui_running' )
847+ let &columns += g: tagbar_width + 1
848+ let s: window_expanded = 1
849+ endif
850+
840851 let openpos = g: tagbar_left ? ' topleft vertical ' : ' botright vertical '
841852 exe ' silent! keepalt ' . openpos . g: tagbar_width . ' split ' . ' __Tagbar__'
842853
@@ -880,21 +891,6 @@ function! s:OpenWindow(autoclose)
880891
881892 let w: autoclose = a: autoclose
882893
883- syntax match Comment ' ^" .*' " Comments
884- syntax match Identifier ' ^ [^: ]\+ [^:]\+ $' " Non-scoped kinds
885- syntax match Title ' [^(* ]\+\z e\*\? :' " Scope names
886- syntax match Type ' : \z s.*' " Scope types
887- syntax match SpecialKey ' (.*)' " Signatures
888- syntax match NonText ' \*\z e :' " Pseudo-tag identifiers
889-
890- highlight default TagbarAccessPublic guifg= Green ctermfg= Green
891- highlight default TagbarAccessProtected guifg= Blue ctermfg= Blue
892- highlight default TagbarAccessPrivate guifg= Red ctermfg= Red
893-
894- syntax match TagbarAccessPublic ' ^\s *+\z e[^ ]'
895- syntax match TagbarAccessProtected ' ^\s *#\z e[^ ]'
896- syntax match TagbarAccessPrivate ' ^\s *-\z e[^ ]'
897-
898894 if has (' balloon_eval' )
899895 setlocal balloonexpr = TagbarBalloonExpr ()
900896 set ballooneval
@@ -930,6 +926,8 @@ function! s:CloseWindow()
930926 return
931927 endif
932928
929+ let tagbarbufnr = winbufnr (tagbarwinnr)
930+
933931 if winnr () == tagbarwinnr
934932 if winbufnr (2 ) != -1
935933 " Other windows are open, only close the tagbar one
@@ -948,6 +946,20 @@ function! s:CloseWindow()
948946 exe winnum . ' wincmd w'
949947 endif
950948 endif
949+
950+ " If the Vim window has been expanded, and Tagbar is not open in any other
951+ " tabpages, shrink the window again
952+ if s: window_expanded
953+ let tablist = []
954+ for i in range (tabpagenr (' $' ))
955+ call extend (tablist, tabpagebuflist (i + 1 ))
956+ endfor
957+
958+ if index (tablist, tagbarbufnr) == -1
959+ let &columns -= g: tagbar_width + 1
960+ let s: window_expanded = 0
961+ endif
962+ endif
951963endfunction
952964
953965" s:ZoomWindow() {{{2
@@ -1676,6 +1688,7 @@ endfunction
16761688" s:CleanUp() {{{2
16771689function ! s: CleanUp ()
16781690 silent ! autocmd ! TagbarAutoCmds
1691+
16791692 unlet s: current_file
16801693 unlet s: is_maximized
16811694 unlet s: compare_typeinfo
0 commit comments