Skip to content

Commit 0b84538

Browse files
committed
version 4.0 (released on Sep 6, 2006)
1 parent 6f9fb86 commit 0b84538

File tree

2 files changed

+157
-54
lines changed

2 files changed

+157
-54
lines changed

doc/taglist.txt

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
44
For Vim version 6.0 and above
5-
Last change: 2006 April 12
5+
Last change: 2006 September 6
66

77
1. Overview |taglist-intro|
88
2. Taglist on the internet |taglist-internet|
@@ -82,16 +82,16 @@ systems).
8282
The taglist plugin will work with Vim version 6.0 and above.
8383

8484
The taglist plugin relies on the exuberant ctags utility to dynamically
85-
generate the tag listing. You can download the exuberant ctags utility from
85+
generate the tag listing. The exuberant ctags utility must be installed in
86+
your system to use this plugin. You should use exuberant ctags version 5.0 and
87+
above. The exuberant ctags utility is shipped with most of the Linux
88+
distributions. You can download the exuberant ctags utility from
8689
>
8790
http://ctags.sourceforge.net
8891
<
89-
The exuberant ctags utility must be installed in your system to use this
90-
plugin. You should use exuberant ctags version 5.0 and above. This plugin
91-
doesn't use or create a tags file and there is no need to create a tags file
92-
to use this plugin. The taglist plugin will not work with the GNU ctags or the
93-
Unix ctags utility. The exuberant ctags utility is shipped with most of the
94-
Linux distributions.
92+
The taglist plugin doesn't use or create a tags file and there is no need to
93+
create a tags file to use this plugin. The taglist plugin will not work with
94+
the GNU ctags or the Unix ctags utility.
9595

9696
This plugin relies on the Vim "filetype" detection mechanism to determine the
9797
type of the current file. You have to turn on the Vim filetype detection by
@@ -124,9 +124,10 @@ Vim without the system() function for security reasons.
124124
directory, start Vim and run the ":helptags ." command to process the
125125
taglist help file. Without this step, you cannot jump to the taglist help
126126
topics.
127-
3. If the exuberant ctags utility is not present in your PATH, then set the
128-
'Tlist_Ctags_Cmd' variable to point to the location of the exuberant ctags
129-
utility (not to the directory) in the .vimrc file.
127+
3. If the exuberant ctags utility is not present in one of the directories in
128+
the PATH environment variable, then set the 'Tlist_Ctags_Cmd' variable to
129+
point to the location of the exuberant ctags utility (not to the directory)
130+
in the .vimrc file.
130131
4. If you are running a terminal/console version of Vim and the terminal
131132
doesn't support changing the window width then set the
132133
'Tlist_Inc_Winwidth' variable to 0 in the .vimrc file.
@@ -135,10 +136,46 @@ Vim without the system() function for security reasons.
135136
window. You can use the ":help taglist" command to get more information
136137
about using the taglist plugin.
137138

139+
To uninstall the taglist plugin, remove the plugin/taglist.vim and
140+
doc/taglist.txt files.
141+
138142
==============================================================================
139143
*taglist-using*
140144
5. Usage~
141145

146+
The taglist plugin can be used in several different ways.
147+
148+
1. You can open the taglist window and keep it open. On opening the taglist
149+
window, the tags defined in all the files in the Vim buffer list will be
150+
displayed in the taglist window. As you edit files, the tags defined in
151+
them will be added to the taglist window. You can select a tag from the
152+
taglist window and jump to it. The current tag will be highlighted in the
153+
taglist window. You can close the taglist window when you no longer need
154+
the window.
155+
2. You can configure the taglist plugin to process the tags defined in all the
156+
edited files always. In this configuration, even if the taglist window is
157+
closed and the taglist menu is not displayed, the taglist plugin will
158+
processes the tags defined in newly edited files. You can then open the
159+
taglist window only when you need to select a tag and then automatically
160+
close the taglist window after selecting the tag.
161+
3. You can configure the taglist plugin to display only the tags defined in
162+
the current file in the taglist window. By default, the taglist plugin
163+
displays the tags defined in all the files in the Vim buffer list. As you
164+
switch between files, the taglist window will be refreshed to display the
165+
tags defined only in the current file.
166+
4. You can use the Tags pull-down and popup menu created by the taglist plugin
167+
to display the tags defined in the current file and select a tag to jump to
168+
it. You can use the menu without opening the taglist window. By default,
169+
the Tags menu is disabled.
170+
5. You can configure the taglist plugin to display the name of the current tag
171+
in the Vim window status line or in the Vim window title bar. For this to
172+
work without the taglist window or menu, you need to configure the taglist
173+
plugin to process the tags defined in a file always.
174+
6. You can save the tags defined in multiple files to a taglist session file
175+
and load it when needed. You can also configure the taglist plugin to not
176+
update the taglist window when editing new files. You can then manually add
177+
files to the taglist window.
178+
142179
Opening the taglist window~
143180
You can open the taglist window using the ":TlistOpen" or the ":TlistToggle"
144181
commands. The ":TlistOpen" command opens the taglist window and jumps to it.
@@ -319,6 +356,10 @@ prototype of the current tag. For example,
319356
:TlistShowPrototype
320357
:TlistShowPrototype myfile.c 50
321358
<
359+
In the taglist window, when the mouse is moved over a tag name, the tag
360+
prototype is displayed in a balloon. This works only in GUI versions where
361+
balloon evaluation is supported.
362+
322363
Taglist window contents~
323364
The tag names are grouped by their type (variable, function, class, etc.). For
324365
tags with scope information (like class members, structures inside structures,
@@ -726,10 +767,9 @@ Tlist_File_Fold_Auto_Close~
726767
By default, the tags tree displayed in the taglist window for all the files is
727768
opened. You can close/fold the tags tree for the files manually. To
728769
automatically close the tags tree for inactive files, you can set the
729-
Tlist_File_Fold_Auto_Close variable to 1. When this variable is set to 1, if a
730-
Vim buffer is no longer displayed in a Vim window, the corresponding tags tree
731-
in the taglist window will be collapsed/folded. When a buffer is loaded in a
732-
Vim window, the corresponding tags tree will be opened.
770+
Tlist_File_Fold_Auto_Close variable to 1. When this variable is set to 1, the
771+
tags tree for the current buffer is automatically opened and for all the
772+
buffers is closed.
733773
>
734774
let Tlist_File_Fold_Auto_Close = 1
735775
<

plugin/taglist.vim

Lines changed: 102 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" File: taglist.vim
22
" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
3-
" Version: 4.0 Beta 4
4-
" Last Modified: April 12, 2006
3+
" Version: 4.0
4+
" Last Modified: September 6, 2006
55
"
66
" The "Tag List" plugin is a source code browser plugin for Vim and provides
77
" an overview of the structure of the programming language files and allows
@@ -252,20 +252,20 @@ if !exists('loaded_taglist')
252252
autocmd BufFilePost __Tag_List__ call s:Tlist_Vim_Session_Load()
253253

254254
" Define the user commands to manage the taglist window
255-
command! -nargs=0 TlistToggle call s:Tlist_Window_Toggle()
256-
command! -nargs=0 TlistOpen call s:Tlist_Window_Open()
255+
command! -nargs=0 -bar TlistToggle call s:Tlist_Window_Toggle()
256+
command! -nargs=0 -bar TlistOpen call s:Tlist_Window_Open()
257257
" For backwards compatiblity define the Tlist command
258-
command! -nargs=0 Tlist TlistToggle
258+
command! -nargs=0 -bar Tlist TlistToggle
259259
command! -nargs=+ -complete=file TlistAddFiles
260260
\ call s:Tlist_Add_Files(<f-args>)
261261
command! -nargs=+ -complete=dir TlistAddFilesRecursive
262262
\ call s:Tlist_Add_Files_Recursive(<f-args>)
263-
command! -nargs=0 TlistClose call s:Tlist_Window_Close()
264-
command! -nargs=0 TlistUpdate call s:Tlist_Update_Current_File()
265-
command! -nargs=0 TlistHighlightTag call s:Tlist_Window_Highlight_Tag(
263+
command! -nargs=0 -bar TlistClose call s:Tlist_Window_Close()
264+
command! -nargs=0 -bar TlistUpdate call s:Tlist_Update_Current_File()
265+
command! -nargs=0 -bar TlistHighlightTag call s:Tlist_Window_Highlight_Tag(
266266
\ fnamemodify(bufname('%'), ':p'), line('.'), 2, 1)
267267
" For backwards compatiblity define the TlistSync command
268-
command! -nargs=0 TlistSync TlistHighlightTag
268+
command! -nargs=0 -bar TlistSync TlistHighlightTag
269269
command! -nargs=* -complete=buffer TlistShowPrototype
270270
\ echo Tlist_Get_Tag_Prototype_By_Line(<f-args>)
271271
command! -nargs=* -complete=buffer TlistShowTag
@@ -274,14 +274,14 @@ if !exists('loaded_taglist')
274274
\ call s:Tlist_Session_Load(<q-args>)
275275
command! -nargs=* -complete=file TlistSessionSave
276276
\ call s:Tlist_Session_Save(<q-args>)
277-
command! TlistLock let Tlist_Auto_Update=0
278-
command! TlistUnlock let Tlist_Auto_Update=1
277+
command! TlistLock -bar let Tlist_Auto_Update=0
278+
command! TlistUnlock -bar let Tlist_Auto_Update=1
279279

280280
" Commands for enabling/disabling debug and to display debug messages
281-
command! -nargs=? -complete=file TlistDebug
281+
command! -nargs=? -complete=file -bar TlistDebug
282282
\ call s:Tlist_Debug_Enable(<q-args>)
283-
command! -nargs=0 TlistUndebug call s:Tlist_Debug_Disable()
284-
command! -nargs=0 TlistMessages echo s:tlist_msg
283+
command! -nargs=0 -bar TlistUndebug call s:Tlist_Debug_Disable()
284+
command! -nargs=0 -bar TlistMessages echo s:tlist_msg
285285

286286
" Define autocommands to autoload the taglist plugin when needed.
287287

@@ -468,7 +468,7 @@ let s:tlist_def_yacc_settings = 'yacc;l:label'
468468
"------------------- end of language specific options --------------------
469469

470470
" Vim window size is changed by the taglist plugin or not
471-
let s:tlist_winsize_chgd = 0
471+
let s:tlist_winsize_chgd = -1
472472
" Taglist window is maximized or not
473473
let s:tlist_win_maximized = 0
474474
" Name of files in the taglist
@@ -1244,20 +1244,22 @@ function! s:Tlist_Window_Create()
12441244
" Horizontal window height
12451245
let win_size = g:Tlist_WinHeight
12461246
else
1247-
" Open a vertically split window. Increase the window size, if
1248-
" needed, to accomodate the new window
1249-
if g:Tlist_Inc_Winwidth &&
1250-
\ &columns < (80 + g:Tlist_WinWidth)
1251-
" Save the original window position
1252-
let s:tlist_pre_winx = getwinposx()
1253-
let s:tlist_pre_winy = getwinposy()
1254-
1255-
" one extra column is needed to include the vertical split
1256-
let &columns= &columns + g:Tlist_WinWidth + 1
1257-
1258-
let s:tlist_winsize_chgd = 1
1259-
else
1260-
let s:tlist_winsize_chgd = 0
1247+
if s:tlist_winsize_chgd == -1
1248+
" Open a vertically split window. Increase the window size, if
1249+
" needed, to accomodate the new window
1250+
if g:Tlist_Inc_Winwidth &&
1251+
\ &columns < (80 + g:Tlist_WinWidth)
1252+
" Save the original window position
1253+
let s:tlist_pre_winx = getwinposx()
1254+
let s:tlist_pre_winy = getwinposy()
1255+
1256+
" one extra column is needed to include the vertical split
1257+
let &columns= &columns + g:Tlist_WinWidth + 1
1258+
1259+
let s:tlist_winsize_chgd = 1
1260+
else
1261+
let s:tlist_winsize_chgd = 0
1262+
endif
12611263
endif
12621264

12631265
if g:Tlist_Use_Right_Window
@@ -1315,6 +1317,26 @@ function! s:Tlist_Window_Zoom()
13151317
endif
13161318
endfunction
13171319

1320+
" Tlist_Ballon_Expr
1321+
" When the mouse cursor is over a tag in the taglist window, display the
1322+
" tag prototype (balloon)
1323+
function! Tlist_Ballon_Expr()
1324+
" Get the file index
1325+
let fidx = s:Tlist_Window_Get_File_Index_By_Linenum(v:beval_lnum)
1326+
if fidx == -1
1327+
return ''
1328+
endif
1329+
1330+
" Get the tag output line for the current tag
1331+
let tidx = s:Tlist_Window_Get_Tag_Index(fidx, v:beval_lnum)
1332+
if tidx == 0
1333+
return ''
1334+
endif
1335+
1336+
" Get the tag search pattern and display it
1337+
return s:Tlist_Get_Tag_Prototype(fidx, tidx)
1338+
endfunction
1339+
13181340
" Tlist_Window_Check_Width
13191341
" Check the width of the taglist window. For horizontally split windows, the
13201342
" 'winfixheight' option is used to fix the height of the window. For
@@ -1341,6 +1363,32 @@ function! s:Tlist_Window_Check_Width()
13411363
endif
13421364
endfunction
13431365

1366+
" Tlist_Window_Exit_Only_Window
1367+
" If the 'Tlist_Exit_OnlyWindow' option is set, then exit Vim if only the
1368+
" taglist window is present.
1369+
function! s:Tlist_Window_Exit_Only_Window()
1370+
" Before quitting Vim, delete the taglist buffer so that
1371+
" the '0 mark is correctly set to the previous buffer.
1372+
if v:version < 700
1373+
if winbufnr(2) == -1
1374+
bdelete
1375+
quit
1376+
endif
1377+
else
1378+
if winbufnr(2) == -1
1379+
if tabpagenr('$') == 1
1380+
" Only one tag page is present
1381+
bdelete
1382+
quit
1383+
else
1384+
" More than one tab page is present. Close only the current
1385+
" tab page
1386+
close
1387+
endif
1388+
endif
1389+
endif
1390+
endfunction
1391+
13441392
" Tlist_Window_Init
13451393
" Set the default options for the taglist window
13461394
function! s:Tlist_Window_Init()
@@ -1439,6 +1487,12 @@ function! s:Tlist_Window_Init()
14391487
set winfixwidth
14401488
endif
14411489

1490+
" Setup balloon evaluation to display tag prototype
1491+
if v:version >= 700 && has('balloon_eval')
1492+
setlocal balloonexpr=Tlist_Ballon_Expr()
1493+
set ballooneval
1494+
endif
1495+
14421496
" Setup the cpoptions properly for the maps to work
14431497
let old_cpoptions = &cpoptions
14441498
set cpoptions&vim
@@ -1531,17 +1585,15 @@ function! s:Tlist_Window_Init()
15311585

15321586
" Adjust the Vim window width when taglist window is closed
15331587
autocmd BufUnload __Tag_List__ call s:Tlist_Post_Close_Cleanup()
1534-
" Close the fold for this buffer when it's not visible in any window
1588+
" Close the fold for this buffer when leaving the buffer
15351589
if g:Tlist_File_Fold_Auto_Close
1536-
autocmd BufWinLeave * silent
1590+
autocmd BufWinLeave,BufLeave * silent
15371591
\ call s:Tlist_Window_Close_File_Fold(expand('<afile>:p'))
15381592
endif
15391593
" Exit Vim itself if only the taglist window is present (optional)
15401594
if g:Tlist_Exit_OnlyWindow
1541-
" Before quitting Vim, delete the taglist buffer so that
1542-
" the '0 mark is correctly set to the previous buffer.
1543-
autocmd BufEnter __Tag_List__ nested if winbufnr(2) == -1 |
1544-
\ bdelete | quit | endif
1595+
autocmd BufEnter __Tag_List__ nested
1596+
\ call s:Tlist_Window_Exit_Only_Window()
15451597
endif
15461598
if s:tlist_app_name != "winmanager" &&
15471599
\ !g:Tlist_Process_File_Always &&
@@ -1670,7 +1722,7 @@ function! s:Tlist_Post_Close_Cleanup()
16701722

16711723
if s:tlist_app_name != "winmanager"
16721724
if g:Tlist_Use_Horiz_Window || g:Tlist_Inc_Winwidth == 0 ||
1673-
\ s:tlist_winsize_chgd == 0 ||
1725+
\ s:tlist_winsize_chgd != 1 ||
16741726
\ &columns < (80 + g:Tlist_WinWidth)
16751727
" No need to adjust window width if using horizontally split taglist
16761728
" window or if columns is less than 101 or if the user chose not to
@@ -1689,6 +1741,8 @@ function! s:Tlist_Post_Close_Cleanup()
16891741
endif
16901742
endif
16911743

1744+
let s:tlist_winsize_chgd = -1
1745+
16921746
" Reset taglist state variables
16931747
if s:tlist_app_name == "winmanager"
16941748
let s:tlist_app_name = "none"
@@ -3006,6 +3060,15 @@ function! s:Tlist_Window_Open_File(win_ctrl, filename, tagpat)
30063060
" Mark the window, so that it can be reused.
30073061
let w:tlist_file_window = "yes"
30083062
else
3063+
if v:version >= 700
3064+
" If the file is opened in more than one window, then check
3065+
" whether the last accessed window has the selected file.
3066+
" If it does, then use that window.
3067+
let lastwin_bufnum = winbufnr(winnr('#'))
3068+
if bufnr(a:filename) == lastwin_bufnum
3069+
let winnum = winnr('#')
3070+
endif
3071+
endif
30093072
exe winnum . 'wincmd w'
30103073

30113074
" If the user asked to jump to the tag in a new window, then split the
@@ -3824,21 +3887,21 @@ endfunction
38243887
" Open the window only when files present in any of the Vim windows support
38253888
" tags.
38263889
function! s:Tlist_Window_Check_Auto_Open()
3827-
let open = 0
3890+
let open_window = 0
38283891

38293892
let i = 1
38303893
let buf_num = winbufnr(i)
38313894
while buf_num != -1
38323895
let filename = fnamemodify(bufname(buf_num), ':p')
38333896
if !s:Tlist_Skip_File(filename, getbufvar(buf_num, '&filetype'))
3834-
let open = 1
3897+
let open_window = 1
38353898
break
38363899
endif
38373900
let i = i + 1
38383901
let buf_num = winbufnr(i)
38393902
endwhile
38403903

3841-
if open
3904+
if open_window
38423905
call s:Tlist_Window_Toggle()
38433906
endif
38443907
endfunction

0 commit comments

Comments
 (0)