1
0
mirror of https://github.com/gryf/tagbar.git synced 2025-12-18 12:00:23 +01:00

Add option to arrange Tagbar window vertically

This commit is contained in:
Jan Larres
2014-11-08 21:30:17 +13:00
parent 5283bc834a
commit f933907afa
3 changed files with 53 additions and 10 deletions

View File

@@ -1767,8 +1767,14 @@ function! s:OpenWindow(flags) abort
endif
let s:window_opening = 1
let openpos = g:tagbar_left ? 'topleft vertical ' : 'botright vertical '
exe 'silent keepalt ' . openpos . g:tagbar_width . 'split ' . '__Tagbar__'
if g:tagbar_vertical == 0
let openpos = g:tagbar_left ? 'topleft vertical ' : 'botright vertical '
let width = g:tagbar_width
else
let openpos = g:tagbar_left ? 'leftabove ' : 'rightbelow '
let width = g:tagbar_vertical
endif
exe 'silent keepalt ' . openpos . width . 'split ' . '__Tagbar__'
unlet s:window_opening
call s:InitWindow(autoclose)
@@ -3050,12 +3056,6 @@ function! s:ShowInPreviewWin() abort
return
endif
call s:GotoFileWindow(taginfo.fileinfo, 1)
call s:mark_window()
" Check whether the preview window is already open and open it if not.
" This has to be done before the :psearch below so the window is relative
" to the Tagbar window.
let pwin_open = 0
for win in range(1, winnr('$'))
if getwinvar(win, '&previewwindow')
@@ -3064,14 +3064,32 @@ function! s:ShowInPreviewWin() abort
endif
endfor
" We want the preview window to be relative to the file window in normal
" (horizontal) mode, and relative to the Tagbar window in vertical mode,
" to make the best use of space.
if g:tagbar_vertical == 0
call s:GotoFileWindow(taginfo.fileinfo, 1)
call s:mark_window()
endif
" Open the preview window if it is not already open. This has to be done
" explicitly before the :psearch below to better control its positioning.
if !pwin_open
silent execute
\ g:tagbar_previewwin_pos . ' pedit ' . taginfo.fileinfo.fpath
if g:tagbar_vertical != 0
silent execute 'vertical resize ' . g:tagbar_width
endif
" Remember that the preview window was opened by Tagbar so we can
" safely close it by ourselves
let s:pwin_by_tagbar = 1
endif
if g:tagbar_vertical != 0
call s:GotoFileWindow(taginfo.fileinfo, 1)
call s:mark_window()
endif
" Use psearch instead of pedit since pedit essentially reloads the file
" and creates an empty undo entry. psearch has to be called from the file
" window, and since we only want matches in the current file we disable