From 19695b87b0ca04509eaf167c790f088fa57dd238 Mon Sep 17 00:00:00 2001 From: kianryan Date: Mon, 1 Oct 2012 14:22:35 +0100 Subject: [PATCH] Pause autocmd functionality with :TagbarPause tagbar#PauseAutocommands :TagbarPause :TagbarPause pauses autocmds, effectively freezing Tagbar on the last file. Useful for keeping a tag reference for a file open whilst working in a different file. --- autoload/tagbar.vim | 19 +++++++++++++++++++ plugin/tagbar.vim | 1 + 2 files changed, 20 insertions(+) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index b852099..9acdcbf 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -45,6 +45,7 @@ let s:icon_open = g:tagbar_iconchars[1] let s:type_init_done = 0 let s:autocommands_done = 0 +let s:autocommands_enable = 0 " 0: not checked yet; 1: checked and found; 2: checked and not found let s:checked_ctags = 0 let s:checked_ctags_types = 0 @@ -971,6 +972,19 @@ function! s:CreateAutocommands() abort augroup END let s:autocommands_done = 1 + let s:autocommands_enable = 1 +endfunction + +" s:PauseAutocommands() {{{2 +" Toggle autocommands +function! s:PauseAutocommands() abort + if s:autocommands_enable == 1 + autocmd! TagbarAutoCmds + let s:autocommands_enable = 0 + else + call s:CreateAutocommands() + call s:AutoUpdate(fnamemodify(expand('%'), ':p'), 0) + endif endfunction " s:CheckForExCtags() {{{2 @@ -3456,6 +3470,11 @@ endfunction function! tagbar#RestoreSession() abort call s:RestoreSession() endfunction + +function! tagbar#PauseAutocommands() abort + call s:PauseAutocommands() +endfunction + " }}}2 " tagbar#getusertypes() {{{2 diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index ad7c3c8..369a00e 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -111,6 +111,7 @@ command! -nargs=? TagbarCurrentTag echo tagbar#currenttag('%s', 'No current t command! -nargs=1 TagbarGetTypeConfig call tagbar#gettypeconfig() command! -nargs=? TagbarDebug call tagbar#StartDebug() command! -nargs=0 TagbarDebugEnd call tagbar#StopDebug() +command! -nargs=0 TagbarPause call tagbar#PauseAutocommands() " Modeline {{{1 " vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1