Skip to content

Commit

Permalink
Move some tests to autoload
Browse files Browse the repository at this point in the history
  • Loading branch information
majutsushi committed Jul 15, 2011
1 parent 4920be4 commit 96d0050
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 52 deletions.
47 changes: 46 additions & 1 deletion autoload/tagbar.vim
Expand Up @@ -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 = ''
Expand All @@ -45,6 +88,8 @@ let s:access_symbols = {
\ 'private' : '-'
\ }

let g:loaded_tagbar = 1

" s:InitTypes() {{{2
function! s:InitTypes()
let s:known_types = {}
Expand Down Expand Up @@ -2782,4 +2827,4 @@ function! tagbar#RestoreSession()
endfunction

" Modeline {{{1
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
54 changes: 6 additions & 48 deletions plugin/tagbar.vim
Expand Up @@ -18,59 +18,14 @@
" use of this software.
" ============================================================================

if has('multi_byte')
scriptencoding utf-8
endif
scriptencoding utf-8

if &cp || exists('g:loaded_tagbar')
finish
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
Expand Down Expand Up @@ -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()
Expand All @@ -130,4 +88,4 @@ command! -nargs=1 TagbarSetFoldlevel call tagbar#SetFoldLevel(<args>)
command! -nargs=0 TagbarShowTag call tagbar#OpenParents()

" Modeline {{{1
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
6 changes: 3 additions & 3 deletions syntax/tagbar.vim
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 96d0050

Please sign in to comment.