From 845754bdade46ab9d648699f75983257cb23585a Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Thu, 12 May 2011 20:50:14 +1200 Subject: [PATCH] Don't check ctags on each 'window open' --- plugin/tagbar.vim | 56 +++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index 442da84..1e053b1 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -121,6 +121,7 @@ endif let s:type_init_done = 0 let s:autocommands_done = 0 +let s:checked_ctags = 0 let s:window_expanded = 0 let s:access_symbols = { @@ -878,6 +879,37 @@ function! s:CreateAutocommands() let s:autocommands_done = 1 endfunction +" s:CheckForExCtags() {{{2 +" Test whether the ctags binary is actually Exuberant Ctags and not GNU ctags +" (or something else) +function! s:CheckForExCtags() + let ctags_cmd = s:EscapeCtagsCmd(g:tagbar_ctags_bin, '--version') + if ctags_cmd == '' + return + endif + + let ctags_output = s:ExecuteCtags(ctags_cmd) + + if v:shell_error || ctags_output !~# 'Exuberant Ctags' + echoerr 'Tagbar: Ctags doesn''t seem to be Exuberant Ctags!' + echomsg 'GNU ctags will NOT WORK.' + \ 'Please download Exuberant Ctags from ctags.sourceforge.net' + \ 'and install it in a directory in your $PATH' + \ 'or set g:tagbar_ctags_bin.' + echomsg 'Executed command: "' . ctags_cmd . '"' + if !empty(ctags_output) + echomsg 'Command output:' + for line in split(ctags_output, '\n') + echomsg line + endfor + endif + return 0 + else + let s:checked_ctags = 1 + return 1 + endif +endfunction + " Prototypes {{{1 " Base tag {{{2 let s:BaseTag = {} @@ -1313,28 +1345,10 @@ function! s:OpenWindow(autoclose) return endif - " Test whether the ctags binary is actually Exuberant Ctags and not GNU - " ctags (or something else) - let ctags_cmd = s:EscapeCtagsCmd(g:tagbar_ctags_bin, '--version') - if ctags_cmd == '' - return - endif - let ctags_output = s:ExecuteCtags(ctags_cmd) - - if v:shell_error || ctags_output !~# 'Exuberant Ctags' - echoerr 'Tagbar: Ctags doesn''t seem to be Exuberant Ctags!' - echomsg 'GNU ctags will NOT WORK.' - \ 'Please download Exuberant Ctags from ctags.sourceforge.net' - \ 'and install it in a directory in your $PATH' - \ 'or set g:tagbar_ctags_bin.' - echomsg 'Executed command: "' . ctags_cmd . '"' - if !empty(ctags_output) - echomsg 'Command output:' - for line in split(ctags_output, '\n') - echomsg line - endfor + if !s:checked_ctags + if !s:CheckForExCtags() + return endif - return endif " Expand the Vim window to accomodate for the Tagbar window if requested