Version 4.3

1. Added support for jumping to a tag/file in a new or existing tab
   from the taglist window (works only with Vim7 and above).
2. Added support for opening a tag in the previous window.
3. With the Tlist_File_Fold_Auto_Close variable set, when opening a
   file from the file explorer window, the folds in the taglist window
   are not closed correctly.  Fixed this problem.
This commit is contained in:
Yegappan Lakshmanan 2007-02-22 00:00:00 +00:00 committed by Able Scraper
parent 569d438e14
commit d6a611f70a
2 changed files with 289 additions and 132 deletions

View File

@ -2,7 +2,7 @@
Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
For Vim version 6.0 and above
Last change: 2006 November 14
Last change: 2007 February 18
1. Overview |taglist-intro|
2. Taglist on the internet |taglist-internet|
@ -14,7 +14,8 @@ Last change: 2006 November 14
8. Global functions |taglist-functions|
9. Extending |taglist-extend|
10. FAQ |taglist-faq|
11. Todo |taglist-todo|
11. License |taglist-license|
12. Todo |taglist-todo|
==============================================================================
*taglist-intro*
@ -75,17 +76,20 @@ for subscribing to the mailing list:
*taglist-requirements*
3. Requirements~
The taglist plugin requires the following:
* Vim version 6.0 and above
* Exuberant ctags 5.0 and above
The taglist plugin will work on all the platforms where the exuberant ctags
utility and Vim are supported (this includes MS-Windows and Unix based
systems).
The taglist plugin will work with Vim version 6.0 and above.
The taglist plugin relies on the exuberant ctags utility to dynamically
generate the tag listing. The exuberant ctags utility must be installed in
your system to use this plugin. You should use exuberant ctags version 5.0 and
above. The exuberant ctags utility is shipped with most of the Linux
distributions. You can download the exuberant ctags utility from
your system to use this plugin. The exuberant ctags utility is shipped with
most of the Linux distributions. You can download the exuberant ctags utility
from
>
http://ctags.sourceforge.net
<
@ -118,8 +122,8 @@ Vim without the system() function for security reasons.
plugin/taglist.vim - main taglist plugin file
doc/taglist.txt - documentation (help) file
Refer to the |add-plugin|, |add-global-plugin| and |'runtimepath'| Vim
help pages for more details about installing Vim plugins.
Refer to the |add-plugin|and |'runtimepath'| Vim help pages for more
details about installing Vim plugins.
2. Change to the $HOME/.vim/doc or $HOME/vimfiles/doc or $VIM/vimfiles/doc
directory, start Vim and run the ":helptags ." command to process the
taglist help file. Without this step, you cannot jump to the taglist help
@ -137,7 +141,7 @@ Vim without the system() function for security reasons.
about using the taglist plugin.
To uninstall the taglist plugin, remove the plugin/taglist.vim and
doc/taglist.txt files.
doc/taglist.txt files from the $HOME/.vim or $HOME/vimfiles directory.
==============================================================================
*taglist-using*
@ -145,13 +149,13 @@ doc/taglist.txt files.
The taglist plugin can be used in several different ways.
1. You can open the taglist window and keep it open. On opening the taglist
window, the tags defined in all the files in the Vim buffer list will be
displayed in the taglist window. As you edit files, the tags defined in
them will be added to the taglist window. You can select a tag from the
taglist window and jump to it. The current tag will be highlighted in the
taglist window. You can close the taglist window when you no longer need
the window.
1. You can keep the taglist window open during the entire editing session. On
opening the taglist window, the tags defined in all the files in the Vim
buffer list will be displayed in the taglist window. As you edit files, the
tags defined in them will be added to the taglist window. You can select a
tag from the taglist window and jump to it. The current tag will be
highlighted in the taglist window. You can close the taglist window when
you no longer need the window.
2. You can configure the taglist plugin to process the tags defined in all the
edited files always. In this configuration, even if the taglist window is
closed and the taglist menu is not displayed, the taglist plugin will
@ -161,12 +165,12 @@ The taglist plugin can be used in several different ways.
3. You can configure the taglist plugin to display only the tags defined in
the current file in the taglist window. By default, the taglist plugin
displays the tags defined in all the files in the Vim buffer list. As you
switch between files, the taglist window will be refreshed to display the
tags defined only in the current file.
4. You can use the Tags pull-down and popup menu created by the taglist plugin
to display the tags defined in the current file and select a tag to jump to
it. You can use the menu without opening the taglist window. By default,
the Tags menu is disabled.
switch between files, the taglist window will be refreshed to display only
the tags defined in the current file.
4. In GUI Vim, you can use the Tags pull-down and popup menu created by the
taglist plugin to display the tags defined in the current file and select a
tag to jump to it. You can use the menu without opening the taglist window.
By default, the Tags menu is disabled.
5. You can configure the taglist plugin to display the name of the current tag
in the Vim window status line or in the Vim window title bar. For this to
work without the taglist window or menu, you need to configure the taglist
@ -189,11 +193,13 @@ creates a normal mode mapping for the <F8> key to toggle the taglist window.
>
nnoremap <silent> <F8> :TlistToggle<CR>
<
Add the above mapping to your ~/.vimrc file.
Add the above mapping to your ~/.vimrc or $HOME/_vimrc file.
To automatically open the taglist window on Vim startup, set the
'Tlist_Auto_Open' variable to 1. You can also open the taglist window on
startup using the following command line:
'Tlist_Auto_Open' variable to 1.
You can also open the taglist window on startup using the following command
line:
>
$ vim +TlistOpen
<
@ -211,12 +217,27 @@ taglist window is present, set the 'Tlist_Exit_OnlyWindow' variable to 1.
Jumping to a tag or a file~
You can select a tag in the taglist window either by pressing the <Enter> key
or by double clicking the tag name using the mouse. To jump to a tag on a
single mouse click set the 'Tlist_Use_SingleClick' variable to 1. To jump to
the tag in a new window, press the 'o' key. You can press the 'p' key to jump
to the tag but still keep the cursor in the taglist window itself (preview).
single mouse click set the 'Tlist_Use_SingleClick' variable to 1.
You can open a file by pressing the <Enter> key or by double clicking the file
name using the mouse.
If the selected file is already opened in a window, then the cursor is moved
to that window. If the file is not currently opened in a window then the file
is opened in the window used by the taglist plugin to show the previously
selected file. If there are no usable windows, then the file is opened in a
new window. The file is not opened in special windows like the quickfix
window, preview window and windows containing buffer with the 'buftype' option
set.
To jump to the tag in a new window, press the 'o' key. To open the file in the
previous window (Ctrl-W_p) use the 'P' key. You can press the 'p' key to jump
to the tag but still keep the cursor in the taglist window (preview).
To open the selected file in a tab, use the 't' key. If the file is already
present in a tab then the cursor is moved to that tab otherwise the file is
opened in a new tab. To jump to a tag in a new tab press Ctrl-t. The taglist
window is automatically opened in the newly created tab.
Instead of jumping to a tag, you can open a file by pressing the <Enter> key
or by double clicking the file name using the mouse.
In the taglist window, you can use the [[ or <Backspace> key to jump to the
beginning of the previous file. You can use the ]] or <Tab> key to jump to the
@ -289,8 +310,8 @@ Vim session. To again display the tags for the file, open the file in a Vim
window and then use the ":TlistUpdate" command or use ":TlistAddFiles" command
to add the file to the taglist.
When a buffer is removed from the Vim buffer list using the ":bdelete" or
the ":bwipe" command, the taglist is updated to remove the stored information
When a buffer is removed from the Vim buffer list using the ":bdelete" or the
":bwipeout" command, the taglist is updated to remove the stored information
for this buffer.
Updating the tags displayed for a file~
@ -337,8 +358,9 @@ option is 4 seconds.
You can get the name and prototype of a tag without opening the taglist window
and the taglist menu using the ":TlistShowTag" and the ":TlistShowPrototype"
commands. To use these commands without the taglist window, set the
'Tlist_Process_File_Always' variable to 1.
commands. These commands will work only if the current file is already present
in the taglist. To use these commands without opening the taglist window, set
the 'Tlist_Process_File_Always' variable to 1.
You can use the ":TlistShowTag" command to display the name of the tag at or
before the specified line number in the specified file. If the file name and
@ -361,10 +383,11 @@ prototype is displayed in a balloon. This works only in GUI versions where
balloon evaluation is supported.
Taglist window contents~
The tag names are grouped by their type (variable, function, class, etc.). For
tags with scope information (like class members, structures inside structures,
etc.), the scope information is displayed in square brackets "[]" after the tag
name.
The taglist window contains the tags defined in various files in the taglist
grouped by the filename and by the tag type (variable, function, class, etc.).
For tags with scope information (like class members, structures inside
structures, etc.), the scope information is displayed in square brackets "[]"
after the tag name.
The contents of the taglist buffer/window are managed by the taglist plugin.
The |'filetype'| for the taglist buffer is set to 'taglist'. The Vim
@ -465,11 +488,13 @@ various entities in the taglist window:
TagListFileName - Used for filenames
By default, these highlight groups are linked to the standard Vim highlight
groups. If you want to change the colors used for these highlight groups, you
can define them in your .vimrc or .gvimrc files. For example, to change the
highlighting used for tag names, you can use:
groups. If you want to change the colors used for these highlight groups,
prefix the highlight group name with 'My' and define it in your .vimrc or
.gvimrc file: MyTagListTagName, MyTagListTagScope, MyTagListTitle,
MyTagListComment and MyTagListFileName. For example, to change the colors
used for tag names, you can use the following command:
>
:highlight TagListTagName guifg=DarkGreen ctermfg=DarkGreen
:highlight MyTagListTagName guifg=blue ctermfg=blue
<
Controlling the taglist window~
To use a horizontally split taglist window, instead of a vertically split
@ -510,8 +535,12 @@ in the taglist window.
defined.
o Jump to the location where the tag under cursor is
defined in a new window.
P Jump to the tag in the previous (Ctrl-W_p) window.
p Display the tag definition in the file window and
keep the cursor in the taglist window itself.
t Jump to the tag in a new tab. If the file is already
opened in a tab, move to that tab.
Ctrl-t Jump to the tag in a new tab.
<Space> Display the prototype of the tag under the cursor.
For file names, display the full path to the file,
file type and the number of tags. For tag types, display the
@ -548,7 +577,9 @@ When you switch between files/buffers, the taglist menu is automatically
updated to display the tags defined in the current file/buffer.
The tags are grouped by their type (variables, functions, classes, methods,
etc.) and displayed as a separate sub-menu for each type.
etc.) and displayed as a separate sub-menu for each type. If all the tags
defined in a file are of the same type (e.g. functions), then the sub-menu is
not used.
If the number of items in a tag type submenu exceeds the value specified by
the 'Tlist_Max_Submenu_Items' variable, then the submenu will be split into
@ -655,14 +686,14 @@ description of these variables refer to the text below this table.
Tlist_Auto_Highlight_Tag~
The taglist plugin will automatically highlight the current tag in the taglist
window. If you want to disable this, then you can set the
Tlist_Auto_Highlight_Tag variable to zero. Note that even though the current
'Tlist_Auto_Highlight_Tag' variable to zero. Note that even though the current
tag highlighting is disabled, the tags for a new file will still be added to
the taglist window.
>
let Tlist_Auto_Highlight_Tag = 0
<
You can still use the ":TlistHighlightTag" command to highlight the current
tag.
With the above variable set to 1, you can use the ":TlistHighlightTag" command
to highlight the current tag.
*'Tlist_Auto_Open'*
Tlist_Auto_Open~
@ -685,12 +716,15 @@ to 1.
>
let Tlist_Auto_Update = 0
<
With the above variable set to 1, you can use the ":TlistUpdate" command to
add the tags defined in the current file to the taglist.
*'Tlist_Close_On_Select'*
Tlist_Close_On_Select~
If you want to close the taglist window when a file or tag is selected, then
set the 'Tlist_Close_On_Select' variable to 1. By default, this variable is
set zero and when you select a tag or file from the taglist window, the window
will not be closed.
is not closed.
>
let Tlist_Close_On_Select = 1
<
@ -721,7 +755,7 @@ the ctags utility in your system. Note that this variable should point to the
fully qualified exuberant ctags location and NOT to the directory in which
exuberant ctags is installed. If the exuberant ctags tool is not found in
either PATH or in the specified location, then the taglist plugin will not be
loaded.
loaded. Examples:
>
let Tlist_Ctags_Cmd = 'd:\tools\ctags.exe'
let Tlist_Ctags_Cmd = '/usr/local/bin/ctags'
@ -767,9 +801,9 @@ Tlist_File_Fold_Auto_Close~
By default, the tags tree displayed in the taglist window for all the files is
opened. You can close/fold the tags tree for the files manually. To
automatically close the tags tree for inactive files, you can set the
Tlist_File_Fold_Auto_Close variable to 1. When this variable is set to 1, the
tags tree for the current buffer is automatically opened and for all the
buffers is closed.
'Tlist_File_Fold_Auto_Close' variable to 1. When this variable is set to 1,
the tags tree for the current buffer is automatically opened and for all the
other buffers is closed.
>
let Tlist_File_Fold_Auto_Close = 1
<
@ -798,10 +832,10 @@ this variable is 1.
*'Tlist_Inc_Winwidth'*
Tlist_Inc_Winwidth~
By default, when the width of the window is less than 100 and a new taglist
window is opened vertically, then the window width will be increased by the
value set in the 'Tlist_WinWidth' variable to accommodate the new window. The
value of this variable is used only if you are using a vertically split
taglist window.
window is opened vertically, then the window width is increased by the value
set in the 'Tlist_WinWidth' variable to accommodate the new window. The value
of this variable is used only if you are using a vertically split taglist
window.
If your terminal doesn't support changing the window width from Vim (older
version of xterm running in a Unix system) or if you see any weird problems in
@ -1166,52 +1200,64 @@ C++, C#, Cobol, Eiffel, Erlang, Fortran, HTML, Java, Javascript, Lisp, Lua,
Make, Pascal, Perl, PHP, Python, Rexx, Ruby, Scheme, Shell, Slang, SML, Sql,
TCL, Verilog, Vim and Yacc.
You can modify the taglist plugin support for the above listed languages. You
can also extend the taglist plugin to add support for new languages.
You can extend the taglist plugin to add support for new languages and also
modify the support for the above listed languages.
If you want to add support for a new language to the taglist plugin, you need
to first extend the exuberant ctags tool. For more information about extending
exuberant ctags, visit http://ctags.sourceforge.net/EXTENDING.html
You should NOT make modifications to the taglist plugin script file to add
support for new languages. You will lose these changes when you upgrade to the
next version of the taglist plugin. Instead you should follow the below
described instructions to extend the taglist plugin.
You can extend the taglist plugin to add support for new languages or modify
the support for an already supported language by setting the following
variables in the .vimrc file.
You can extend the taglist plugin by setting variables in the .vimrc or _vimrc
file. The name of these variables depends on the language name and is
described below.
Modifying support for an existing language~
To modify the support for an already supported language, you have to set the
tlist_xxx_settings variable. Replace xxx with the Vim filetype name. To
determine the filetype name used by Vim for a file, use the following command
in the buffer containing the file: >
tlist_xxx_settings variable in the ~/.vimrc or $HOME/_vimrc file. Replace xxx
with the Vim filetype name for the language file. For example, to modify the
support for the perl language files, you have to set the tlist_perl_settings
variable. To modify the support for java files, you have to set the
tlist_java_settings variable.
To determine the filetype name used by Vim for a file, use the following
command in the buffer containing the file:
:set filetype
<
For example, to modify the support for the perl language files, you have to
set the tlist_perl_settings variable.
The above command will display the Vim filetype for the current buffer.
The format of the value set in the tlist_xxx_settings variable is
>
<language_name>;flag1:name1;flag2:name2;flag3:name3
<
<language_name>;flag1:name1;flag2:name2;flag3:name3
The different fields in the value are separated by the ';' character.
The first field 'language_name' is the name used by exuberant ctags to refer
to this language files. This name can be different from the file type name
used by Vim. For example, for C++, the language name used by ctags is 'c++'
but the filetype name used by Vim is 'cpp'.
to this language file. This name can be different from the file type name used
by Vim. For example, for C++, the language name used by ctags is 'c++' but the
filetype name used by Vim is 'cpp'. To get the list of language names
supported by exuberant ctags, use the following command:
$ ctags --list-maps=all
The remaining fields follow the format "flag:name". The sub-field 'flag' is
the language specific flag used by exuberant ctags to generate the
corresponding tags. For example, for the C language, to list only the
functions, the 'f' flag is used. For more information about the flags
supported by exuberant ctags for a particular language, read the help text
from the 'ctags --help' command. The sub-field 'name' specifies the title text
to use for displaying the tags of a particular type. For example, 'name' can
be set to 'functions'. This field can be set to any text string name.
functions, the 'f' flag is used. To get the list of flags supported by
exuberant ctags for the various languages use the following command:
$ ctags --list-kinds=all
The sub-field 'name' specifies the title text to use for displaying the tags
of a particular type. For example, 'name' can be set to 'functions'. This
field can be set to any text string name.
For example, to list only the classes and functions defined in a C++ language
file, add the following line to your .vimrc file:
For example, to list only the classes and functions defined in a C++
language file, add the following lines to your .vimrc file
>
let tlist_cpp_settings = 'c++;c:class;f:function'
<
In the above setting, 'cpp' is the Vim filetype name and 'c++' is the name
used by the exuberant ctags tool. 'c' and 'f' are the flags passed to
exuberant ctags to list C++ classes and functions and 'class' is the title
@ -1220,23 +1266,32 @@ in the taglist window.
For example, to display only functions defined in a C file and to use "My
Functions" as the title for the function tags, use
>
let tlist_c_settings = 'c;f:My Functions'
<
When you set the tlist_xxx_settings variable, you will override the default
setting used by the taglist plugin for the 'xxx' language. You cannot add to
the default options used by the taglist plugin for a particular file type.
the default options used by the taglist plugin for a particular file type. To
add to the options used by the taglist plugin for a language, copy the option
values from the taglist plugin file to your .vimrc file and modify it.
To add support for a new language, set the tlist_xxx_settings variable
appropriately as described above. Replace 'xxx' in the variable name with the
Vim filetype name for the new language.
Adding support for a new language~
If you want to add support for a new language to the taglist plugin, you need
to first extend the exuberant ctags tool. For more information about extending
exuberant ctags, visit the following page:
http://ctags.sourceforge.net/EXTENDING.html
To add support for a new language, set the tlist_xxx_settings variable in the
~/.vimrc file appropriately as described above. Replace 'xxx' in the variable
name with the Vim filetype name for the new language.
For example, to extend the taglist plugin to support the latex language, you
can use the following line (assuming, you have already extended exuberant
ctags to support the latex language): >
ctags to support the latex language):
let tlist_tex_settings='latex;b:bibitem;c:command;l:label'
<
With the above line, when you edit files of filetype "tex" in Vim, the taglist
plugin will invoke the exuberant ctags tool passing the "latex" filetype and
the flags b, c and l to generate the tags. The text heading 'bibitem',
@ -1262,6 +1317,16 @@ A. Are you using Vim version 6.0 and above? The taglist plugin relies on the
>
$ ctags --version
<
Is exuberant ctags present in one of the directories in your PATH? If not,
you need to set the Tlist_Ctags_Cmd variable to point to the location of
exuberant ctags. Use the following Vim command to verify that this is setup
correctly:
>
:echo system(Tlist_Ctags_Cmd . ' --version')
<
The above command should display the version information for exuberant
ctags.
Did you turn on the Vim filetype detection? The taglist plugin relies on
the filetype detected by Vim and passes the filetype to the exuberant ctags
utility to parse the tags. Check the output of the following Vim command:
@ -1399,9 +1464,19 @@ A. The taglist plugin uses the |CursorHold| autocmd to highlight the current
the current buffer. The workaround for this problem is to not set the
|'updatetime'| option to a low value.
==============================================================================
*taglist-license*
11. License~
Permission is hereby granted to use and distribute the taglist plugin, with or
without modifications, provided that this copyright notice is copied with it.
Like anything else that's free, taglist.vim is provided *as is* and comes with
no warranty of any kind, either expressed or implied. In no event will the
copyright holder be liable for any damamges resulting from the use of this
software.
==============================================================================
*taglist-todo*
11. Todo~
12. Todo~
1. Group tags according to the scope and display them. For example,
group all the tags belonging to a C++/Java class

View File

@ -1,7 +1,7 @@
" File: taglist.vim
" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
" Version: 4.2
" Last Modified: November 14, 2006
" Version: 4.3
" Last Modified: February 18, 2007
" Copyright: Copyright (C) 2002-2006 Yegappan Lakshmanan
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
@ -41,7 +41,7 @@
" Refer to the 'add-plugin', 'add-global-plugin' and 'runtimepath'
" Vim help pages for more details about installing Vim plugins.
" 2. Change to the $HOME/.vim/doc or $HOME/vimfiles/doc or
" $VIM/doc/vimfiles directory, start Vim and run the ":helptags ."
" $VIM/vimfiles/doc directory, start Vim and run the ":helptags ."
" command to process the taglist help file.
" 3. If the exuberant ctags utility is not present in your PATH, then set the
" Tlist_Ctags_Cmd variable to point to the location of the exuberant ctags
@ -638,13 +638,8 @@ function! s:Tlist_Debug_Disable(...)
endfunction
" Tlist_Debug_Show
" Display the taglist debug message in a new window
" Display the taglist debug messages in a new window
function! s:Tlist_Debug_Show()
if s:tlist_debug == 0
call s:Tlist_Warning_Msg('Taglist: Debug is disabled')
return
endif
if s:tlist_msg == ''
call s:Tlist_Warning_Msg('Taglist: No debug messages')
return
@ -1551,10 +1546,22 @@ function! s:Tlist_Window_Init()
set cpoptions&vim
" Create buffer local mappings for jumping to the tags and sorting the list
nnoremap <buffer> <silent> <CR> :call <SID>Tlist_Window_Jump_To_Tag(0)<CR>
nnoremap <buffer> <silent> o :call <SID>Tlist_Window_Jump_To_Tag(1)<CR>
nnoremap <buffer> <silent> p :call <SID>Tlist_Window_Jump_To_Tag(2)<CR>
nnoremap <buffer> <silent> <2-LeftMouse> :call <SID>Tlist_Window_Jump_To_Tag(0)<CR>
nnoremap <buffer> <silent> <CR>
\ :call <SID>Tlist_Window_Jump_To_Tag('useopen')<CR>
nnoremap <buffer> <silent> o
\ :call <SID>Tlist_Window_Jump_To_Tag('newwin')<CR>
nnoremap <buffer> <silent> p
\ :call <SID>Tlist_Window_Jump_To_Tag('preview')<CR>
nnoremap <buffer> <silent> P
\ :call <SID>Tlist_Window_Jump_To_Tag('prevwin')<CR>
if v:version >= 700
nnoremap <buffer> <silent> t
\ :call <SID>Tlist_Window_Jump_To_Tag('checktab')<CR>
nnoremap <buffer> <silent> <C-t>
\ :call <SID>Tlist_Window_Jump_To_Tag('newtab')<CR>
endif
nnoremap <buffer> <silent> <2-LeftMouse>
\ :call <SID>Tlist_Window_Jump_To_Tag('useopen')<CR>
nnoremap <buffer> <silent> s
\ :call <SID>Tlist_Change_Sort('cmd', 'toggle', '')<CR>
nnoremap <buffer> <silent> + :silent! foldopen<CR>
@ -1576,13 +1583,25 @@ function! s:Tlist_Window_Init()
nnoremap <buffer> <silent> q :close<CR>
" Insert mode mappings
inoremap <buffer> <silent> <CR> <C-o>:call <SID>Tlist_Window_Jump_To_Tag(0)<CR>
inoremap <buffer> <silent> <CR>
\ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('useopen')<CR>
" Windows needs return
inoremap <buffer> <silent> <Return> <C-o>:call <SID>Tlist_Window_Jump_To_Tag(0)<CR>
inoremap <buffer> <silent> o <C-o>:call <SID>Tlist_Window_Jump_To_Tag(1)<CR>
inoremap <buffer> <silent> p <C-o>:call <SID>Tlist_Window_Jump_To_Tag(2)<CR>
inoremap <buffer> <silent> <2-LeftMouse> <C-o>:call
\ <SID>Tlist_Window_Jump_To_Tag(0)<CR>
inoremap <buffer> <silent> <Return>
\ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('useopen')<CR>
inoremap <buffer> <silent> o
\ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('newwin')<CR>
inoremap <buffer> <silent> p
\ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('preview')<CR>
inoremap <buffer> <silent> P
\ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('prevwin')<CR>
if v:version >= 700
inoremap <buffer> <silent> t
\ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('checktab')<CR>
inoremap <buffer> <silent> <C-t>
\ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('newtab')<CR>
endif
inoremap <buffer> <silent> <2-LeftMouse>
\ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('useopen')<CR>
inoremap <buffer> <silent> s
\ <C-o>:call <SID>Tlist_Change_Sort('cmd', 'toggle', '')<CR>
inoremap <buffer> <silent> + <C-o>:silent! foldopen<CR>
@ -1613,7 +1632,8 @@ function! s:Tlist_Window_Init()
" not fire the <buffer> <leftmouse> when you use the mouse
" to enter a buffer.
let clickmap = ':if bufname("%") =~ "__Tag_List__" <bar> ' .
\ 'call <SID>Tlist_Window_Jump_To_Tag(0) <bar> endif <CR>'
\ 'call <SID>Tlist_Window_Jump_To_Tag("useopen") ' .
\ '<bar> endif <CR>'
if maparg('<leftmouse>', 'n') == ''
" no mapping for leftmouse
exe ':nnoremap <silent> <leftmouse> <leftmouse>' . clickmap
@ -1642,7 +1662,7 @@ function! s:Tlist_Window_Init()
" Close the fold for this buffer when leaving the buffer
if g:Tlist_File_Fold_Auto_Close
autocmd BufEnter * silent
\ call s:Tlist_Window_Open_File_Fold(expand('<afile>:p'))
\ call s:Tlist_Window_Open_File_Fold(expand('<afile>'))
endif
" Exit Vim itself if only the taglist window is present (optional)
if g:Tlist_Exit_OnlyWindow
@ -3075,18 +3095,75 @@ endfunction
" Open the specified file in either a new window or an existing window
" and place the cursor at the specified tag pattern
function! s:Tlist_Window_Open_File(win_ctrl, filename, tagpat)
call s:Tlist_Log_Msg('Tlist_Window_Open_File (' . a:filename . ')')
call s:Tlist_Log_Msg('Tlist_Window_Open_File (' . a:filename . ',' .
\ a:win_ctrl . ')')
let prev_Tlist_Skip_Refresh = s:Tlist_Skip_Refresh
let s:Tlist_Skip_Refresh = 1
if s:tlist_app_name == "winmanager"
" Let the winmanager edit the file
call WinManagerFileEdit(a:filename, a:win_ctrl)
call WinManagerFileEdit(a:filename, a:win_ctrl == 'newwin')
else
if a:win_ctrl == 'newtab'
" Create a new tab
exe 'tabnew ' . escape(a:filename, ' ')
" Open the taglist window in the new tab
call s:Tlist_Window_Open()
endif
if a:win_ctrl == 'checktab'
" Check whether the file is present in any of the tabs.
" If the file is present in the current tab, then use the
" current tab.
if bufwinnr(a:filename) != -1
let file_present_in_tab = 1
let i = tabpagenr()
else
let i = 1
let bnum = bufnr(a:filename)
let file_present_in_tab = 0
while i <= tabpagenr('$')
if index(tabpagebuflist(i), bnum) != -1
let file_present_in_tab = 1
break
endif
let i += 1
endwhile
endif
if file_present_in_tab
" Goto the tab containing the file
exe 'tabnext ' . i
else
" Open a new tab
exe 'tabnew ' . escape(a:filename, ' ')
" Open the taglist window
call s:Tlist_Window_Open()
endif
endif
let winnum = -1
if a:win_ctrl == 'prevwin'
" Open the file in the previous window, if it is usable
let cur_win = winnr()
wincmd p
if &buftype == '' && !&previewwindow
exe "edit " . escape(a:filename, ' ')
let winnum = winnr()
else
" Previous window is not usable
exe cur_win . 'wincmd w'
endif
endif
" Goto the window containing the file. If the window is not there, open a
" new window
let winnum = bufwinnr(a:filename)
if winnum == -1
let winnum = bufwinnr(a:filename)
endif
if winnum == -1
" Locate the previously used window for opening a file
let fwin_num = 0
@ -3121,7 +3198,7 @@ function! s:Tlist_Window_Open_File(win_ctrl, filename, tagpat)
" If the user asked to jump to the tag in a new window, then split
" the existing window into two.
if a:win_ctrl == 1
if a:win_ctrl == 'newwin'
split
endif
exe "edit " . escape(a:filename, ' ')
@ -3173,7 +3250,7 @@ function! s:Tlist_Window_Open_File(win_ctrl, filename, tagpat)
" If the user asked to jump to the tag in a new window, then split the
" existing window into two.
if a:win_ctrl == 1
if a:win_ctrl == 'newwin'
split
endif
endif
@ -3197,7 +3274,7 @@ function! s:Tlist_Window_Open_File(win_ctrl, filename, tagpat)
" If the user selects to preview the tag then jump back to the
" taglist window
if a:win_ctrl == 2
if a:win_ctrl == 'preview'
" Go back to the taglist window
let winnum = bufwinnr(g:TagList_title)
exe winnum . 'wincmd w'
@ -3221,11 +3298,13 @@ endfunction
" Tlist_Window_Jump_To_Tag()
" Jump to the location of the current tag
" win_ctrl == 0 - Reuse the existing file window
" win_ctrl == 1 - Open a new window
" win_ctrl == 2 - Preview the tag
" win_ctrl == useopen - Reuse the existing file window
" win_ctrl == newwin - Open a new window
" win_ctrl == preview - Preview the tag
" win_ctrl == prevwin - Open in previous window
" win_ctrl == newtab - Open in new tab
function! s:Tlist_Window_Jump_To_Tag(win_ctrl)
call s:Tlist_Log_Msg('Tlist_Window_Jump_To_Tag()')
call s:Tlist_Log_Msg('Tlist_Window_Jump_To_Tag(' . a:win_ctrl . ')')
" Do not process comment lines and empty lines
let curline = getline('.')
if curline =~ '^\s*$' || curline[0] == '"'
@ -3933,8 +4012,8 @@ autocmd BufDelete * silent call s:Tlist_Buffer_Removed(expand('<afile>:p'))
" Tlist_Window_Open_File_Fold
" Open the fold for the specified file and close the fold for all the
" other files
function! s:Tlist_Window_Open_File_Fold(filename)
call s:Tlist_Log_Msg('Tlist_Window_Open_File_Fold (' . a:filename . ')')
function! s:Tlist_Window_Open_File_Fold(acmd_file)
call s:Tlist_Log_Msg('Tlist_Window_Open_File_Fold (' . a:acmd_file . ')')
" Make sure the taglist window is present
let winnum = bufwinnr(g:TagList_title)
@ -3965,11 +4044,14 @@ function! s:Tlist_Window_Open_File_Fold(filename)
silent! %foldclose
" Get tag list index of the specified file
let fidx = s:Tlist_Get_File_Index(a:filename)
if fidx != -1
" Open the fold for the file
exe "silent! " . s:tlist_{fidx}_start . "," .
\ s:tlist_{fidx}_end . "foldopen"
let fname = fnamemodify(a:acmd_file, ":p")
if filereadable(fname)
let fidx = s:Tlist_Get_File_Index(fname)
if fidx != -1
" Open the fold for the file
exe "silent! " . s:tlist_{fidx}_start . "," .
\ s:tlist_{fidx}_end . "foldopen"
endif
endif
" Go back to the original window