" ============================================================================ " File: tagbar.vim " Description: List the current file's tags in a sidebar, ordered by class etc " Maintainer: Jan Larres " Licence: Vim licence " Website: http://github.com/majutsushi/tagbar " Note: This plugin was heavily inspired by the 'Taglist' plugin by " Yegappan Lakshamanan and uses some small portions of code from " it. " ============================================================================ if &cp || exists('g:loaded_tagbar') finish endif if !exists('*system') echomsg 'Tagbar: No system() function available, skipping plugin' finish endif if !exists('g:tagbar_ctags_exe') if executable('exuberant-ctags') let g:tagbar_ctags_exe = 'exuberant-ctags' elseif executable('exctags') let g:tagbar_ctags_exe = 'exctags' elseif executable('ctags') let g:tagbar_ctags_exe = 'ctags' elseif executable('ctags.exe') let g:tagbar_ctags_exe = 'ctags.exe' elseif executable('tags') let g:tagbar_ctags_exe = 'tags' else echomsg 'Tagbar: Exuberant ctags not found, skipping plugin' finish endif endif let g:loaded_tagbar = 1 if !exists('g:tagbar_left') let g:tagbar_left = 0 endif if !exists('g:tagbar_width') let g:tagbar_width = 40 endif if !exists('g:tagbar_types') let g:tagbar_types = {} endif if !exists('g:tagbar_autoclose') let g:tagbar_autoclose = 0 endif function! s:InitTypes() let s:known_files = {} let s:known_types = {} let type_cpp = {} let type_cpp.ctagstype = 'c++' let type_cpp.scopes = ['namespace', 'class', 'struct'] let type_cpp.sro = '::' let type_cpp.kinds = [ \ 'd:macros', \ 'n:namespaces', \ 'p:prototypes', \ 'v:variables', \ 't:typedefs', \ 'c:classes', \ 'm:members', \ 'g:enum', \ 's:structs', \ 'u:unions', \ 'f:functions' \ ] let type_cpp.scope2kind = { \ 'namespace' : 'n', \ 'class' : 'c', \ 'struct' : 's' \ } let s:known_types.cpp = type_cpp let type_python = {} let type_python.ctagstype = 'python' let type_python.scopes = ['class', 'function'] let type_python.sro = '.' let type_python.kinds = [ \ 'i:imports', \ 'c:classes', \ 'f:functions', \ 'm:members', \ 'v:variables' \ ] let type_python.scope2kind = { \ 'class' : 'c', \ 'function' : 'f' \ } let s:known_types.python = type_python call extend(s:known_types, g:tagbar_types) endfunction call s:InitTypes() function! s:ToggleWindow() let tagbarwinnr = bufwinnr("__Tagbar__") if tagbarwinnr != -1 call s:CloseWindow() return endif call s:OpenWindow() endfunction function! s:OpenWindow() " If the tagbar window is already open jump to it let tagbarwinnr = bufwinnr('__Tagbar__') if tagbarwinnr != -1 && winnr() != tagbarwinnr " execute tagbarwinnr . 'wincmd w' return endif let openpos = g:tagbar_left ? 'topleft vertical ' : 'botright vertical ' execute 'silent! ' . openpos . g:tagbar_width . 'split ' . '__Tagbar__' setlocal noreadonly " in case the "view" mode is used setlocal buftype=nofile setlocal bufhidden=delete setlocal noswapfile setlocal nobuflisted setlocal nomodifiable setlocal filetype=tagbar setlocal nolist setlocal nonumber setlocal norelativenumber setlocal nowrap setlocal winfixwidth setlocal foldenable setlocal foldminlines=0 setlocal foldmethod=manual setlocal foldlevel=9999 setlocal foldcolumn=1 setlocal foldtext=v:folddashes.getline(v:foldstart) let cpoptions_save = &cpoptions set cpoptions&vim " nnoremap