mirror of
https://github.com/gryf/tagbar.git
synced 2025-12-18 12:00:23 +01:00
Add mapping to toggle autoclose option
The current tagbar_autoclose state will be displayed in the statusline. Also change the "hide nonpublic" flag to "v" to match the mapping and properly document the statusline flags.
This commit is contained in:
@@ -938,10 +938,11 @@ function! s:MapKeys() abort
|
||||
\ ['openallfolds', 'SetFoldLevel(99, 1)'],
|
||||
\ ['closeallfolds', 'SetFoldLevel(0, 1)'],
|
||||
\
|
||||
\ ['togglesort', 'ToggleSort()'],
|
||||
\ ['zoomwin', 'ZoomWindow()'],
|
||||
\ ['close', 'CloseWindow()'],
|
||||
\ ['help', 'ToggleHelp()'],
|
||||
\ ['togglesort', 'ToggleSort()'],
|
||||
\ ['toggleautoclose', 'ToggleAutoclose()'],
|
||||
\ ['zoomwin', 'ZoomWindow()'],
|
||||
\ ['close', 'CloseWindow()'],
|
||||
\ ['help', 'ToggleHelp()'],
|
||||
\ ]
|
||||
|
||||
for [map, func] in maps
|
||||
@@ -1808,12 +1809,12 @@ function! s:InitWindow(autoclose) abort
|
||||
setlocal foldmethod&
|
||||
setlocal foldexpr&
|
||||
|
||||
let w:autoclose = a:autoclose
|
||||
|
||||
call s:SetStatusLine('current')
|
||||
|
||||
let s:new_window = 1
|
||||
|
||||
let w:autoclose = a:autoclose
|
||||
|
||||
if has('balloon_eval')
|
||||
setlocal balloonexpr=TagbarBalloonExpr()
|
||||
set ballooneval
|
||||
@@ -3666,6 +3667,12 @@ function! s:ToggleHideNonPublicTags() abort
|
||||
call s:SetStatusLine('current')
|
||||
endfunction
|
||||
|
||||
" s:ToggleAutoclose() {{{2
|
||||
function! s:ToggleAutoclose() abort
|
||||
let g:tagbar_autoclose = !g:tagbar_autoclose
|
||||
call s:SetStatusLine('current')
|
||||
endfunction
|
||||
|
||||
" s:IsValidFile() {{{2
|
||||
function! s:IsValidFile(fname, ftype) abort
|
||||
call s:debug('Checking if file is valid [' . a:fname . ']')
|
||||
@@ -3727,13 +3734,21 @@ function! s:SetStatusLine(current)
|
||||
let fname = ''
|
||||
endif
|
||||
|
||||
let flags = []
|
||||
let flags += exists('w:autoclose') && w:autoclose ? ['c'] : []
|
||||
let flags += g:tagbar_autoclose ? ['C'] : []
|
||||
let flags += g:tagbar_hide_nonpublic ? ['v'] : []
|
||||
|
||||
if exists('g:tagbar_status_func')
|
||||
let args = [current, sort, fname]
|
||||
let args = [current, sort, fname, flags]
|
||||
let &l:statusline = call(g:tagbar_status_func, args)
|
||||
else
|
||||
let colour = current ? '%#StatusLine#' : '%#StatusLineNC#'
|
||||
let hide = g:tagbar_hide_nonpublic ? '[h] ' : ''
|
||||
let text = colour . '[' . sort . '] ' . hide . fname
|
||||
let flagstr = join(flags, '')
|
||||
if flagstr != ''
|
||||
let flagstr = '[' . flagstr . '] '
|
||||
endif
|
||||
let text = colour . '[' . sort . '] ' . flagstr . fname
|
||||
let &l:statusline = text
|
||||
endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user