mirror of
https://github.com/preservim/tagbar.git
synced 2024-11-23 11:10:34 +08:00
Allow expanding the vim window when opening Tagbar
This commit is contained in:
parent
a18be73b63
commit
9ae8cfedd8
|
@ -304,6 +304,18 @@ Example:
|
|||
>
|
||||
let g:tagbar_compact = 1
|
||||
<
|
||||
|
||||
*g:tagbar_expand*
|
||||
g:tagbar_expand~
|
||||
If this option is set the Vim window will be expanded by the width of the
|
||||
Tagbar window if using a GUI version of Vim. The default is not to expand the
|
||||
window.
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:tagbar_expand = 1
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
6. Extending Tagbar *tagbar-extend*
|
||||
|
||||
|
@ -607,3 +619,6 @@ anything else that's free, taglist.vim is provided *as is* and comes with no
|
|||
warranty of any kind, either expressed or implied. In no event will the
|
||||
copyright holder be liable for any damamges resulting from the use of this
|
||||
software.
|
||||
|
||||
==============================================================================
|
||||
vim: tw=78 ts=8 sw=8 sts=8 noet ft=help
|
||||
|
|
|
@ -62,9 +62,14 @@ if !exists('g:tagbar_compact')
|
|||
let g:tagbar_compact = 0
|
||||
endif
|
||||
|
||||
if !exists('g:tagbar_expand')
|
||||
let g:tagbar_expand = 0
|
||||
endif
|
||||
|
||||
let s:type_init_done = 0
|
||||
let s:key_mapping_done = 0
|
||||
let s:autocommands_done = 0
|
||||
let s:window_expanded = 0
|
||||
|
||||
" s:InitTypes() {{{2
|
||||
function! s:InitTypes()
|
||||
|
@ -837,6 +842,12 @@ function! s:OpenWindow(autoclose)
|
|||
return
|
||||
endif
|
||||
|
||||
" Expand the Vim window to accomodate for the Tagbar window if requested
|
||||
if g:tagbar_expand && !s:window_expanded && has('gui_running')
|
||||
let &columns += g:tagbar_width + 1
|
||||
let s:window_expanded = 1
|
||||
endif
|
||||
|
||||
let openpos = g:tagbar_left ? 'topleft vertical ' : 'botright vertical '
|
||||
exe 'silent! keepalt ' . openpos . g:tagbar_width . 'split ' . '__Tagbar__'
|
||||
|
||||
|
@ -915,6 +926,8 @@ function! s:CloseWindow()
|
|||
return
|
||||
endif
|
||||
|
||||
let tagbarbufnr = winbufnr(tagbarwinnr)
|
||||
|
||||
if winnr() == tagbarwinnr
|
||||
if winbufnr(2) != -1
|
||||
" Other windows are open, only close the tagbar one
|
||||
|
@ -933,6 +946,20 @@ function! s:CloseWindow()
|
|||
exe winnum . 'wincmd w'
|
||||
endif
|
||||
endif
|
||||
|
||||
" If the Vim window has been expanded, and Tagbar is not open in any other
|
||||
" tabpages, shrink the window again
|
||||
if s:window_expanded
|
||||
let tablist = []
|
||||
for i in range(tabpagenr('$'))
|
||||
call extend(tablist, tabpagebuflist(i + 1))
|
||||
endfor
|
||||
|
||||
if index(tablist, tagbarbufnr) == -1
|
||||
let &columns -= g:tagbar_width + 1
|
||||
let s:window_expanded = 0
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" s:ZoomWindow() {{{2
|
||||
|
@ -1661,6 +1688,7 @@ endfunction
|
|||
" s:CleanUp() {{{2
|
||||
function! s:CleanUp()
|
||||
silent! autocmd! TagbarAutoCmds
|
||||
|
||||
unlet s:current_file
|
||||
unlet s:is_maximized
|
||||
unlet s:compare_typeinfo
|
||||
|
|
Loading…
Reference in New Issue
Block a user