diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 11d46ff..8f07c9f 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -18,10 +18,53 @@ " use of this software. " ============================================================================ +scriptencoding utf-8 + " Initialization {{{1 " Basic init {{{2 +if v:version < 700 + echomsg 'Tagbar: Vim version is too old, Tagbar requires at least 7.0' + finish +endif + +if !exists('g:tagbar_ctags_bin') + if executable('ctags-exuberant') + let g:tagbar_ctags_bin = 'ctags-exuberant' + elseif executable('exuberant-ctags') + let g:tagbar_ctags_bin = 'exuberant-ctags' + elseif executable('exctags') + let g:tagbar_ctags_bin = 'exctags' + elseif executable('ctags') + let g:tagbar_ctags_bin = 'ctags' + elseif executable('ctags.exe') + let g:tagbar_ctags_bin = 'ctags.exe' + elseif executable('tags') + let g:tagbar_ctags_bin = 'tags' + else + echomsg 'Tagbar: Exuberant ctags not found, skipping plugin' + finish + endif +else + let g:tagbar_ctags_bin = expand(g:tagbar_ctags_bin) + if !executable(g:tagbar_ctags_bin) + echomsg 'Tagbar: Exuberant ctags not found in specified place,' + \ 'skipping plugin' + finish + endif +endif + +redir => s:ftype_out +silent filetype +redir END +if s:ftype_out !~# 'detection:ON' + echomsg 'Tagbar: Filetype detection is turned off, skipping plugin' + unlet s:ftype_out + finish +endif +unlet s:ftype_out + if has('multi_byte') && has('unix') && &encoding == 'utf-8' && \ (empty(&termencoding) || &termencoding == 'utf-8') let s:icon_closed = '▶' @@ -45,6 +88,8 @@ let s:access_symbols = { \ 'private' : '-' \ } +let g:loaded_tagbar = 1 + " s:InitTypes() {{{2 function! s:InitTypes() let s:known_types = {} @@ -2782,4 +2827,4 @@ function! tagbar#RestoreSession() endfunction " Modeline {{{1 -" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 \ No newline at end of file +" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index a864cbf..be874d7 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -18,9 +18,7 @@ " use of this software. " ============================================================================ -if has('multi_byte') - scriptencoding utf-8 -endif +scriptencoding utf-8 if &cp || exists('g:loaded_tagbar') finish @@ -28,49 +26,6 @@ endif " Basic init {{{1 -if v:version < 700 - echomsg 'Tagbar: Vim version is too old, Tagbar requires at least 7.0' - finish -endif - -if !exists('g:tagbar_ctags_bin') - if executable('ctags-exuberant') - let g:tagbar_ctags_bin = 'ctags-exuberant' - elseif executable('exuberant-ctags') - let g:tagbar_ctags_bin = 'exuberant-ctags' - elseif executable('exctags') - let g:tagbar_ctags_bin = 'exctags' - elseif executable('ctags') - let g:tagbar_ctags_bin = 'ctags' - elseif executable('ctags.exe') - let g:tagbar_ctags_bin = 'ctags.exe' - elseif executable('tags') - let g:tagbar_ctags_bin = 'tags' - else - echomsg 'Tagbar: Exuberant ctags not found, skipping plugin' - finish - endif -else - let g:tagbar_ctags_bin = expand(g:tagbar_ctags_bin) - if !executable(g:tagbar_ctags_bin) - echomsg 'Tagbar: Exuberant ctags not found in specified place,' - \ 'skipping plugin' - finish - endif -endif - -redir => s:ftype_out -silent filetype -redir END -if s:ftype_out !~# 'detection:ON' - echomsg 'Tagbar: Filetype detection is turned off, skipping plugin' - unlet s:ftype_out - finish -endif -unlet s:ftype_out - -let g:loaded_tagbar = 1 - if !exists('g:tagbar_left') let g:tagbar_left = 0 endif @@ -119,7 +74,10 @@ if !exists('g:tagbar_systemenc') let g:tagbar_systemenc = &encoding endif -autocmd SessionLoadPost * nested call tagbar#RestoreSession() +augroup TagbarSession + autocmd! + autocmd SessionLoadPost * nested call tagbar#RestoreSession() +augroup END " Commands {{{1 command! -nargs=0 TagbarToggle call tagbar#ToggleWindow() @@ -130,4 +88,4 @@ command! -nargs=1 TagbarSetFoldlevel call tagbar#SetFoldLevel() command! -nargs=0 TagbarShowTag call tagbar#OpenParents() " Modeline {{{1 -" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 \ No newline at end of file +" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 diff --git a/syntax/tagbar.vim b/syntax/tagbar.vim index e51fa72..b3bf346 100644 --- a/syntax/tagbar.vim +++ b/syntax/tagbar.vim @@ -5,9 +5,7 @@ " Website: http://majutsushi.github.com/tagbar/ " Version: 2.1 -if has('multi_byte') - scriptencoding utf-8 -endif +scriptencoding utf-8 if exists("b:current_syntax") finish @@ -62,3 +60,5 @@ highlight default TagbarAccessProtected guifg=Blue ctermfg=Blue highlight default TagbarAccessPrivate guifg=Red ctermfg=Red let b:current_syntax = "tagbar" + +" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1