mirror of
https://github.com/gryf/tagbar.git
synced 2026-05-10 16:32:58 +02:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a7f155874 | |||
| 768cd6b908 | |||
| 4981cf9896 | |||
| fd9ac426e9 | |||
| 4dabb96014 | |||
| 7f95420284 | |||
| 44ce05fb5d | |||
| 9ae2b2d818 | |||
| 2e0d125b79 |
+121
-84
@@ -4,7 +4,7 @@
|
||||
" Author: Jan Larres <jan@majutsushi.net>
|
||||
" Licence: Vim licence
|
||||
" Website: http://majutsushi.github.com/tagbar/
|
||||
" Version: 2.4
|
||||
" Version: 2.4.1
|
||||
" Note: This plugin was heavily inspired by the 'Taglist' plugin by
|
||||
" Yegappan Lakshmanan and uses a small amount of code from it.
|
||||
"
|
||||
@@ -22,46 +22,14 @@ scriptencoding utf-8
|
||||
|
||||
" Initialization {{{1
|
||||
|
||||
" Basic init {{{2
|
||||
|
||||
if !exists('g:tagbar_ctags_bin')
|
||||
let ctagsbins = []
|
||||
let ctagsbins += ['ctags-exuberant'] " Debian
|
||||
let ctagsbins += ['exuberant-ctags']
|
||||
let ctagsbins += ['exctags'] " FreeBSD, NetBSD
|
||||
let ctagsbins += ['/usr/local/bin/ctags'] " Homebrew
|
||||
let ctagsbins += ['/opt/local/bin/ctags'] " Macports
|
||||
let ctagsbins += ['ectags'] " OpenBSD
|
||||
let ctagsbins += ['ctags']
|
||||
let ctagsbins += ['ctags.exe']
|
||||
let ctagsbins += ['tags']
|
||||
for ctags in ctagsbins
|
||||
if executable(ctags)
|
||||
let g:tagbar_ctags_bin = ctags
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
if !exists('g:tagbar_ctags_bin')
|
||||
echomsg 'Tagbar: Exuberant ctags not found, skipping plugin'
|
||||
finish
|
||||
endif
|
||||
else
|
||||
" reset 'wildignore' temporarily in case *.exe is included in it
|
||||
let wildignore_save = &wildignore
|
||||
set wildignore&
|
||||
|
||||
let g:tagbar_ctags_bin = expand(g:tagbar_ctags_bin)
|
||||
|
||||
let &wildignore = wildignore_save
|
||||
|
||||
if !executable(g:tagbar_ctags_bin)
|
||||
echomsg "Tagbar: Exuberant ctags not found at " .
|
||||
\ "'" . g:tagbar_ctags_bin . "', " .
|
||||
\ "skipping plugin"
|
||||
finish
|
||||
endif
|
||||
" If another plugin calls an autoloaded Tagbar function on startup before the
|
||||
" plugin/tagbar.vim file got loaded, load it explicitly
|
||||
if exists(':Tagbar') == 0
|
||||
runtime plugin/tagbar.vim
|
||||
endif
|
||||
|
||||
" Basic init {{{2
|
||||
|
||||
redir => s:ftype_out
|
||||
silent filetype
|
||||
redir END
|
||||
@@ -77,6 +45,7 @@ let s:icon_open = g:tagbar_iconchars[1]
|
||||
|
||||
let s:type_init_done = 0
|
||||
let s:autocommands_done = 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
|
||||
let s:ctags_types = {}
|
||||
@@ -96,9 +65,11 @@ let s:debug = 0
|
||||
let s:debug_file = ''
|
||||
|
||||
" s:Init() {{{2
|
||||
function! s:Init()
|
||||
if !s:checked_ctags
|
||||
if !s:CheckForExCtags()
|
||||
function! s:Init(silent)
|
||||
if s:checked_ctags == 2 && a:silent
|
||||
return 0
|
||||
elseif s:checked_ctags != 1
|
||||
if !s:CheckForExCtags(a:silent)
|
||||
return 0
|
||||
endif
|
||||
endif
|
||||
@@ -334,9 +305,9 @@ function! s:InitTypes()
|
||||
" guesses and probably requires
|
||||
" http://www.vim.org/scripts/script.php?script_id=2909
|
||||
" Improvements welcome!
|
||||
let type_mxml = s:TypeInfo.New()
|
||||
let type_mxml.ctagstype = 'flex'
|
||||
let type_mxml.kinds = [
|
||||
let type_as = s:TypeInfo.New()
|
||||
let type_as.ctagstype = 'flex'
|
||||
let type_as.kinds = [
|
||||
\ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0},
|
||||
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1},
|
||||
@@ -344,14 +315,15 @@ function! s:InitTypes()
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'x', 'long' : 'mxtags', 'fold' : 0, 'stl' : 0}
|
||||
\ ]
|
||||
let type_mxml.sro = '.'
|
||||
let type_mxml.kind2scope = {
|
||||
let type_as.sro = '.'
|
||||
let type_as.kind2scope = {
|
||||
\ 'c' : 'class'
|
||||
\ }
|
||||
let type_mxml.scope2kind = {
|
||||
let type_as.scope2kind = {
|
||||
\ 'class' : 'c'
|
||||
\ }
|
||||
let s:known_types.mxml = type_mxml
|
||||
let s:known_types.mxml = type_as
|
||||
let s:known_types.actionscript = type_as
|
||||
" Fortran {{{3
|
||||
let type_fortran = s:TypeInfo.New()
|
||||
let type_fortran.ctagstype = 'fortran'
|
||||
@@ -626,6 +598,7 @@ function! s:InitTypes()
|
||||
let type_sql.ctagstype = 'sql'
|
||||
let type_sql.kinds = [
|
||||
\ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 1},
|
||||
\ {'short' : 'd', 'long' : 'prototypes', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'c', 'long' : 'cursors', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'F', 'long' : 'record fields', 'fold' : 0, 'stl' : 1},
|
||||
@@ -643,7 +616,8 @@ function! s:InitTypes()
|
||||
\ {'short' : 'V', 'long' : 'views', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'n', 'long' : 'synonyms', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'x', 'long' : 'MobiLink Table Scripts', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'y', 'long' : 'MobiLink Conn Scripts', 'fold' : 0, 'stl' : 1}
|
||||
\ {'short' : 'y', 'long' : 'MobiLink Conn Scripts', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'z', 'long' : 'MobiLink Properties', 'fold' : 0, 'stl' : 1}
|
||||
\ ]
|
||||
let s:known_types.sql = type_sql
|
||||
" Tcl {{{3
|
||||
@@ -787,6 +761,7 @@ function! s:InitTypes()
|
||||
let type_vim = s:TypeInfo.New()
|
||||
let type_vim.ctagstype = 'vim'
|
||||
let type_vim.kinds = [
|
||||
\ {'short' : 'n', 'long' : 'vimball filenames', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'v', 'long' : 'variables', 'fold' : 1, 'stl' : 0},
|
||||
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
|
||||
\ {'short' : 'a', 'long' : 'autocommand groups', 'fold' : 1, 'stl' : 1},
|
||||
@@ -911,7 +886,7 @@ function! s:RestoreSession()
|
||||
|
||||
let s:last_autofocus = 0
|
||||
|
||||
call s:Init()
|
||||
call s:Init(0)
|
||||
|
||||
call s:InitWindow(g:tagbar_autoclose)
|
||||
|
||||
@@ -994,41 +969,95 @@ endfunction
|
||||
" s:CheckForExCtags() {{{2
|
||||
" Test whether the ctags binary is actually Exuberant Ctags and not GNU ctags
|
||||
" (or something else)
|
||||
function! s:CheckForExCtags()
|
||||
function! s:CheckForExCtags(silent)
|
||||
call s:LogDebugMessage('Checking for Exuberant Ctags')
|
||||
|
||||
if !exists('g:tagbar_ctags_bin')
|
||||
let ctagsbins = []
|
||||
let ctagsbins += ['ctags-exuberant'] " Debian
|
||||
let ctagsbins += ['exuberant-ctags']
|
||||
let ctagsbins += ['exctags'] " FreeBSD, NetBSD
|
||||
let ctagsbins += ['/usr/local/bin/ctags'] " Homebrew
|
||||
let ctagsbins += ['/opt/local/bin/ctags'] " Macports
|
||||
let ctagsbins += ['ectags'] " OpenBSD
|
||||
let ctagsbins += ['ctags']
|
||||
let ctagsbins += ['ctags.exe']
|
||||
let ctagsbins += ['tags']
|
||||
for ctags in ctagsbins
|
||||
if executable(ctags)
|
||||
let g:tagbar_ctags_bin = ctags
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
if !exists('g:tagbar_ctags_bin')
|
||||
if !a:silent
|
||||
echoerr 'Tagbar: Exuberant ctags not found!'
|
||||
echomsg 'Please download Exuberant Ctags from ctags.sourceforge.net'
|
||||
\ 'and install it in a directory in your $PATH'
|
||||
\ 'or set g:tagbar_ctags_bin.'
|
||||
endif
|
||||
let s:checked_ctags = 2
|
||||
return 0
|
||||
endif
|
||||
else
|
||||
" reset 'wildignore' temporarily in case *.exe is included in it
|
||||
let wildignore_save = &wildignore
|
||||
set wildignore&
|
||||
|
||||
let g:tagbar_ctags_bin = expand(g:tagbar_ctags_bin)
|
||||
|
||||
let &wildignore = wildignore_save
|
||||
|
||||
if !executable(g:tagbar_ctags_bin)
|
||||
if !a:silent
|
||||
echoerr "Tagbar: Exuberant ctags not found at " .
|
||||
\ "'" . g:tagbar_ctags_bin . "'!"
|
||||
echomsg 'Please check your g:tagbar_ctags_bin setting.'
|
||||
endif
|
||||
let s:checked_ctags = 2
|
||||
return 0
|
||||
endif
|
||||
endif
|
||||
|
||||
let ctags_cmd = s:EscapeCtagsCmd(g:tagbar_ctags_bin, '--version')
|
||||
if ctags_cmd == ''
|
||||
return
|
||||
let s:checked_ctags = 2
|
||||
return 0
|
||||
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 !a:silent
|
||||
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
|
||||
endif
|
||||
let s:checked_ctags = 2
|
||||
return 0
|
||||
elseif !s:CheckExCtagsVersion(ctags_output)
|
||||
echoerr 'Tagbar: Exuberant Ctags is too old!'
|
||||
echomsg 'You need at least version 5.5 for Tagbar to work.'
|
||||
\ 'Please download a newer version from ctags.sourceforge.net.'
|
||||
echomsg 'Executed command: "' . ctags_cmd . '"'
|
||||
if !empty(ctags_output)
|
||||
echomsg 'Command output:'
|
||||
for line in split(ctags_output, '\n')
|
||||
echomsg line
|
||||
endfor
|
||||
if !a:silent
|
||||
echoerr 'Tagbar: Exuberant Ctags is too old!'
|
||||
echomsg 'You need at least version 5.5 for Tagbar to work.'
|
||||
\ 'Please download a newer version from ctags.sourceforge.net.'
|
||||
echomsg 'Executed command: "' . ctags_cmd . '"'
|
||||
if !empty(ctags_output)
|
||||
echomsg 'Command output:'
|
||||
for line in split(ctags_output, '\n')
|
||||
echomsg line
|
||||
endfor
|
||||
endif
|
||||
endif
|
||||
let s:checked_ctags = 2
|
||||
return 0
|
||||
else
|
||||
let s:checked_ctags = 1
|
||||
@@ -1185,17 +1214,22 @@ endfunction
|
||||
|
||||
" s:BaseTag.getClosedParentTline() {{{3
|
||||
function! s:BaseTag.getClosedParentTline() dict
|
||||
let tagline = self.tline
|
||||
let tagline = self.tline
|
||||
let fileinfo = self.fileinfo
|
||||
|
||||
let parent = self.parent
|
||||
while !empty(parent)
|
||||
" Find the first closed parent, starting from the top of the hierarchy.
|
||||
let parents = []
|
||||
let curparent = self.parent
|
||||
while !empty(curparent)
|
||||
call add(parents, curparent)
|
||||
let curparent = curparent.parent
|
||||
endwhile
|
||||
for parent in reverse(parents)
|
||||
if parent.isFolded()
|
||||
let tagline = parent.tline
|
||||
break
|
||||
endif
|
||||
let parent = parent.parent
|
||||
endwhile
|
||||
endfor
|
||||
|
||||
return tagline
|
||||
endfunction
|
||||
@@ -1575,7 +1609,7 @@ function! s:OpenWindow(flags)
|
||||
" This is only needed for the CorrectFocusOnStartup() function
|
||||
let s:last_autofocus = autofocus
|
||||
|
||||
if !s:Init()
|
||||
if !s:Init(0)
|
||||
return 0
|
||||
endif
|
||||
|
||||
@@ -1609,13 +1643,14 @@ endfunction
|
||||
function! s:InitWindow(autoclose)
|
||||
call s:LogDebugMessage('InitWindow called with autoclose: ' . a:autoclose)
|
||||
|
||||
setlocal filetype=tagbar
|
||||
|
||||
setlocal noreadonly " in case the "view" mode is used
|
||||
setlocal buftype=nofile
|
||||
setlocal bufhidden=hide
|
||||
setlocal noswapfile
|
||||
setlocal nobuflisted
|
||||
setlocal nomodifiable
|
||||
setlocal filetype=tagbar
|
||||
setlocal nolist
|
||||
setlocal nonumber
|
||||
setlocal nowrap
|
||||
@@ -1623,6 +1658,7 @@ function! s:InitWindow(autoclose)
|
||||
setlocal textwidth=0
|
||||
setlocal nocursorline
|
||||
setlocal nocursorcolumn
|
||||
setlocal nospell
|
||||
|
||||
if exists('+relativenumber')
|
||||
setlocal norelativenumber
|
||||
@@ -2620,6 +2656,7 @@ function! s:HighlightTag(openfolds, ...)
|
||||
|
||||
let foldpat = '[' . s:icon_open . s:icon_closed . ' ]'
|
||||
let pattern = '/^\%' . tagline . 'l\s*' . foldpat . '[-+# ]\zs[^( ]\+\ze/'
|
||||
call s:LogDebugMessage("Highlight pattern: '" . pattern . "'")
|
||||
execute 'match TagbarHighlight ' . pattern
|
||||
|
||||
if a:0 == 0 " no line explicitly given, so assume we were in the file window
|
||||
@@ -3356,7 +3393,7 @@ function! tagbar#autoopen(...)
|
||||
call s:LogDebugMessage('tagbar#autoopen called on ' . bufname('%'))
|
||||
let always = a:0 > 0 ? a:1 : 1
|
||||
|
||||
call s:Init()
|
||||
call s:Init(0)
|
||||
|
||||
for bufnr in range(1, bufnr('$'))
|
||||
if buflisted(bufnr) && (always || bufwinnr(bufnr) != -1)
|
||||
@@ -3385,8 +3422,8 @@ function! tagbar#currenttag(fmt, default, ...)
|
||||
let fullpath = 0
|
||||
endif
|
||||
|
||||
if !s:Init()
|
||||
return ''
|
||||
if !s:Init(1)
|
||||
return a:default
|
||||
endif
|
||||
|
||||
let tag = s:GetNearbyTag(0)
|
||||
@@ -3400,7 +3437,7 @@ endfunction
|
||||
|
||||
" tagbar#gettypeconfig() {{{2
|
||||
function! tagbar#gettypeconfig(type)
|
||||
if !s:Init()
|
||||
if !s:Init(1)
|
||||
return ''
|
||||
endif
|
||||
|
||||
|
||||
+17
-5
@@ -3,7 +3,7 @@
|
||||
Author: Jan Larres <jan@majutsushi.net>
|
||||
Licence: Vim licence, see |license|
|
||||
Homepage: http://majutsushi.github.com/tagbar/
|
||||
Version: 2.4
|
||||
Version: 2.4.1
|
||||
|
||||
==============================================================================
|
||||
Contents *tagbar* *tagbar-contents*
|
||||
@@ -933,17 +933,21 @@ imporant tips to get it to integrate well with Tagbar:
|
||||
other fields need to have a fieldname in order to determine what they are.
|
||||
The following fields are supported for all filetypes:
|
||||
|
||||
* line: The line number of the tag
|
||||
* column: The column number of the tag
|
||||
* signature: The signature of a function
|
||||
* line: The line number of the tag.
|
||||
* column: The column number of the tag.
|
||||
* signature: The signature of a function.
|
||||
* access: Visibility/access information of a tag; the values
|
||||
"public", "protected" and "private" will be denoted with
|
||||
a special symbol in Tagbar
|
||||
a special symbol in Tagbar.
|
||||
|
||||
In addition fields that describe the surrounding scope of the tag are
|
||||
supported if they are specified in the type configuration as explained at
|
||||
the beginning of this section. For example, for a tag in class "Foo" this
|
||||
could look like "class:Foo".
|
||||
Important: the value of such a scope-specifying field should be the entire
|
||||
hierarchy of scopes that the tag is in, so if for example in C++ you have
|
||||
a member in class "Foo" which is in namespace "Bar" then the scope field
|
||||
should be "class:Bar::Foo".
|
||||
|
||||
==============================================================================
|
||||
7. Troubleshooting & Known issues *tagbar-issues*
|
||||
@@ -1018,6 +1022,14 @@ file.
|
||||
==============================================================================
|
||||
8. History *tagbar-history*
|
||||
|
||||
2.4.1 (2012-07-16)
|
||||
- Fixed some bugs related to the currenttag() function when it was called
|
||||
before the rest of the plugin was loaded. Also fail silently in case
|
||||
something goes wrong so the statusline doesn't get messed up.
|
||||
- In certain cases highlighting tags in deeply nested folds could cause an
|
||||
error message.
|
||||
- Spellchecking is now correctly getting disabled in the Tagbar window.
|
||||
|
||||
2.4 (2012-06-17)
|
||||
- New function tagbar#currenttag() that reports the current tag, for
|
||||
example for putting it into the statusline.
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
" Author: Jan Larres <jan@majutsushi.net>
|
||||
" Licence: Vim licence
|
||||
" Website: http://majutsushi.github.com/tagbar/
|
||||
" Version: 2.4
|
||||
" Version: 2.4.1
|
||||
" Note: This plugin was heavily inspired by the 'Taglist' plugin by
|
||||
" Yegappan Lakshmanan and uses a small amount of code from it.
|
||||
"
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
" Author: Jan Larres <jan@majutsushi.net>
|
||||
" Licence: Vim licence
|
||||
" Website: http://majutsushi.github.com/tagbar/
|
||||
" Version: 2.4
|
||||
" Version: 2.4.1
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
|
||||
Reference in New Issue
Block a user