Version 2.7

1. Added TlistUpdate command to update the taglist window.
2. Made the taglist highlight groups user configurable.
3. Fixed a problem in the taglist integration with the winmanager plugin
This commit is contained in:
Yegappan Lakshmanan 2003-08-21 00:00:00 +00:00 committed by Able Scraper
parent 5c9f5bc85c
commit 642b3296e7
1 changed files with 144 additions and 38 deletions

View File

@ -1,7 +1,7 @@
" File: taglist.vim
" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
" Version: 2.6
" Last Modified: June 9, 2003
" Version: 2.7
" Last Modified: August 10, 2003
"
" Overview
" --------
@ -38,10 +38,9 @@
" 15. Can be easily extended to support new languages. Support for existing
" languages can be modified easily.
"
" To see the screenshots of the taglist plugin in different environments,
" visit the following page:
" You can visit the taglist plugin home page for more information:
"
" http://www.geocities.com/yegappan/taglist/screenshots.html
" http://www.geocities.com/yegappan/taglist
"
" This plugin relies on the exuberant ctags utility to dynamically generate
" the tag listing. You can download the exuberant ctags utility from
@ -119,10 +118,11 @@
"
" This plugin will automatically highlight the name of the current tag. The
" tag name will be highlighted after 'updatetime' milliseconds. The default
" value for this Vim option is 4 seconds. You can also use the ":TlistSync"
" command to force the highlighting of the current tag. You can map a key to
" invoke this command. For example, the following command creates a normal
" mapping for the <F9> key to highlight the current tag name.
" value for this Vim option is 4 seconds. You should not set the 'updatetime'
" option to very low values to avoid unexpected problems. You can also use the
" ":TlistSync" command to force the highlighting of the current tag. You can
" map a key to invoke this command. For example, the following command creates
" a normal mapping for the <F9> key to highlight the current tag name.
"
" nnoremap <silent> <F9> :TlistSync<CR>
"
@ -169,6 +169,16 @@
" ? Display help
"
"
" You can use the ":TlistUpdate" command to update the tags for the current
" buffer after you made some changes to it. This is equivalent to pressing 'u'
" in the taglist window. You should save the modified buffer before you update
" the tag list for it. Otherwise the listed tags will not include the new tags
" created in the buffer. You can map a key to invoke this command. For
" example, the following command creates a normal mode mapping for the <F7>
" key to update the taglist window.
"
" nnoremap <silent> <F7> :TlistUpdate<CR>
"
" You can use the ":TlistShowPrototype" command to display the prototype of
" a function in the specified line number. For example,
"
@ -186,6 +196,34 @@
"
" let winManagerWindowLayout = 'FileExplorer|TagList'
"
" If you have more than one tag with the same name and prototype in a file,
" then when you jump to one tag, the cursor may be positioned at the location
" of the other tag. For example, in a C++ file if you have functions with the
" same name and prototype in a file, then you will see this problem. This is
" due to the fact that the taglist plugin uses the search pattern generated by
" the exuberant ctags tool to position the cursor for a selected tag. The
" exuberant ctags generates the same search pattern for tags with the same
" prototype.
"
" The following highlight groups are defined and used to highlight the various
" entities in the taglist window:
"
" TagListTagName - Used for tag names
" TagListTagScope - Used for tag scope
" TagListTitle - Used for tag titles
" TagListComment - Used for comments in the taglist window
" TagListSortBy - Used for "sort by" text
" TagListCurDir - Used for current directory name
"
" By default, these highlight groups are linked to the standard Vim highlight
" groups. If you want to change these highlight groups, you can prepend 'My'
" to the above highlight group names and define them in your .vimrc file. The
" taglist plugin will use the defined highlight groups instead of the default
" groups. For example, to change the highlighting used for tag names, you can
" use:
"
" highlight MyTagListTagName guifg=cyan
"
" Configuration
" -------------
" By changing the following variables you can configure the behavior of this
@ -922,32 +960,57 @@ function! s:Tlist_Init_Window(bufnum)
" Mark the buffer as not modifiable
setlocal nomodifiable
" Highlight the comments
" Define taglist window element highlighting
if has('syntax')
syntax match TagListComment '^" .*'
syntax match TagListSortBy '^" Sorted by .*'
syntax match TagListCurDir '^"= .*'
syntax match TagScope '\s\[.\{-\}\]$'
syntax match TagListTagScope '\s\[.\{-\}\]$'
" Colors used to highlight the selected tag name
highlight clear TagName
" Define the highlighting only if the colors are supported
if has('gui_running') || &t_Co > 2
highlight link TagName Search
" Colors to highlight various taglist window elements
" If user defined highlighting group exists, then use them.
" Otherwise, use default highlight groups.
if hlexists('MyTagListTagName')
highlight link TagListTagName MyTagListTagName
else
highlight link TagListTagName Search
endif
" Colors to highlight comments and titles
if hlexists('MyTagListComment')
highlight link TagListComment MyTagListComment
else
highlight clear TagListComment
highlight link TagListComment Comment
endif
if hlexists('MyTagListTitle')
highlight link TagListTitle MyTagListTitle
else
highlight clear TagListTitle
highlight link TagListTitle Title
endif
if hlexists('MyTagListSortBy')
highlight link TagListSortBy MyTagListSortBy
else
highlight clear TagListSortBy
highlight link TagListSortBy String
endif
if hlexists('MyTagListCurDir')
highlight link TagListCurDir MyTagListCurDir
else
highlight clear TagListCurDir
highlight link TagListCurDir Statement
endif
if hlexists('MyTagListTagScope')
highlight link TagListTagScope MyTagListTagScope
else
highlight clear TagListTagScope
highlight link TagListTagScope Identifier
endif
else
highlight TagName term=reverse cterm=reverse
highlight TagListTagName term=reverse cterm=reverse
endif
" Colors to highlight comments and titles
highlight clear TagListComment
highlight link TagListComment Comment
highlight clear TagListTitle
highlight link TagListTitle Title
highlight clear TagListSortBy
highlight link TagListSortBy String
highlight clear TagListCurDir
highlight link TagListCurDir Statement
highlight clear TagScope
highlight link TagScope Identifier
endif
" Folding related settings
@ -1052,7 +1115,7 @@ function! s:Tlist_Post_Close_Cleanup()
match none
if has('syntax')
silent! syntax clear TagListTitle
silent! syntax clear
endif
" Remove the left mouse click mapping if it was setup initially
@ -1374,13 +1437,15 @@ endfunction
function! s:Tlist_Close_Window()
" Make sure the taglist window exists
let winnum = bufwinnr(g:TagList_title)
if winnum != -1
" Jump to the window if not already there
if winnr() != winnum
exe winnum . 'wincmd w'
endif
close
if winnum == -1
call s:Tlist_Warning_Msg('Error: Taglist window is not open')
return
endif
" Jump to the window if not already there
if winnr() != winnum
exe winnum . 'wincmd w'
endif
close
endfunction
" Tlist_Toggle_Window()
@ -1548,6 +1613,45 @@ function! s:Tlist_Change_Sort()
call search(curline, 'w')
endfunction
" Tlist_Update_Tags()
" Update taglist for the current buffer by regenerating the tag list
" Contributed by WEN Guopeng.
function! s:Tlist_Update_Tags()
" If taglist window is not open, show an error message:
let winnum = bufwinnr(g:TagList_title)
if winnum == -1
call s:Tlist_Warning_Msg('Error: Taglist window is not open')
return 0
endif
" Update the tag list window only if it's open
if winnr() == winnum
" Already in the taglist window, simply update the window content
call s:Tlist_Update_Window()
else
" First check the current buffer is modified or not:
if &modified
let msg = "No write since last change, tag list may be inaccurate"
call s:Tlist_Warning_Msg(msg)
endif
" Goto the taglist window, update it and get back to the original
" window:
let curbufnr = bufnr('%')
exe winnum . 'wincmd w'
call s:Tlist_Update_Window()
" Need to jump back to the original window only if we are not
" already in that window
let winnum = bufwinnr(curbufnr)
if winnr() != winnum
exe winnum . 'wincmd w'
endif
endif
return 1
endfunction
" Tlist_Update_Window()
" Update the window by regenerating the tag list
function! s:Tlist_Update_Window()
@ -1615,9 +1719,9 @@ function! s:Tlist_Highlight_Tagline()
" Highlight the current selected name
if g:Tlist_Display_Prototype == 0
exe 'match TagName /\%' . line('.') . 'l\s\+\zs.*/'
exe 'match TagListTagName /\%' . line('.') . 'l\s\+\zs.*/'
else
exe 'match TagName /\%' . line('.') . 'l.*/'
exe 'match TagListTagName /\%' . line('.') . 'l.*/'
endif
endfunction
@ -1629,7 +1733,7 @@ endfunction
function! s:Tlist_Jump_To_Tag(win_ctrl)
" Do not process comment lines and empty lines
let curline = getline('.')
if curline == '' || curline[0] == '"'
if curline =~ '^\s*$' || curline[0] == '"'
return
endif
@ -1732,7 +1836,7 @@ function! s:Tlist_Show_Tag_Prototype()
" Do not process comment lines and empty lines
let curline = getline('.')
if curline == '' || curline[0] == '"'
if curline =~ '^\s*$' || curline[0] == '"'
return
endif
@ -1851,6 +1955,7 @@ function! s:Tlist_Highlight_Tag(bufnum, curline)
" Make sure the taglist window is present
let winnum = bufwinnr(g:TagList_title)
if winnum == -1
call s:Tlist_Warning_Msg('Error: Taglist window is not open')
return
endif
@ -1979,6 +2084,7 @@ endif
" Define the user commands to manage the taglist window
command! -nargs=0 Tlist call s:Tlist_Toggle_Window(bufnr('%'))
command! -nargs=0 TlistClose call s:Tlist_Close_Window()
command! -nargs=0 TlistUpdate call s:Tlist_Update_Tags()
command! -nargs=0 TlistSync call s:Tlist_Highlight_Tag(bufnr('%'), line('.'))
command! -nargs=? TlistShowPrototype echo s:Tlist_Get_Tag_Prototype_By_Line(<q-args>)