r958 - in /trunk/packages/vim-scripts: debian/ debian/vim-registry/ doc/ plugin/
zack at users.alioth.debian.org
zack at users.alioth.debian.org
Thu Jun 21 10:27:20 UTC 2007
Author: zack
Date: Thu Jun 21 10:27:19 2007
New Revision: 958
URL: http://svn.debian.org/wsvn/pkg-vim/?sc=1&rev=958
Log:
updated addons
Added:
trunk/packages/vim-scripts/plugin/vcssvk.vim
Modified:
trunk/packages/vim-scripts/debian/changelog
trunk/packages/vim-scripts/debian/vim-registry/vim-scripts.yaml
trunk/packages/vim-scripts/debian/vim-scripts.status
trunk/packages/vim-scripts/doc/bufexplorer.txt
trunk/packages/vim-scripts/doc/taglist.txt
trunk/packages/vim-scripts/doc/vcscommand.txt
trunk/packages/vim-scripts/plugin/NERD_comments.vim
trunk/packages/vim-scripts/plugin/a.vim
trunk/packages/vim-scripts/plugin/bufexplorer.vim
trunk/packages/vim-scripts/plugin/calendar.vim
trunk/packages/vim-scripts/plugin/cvsmenu.vim
trunk/packages/vim-scripts/plugin/gnupg.vim
trunk/packages/vim-scripts/plugin/taglist.vim
trunk/packages/vim-scripts/plugin/vcscommand.vim
trunk/packages/vim-scripts/plugin/vcscvs.vim
trunk/packages/vim-scripts/plugin/vcssvn.vim
Modified: trunk/packages/vim-scripts/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/debian/changelog?rev=958&op=diff
==============================================================================
--- trunk/packages/vim-scripts/debian/changelog (original)
+++ trunk/packages/vim-scripts/debian/changelog Thu Jun 21 10:27:19 2007
@@ -3,12 +3,16 @@
[ Stefano Zacchiroli ]
* debian/control
- added XS-Vcs-Browser field
+ * addons adds/removals/upgrades(/other changes)
+ - upgraded addons: alternate, bufexplorer, gnupg (Closes: #416011),
+ taglist, calendar, cvsmenu, vcscommand (add support for svk),
+ nerd-commenter
[ James Vega ]
* Fix debian/patches/disabledby-themes.dpatch to use endif instead of
fi[nish]. (Closes: #413468)
- -- James Vega <jamessan at debian.org> Tue, 20 Mar 2007 15:27:49 -0400
+ -- Stefano Zacchiroli <zack at debian.org> Thu, 21 Jun 2007 11:24:20 +0100
vim-scripts (7.0.5) unstable; urgency=low
Modified: trunk/packages/vim-scripts/debian/vim-registry/vim-scripts.yaml
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/debian/vim-registry/vim-scripts.yaml?rev=958&op=diff
==============================================================================
--- trunk/packages/vim-scripts/debian/vim-registry/vim-scripts.yaml (original)
+++ trunk/packages/vim-scripts/debian/vim-registry/vim-scripts.yaml Thu Jun 21 10:27:19 2007
@@ -87,6 +87,7 @@
- doc/vcscommand.txt
- plugin/vcscvs.vim
- plugin/vcssvn.vim
+ - plugin/vcssvk.vim
- syntax/CVSAnnotate.vim
- syntax/SVNAnnotate.vim
- syntax/vcscommit.vim
Modified: trunk/packages/vim-scripts/debian/vim-scripts.status
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/debian/vim-scripts.status?rev=958&op=diff
==============================================================================
--- trunk/packages/vim-scripts/debian/vim-scripts.status (original)
+++ trunk/packages/vim-scripts/debian/vim-scripts.status Thu Jun 21 10:27:19 2007
@@ -24,7 +24,7 @@
license: license [1], see below
extras: doc/alternate.txt
disabledby: let loaded_alternateFile = 1
-version: 2.15
+version: 2.18
script_name: plugin/whatdomain.vim
addon: whatdomain
@@ -47,7 +47,7 @@
license: license [2], see below
extras: doc/bufexplorer.txt
disabledby: let loaded_bufexplorer = 1
-version: 7.0.12
+version: 7.0.15
script_name: plugin/minibufexpl.vim
addon: minibufexplorer
@@ -69,7 +69,7 @@
email: markus.braun at krawel.de
license: no license
disabledby: let loaded_gnupg = 1
-version: 1.27
+version: 1605
script_name: plugin/taglist.vim
addon: taglist
@@ -81,7 +81,7 @@
license: no license
extras: doc/taglist.txt
disabledby: let loaded_taglist = 'no'
-version: 4.0b4
+version: 4.4
script_name: plugin/calendar.vim
addon: calendar
@@ -92,7 +92,7 @@
email: mattn_jp at mail.goo.ne.jp
license: no license
disabledby: let loaded_calendar = 1
-version: 1.4a
+version: 1.5
script_name: plugin/winmanager.vim
addon: winmanager
@@ -127,7 +127,7 @@
email: adah at sh163.net
license: GNU LGPL, see /usr/share/common-licenses/LGPL-2
disabledby: let loaded_cvsmenu = 1
-version: 1.140
+version: 1.142
script_name: plugin/vcscommand.vim
addon: vcscommand
@@ -137,9 +137,9 @@
author_url: http://www.vim.org/account/profile.php?user_id=241
email: bob.hiestand at gmail.com
license: public domain
-extras: doc/vcscommand.txt, plugin/vcscvs.vim, plugin/vcssvn.vim, syntax/CVSAnnotate.vim, syntax/SVNAnnotate.vim, syntax/vcscommit.vim
+extras: doc/vcscommand.txt, plugin/vcscvs.vim, plugin/vcssvn.vim, plugin/vcssvk.vim, syntax/CVSAnnotate.vim, syntax/SVNAnnotate.vim, syntax/vcscommit.vim
disabledby: let loaded_VCSCommand = 1
-version: Beta10
+version: Beta18
script_name: plugin/utl.vim
addon: utl
@@ -252,7 +252,7 @@
email: mrg39 at student.canterbury.ac.nz
license: no license
disabledby: let loaded_nerd_comments = 1
-version: 1.69
+version: 2.0.5
script_name: plugin/project.vim
addon: project
Modified: trunk/packages/vim-scripts/doc/bufexplorer.txt
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/doc/bufexplorer.txt?rev=958&op=diff
==============================================================================
--- trunk/packages/vim-scripts/doc/bufexplorer.txt (original)
+++ trunk/packages/vim-scripts/doc/bufexplorer.txt Thu Jun 21 10:27:19 2007
@@ -1,7 +1,7 @@
-*bufexplorer.txt* Buffer Explorer Last Change: 30 Nov 2006
+*bufexplorer.txt* Buffer Explorer Last Change: 27 Apr 2007
Buffer Explorer *buffer-explorer* *bufexplorer*
- Version 7.0.12
+ Version 7.0.15
Plugin for easily exploring (or browsing) open buffers
@@ -68,10 +68,36 @@
===============================================================================
CUSTOMIZATION *bufexplorer-customization*
+ *g:bufExplorerDefaultHelp*
+To control whether the default help is displayed or not, use: >
+ let g:bufExplorerDefaultHelp=0 " Do not show default help.
+ let g:bufExplorerDefaultHelp=1 " Show default help.
+The default is to show the default help.
+
*g:bufExplorerDetailedHelp*
To control whether detailed help is display by, use: >
let g:bufExplorerDetailedHelp=1
The default is not to show detailed help.
+
+ *g:bufExplorerReverseSort*
+To control whether to sort the buffer in reverse order or not, use: >
+ let g:bufExplorerReverseSort=0 " Do not sort in reverse order.
+ let g:bufExplorerReverseSort=1 " Sort in reverse order.
+The default is not to sort in reverse order.
+
+ *g:bufExplorerShowDirectories*
+Directories usually show up in the list from using a command like ":e .".
+To control whether to show directories in the buffer list or not, use: >
+ let g:bufExplorerShowDirectories=1 " Show directories.
+ let g:bufExplorerShowDirectories=0 " Don't show directories.
+Note: This is only available when using vim 7.0 and above.
+
+ *g:bufExplorerShowRelativePath*
+To control whether to show absolute paths or relative to the current
+directory, use: >
+ let g:bufExplorerShowRelativePath=0 " Show absolute paths.
+ let g:bufExplorerShowRelativePath=1 " Show relative paths.
+The default is to show absolute paths.
*g:bufExplorerSortBy*
To control what field the buffers are sorted by, use: >
@@ -90,6 +116,19 @@
The default is to use what ever is set by the global &splitbelow
variable.
+ *g:bufExplorerSplitHorzSize*
+To control the height of the window When opening a new window horizontally
+use: >
+ let g:bufExplorerSplitHorzSize = [height]
+The default is 0, which is to use half the existing height.
+
+ *g:bufExplorerSplitOutPathName*
+To control whether to split out the path and file name or not, use: >
+ let g:bufExplorerSplitOutPathName=1 " Split the path and file name.
+ let g:bufExplorerSplitOutPathName=0 " Don't split the path and file
+ " name.
+The default is to split the path and file name.
+
*g:bufExplorerSplitRight*
To control when opening a new window, if the new window is split to the
right or to the left of the current window, use: >
@@ -97,17 +136,12 @@
let g:bufExplorerSplitRight=1 " Split right.
The default is to use the global &splitright.
- *g:bufExplorerSplitType*
-To control the type of split when creating a new window, use: >
- let g:bufExplorerSplitType='' " Split horizontally.
- let g:bufExplorerSplitType='v' " Split vertically.
-The default is to split horizontally.
-
- *g:bufExplorerOpenMode*
-To control how the selected buffer is opened in 'split mode', use: >
- let g:bufExplorerOpenMode=1 " Open using current window.
- let g:bufExplorerOpenMode=0 " Open in new window.
-The default is to use a new window.
+ *g:bufExplorerSplitVertical*
+To control when opening a new window, if the current is split
+horizontally or vertically, use: >
+ let g:bufExplorerSplitVertical=0 " Split horizontally.
+ let g:bufExplorerSplitVertical=1 " Split vertically.
+The default is horizontally.
*g:bufexplorerSplitVertSize*
To control the width of the window when opening a new window vertically
@@ -115,42 +149,73 @@
let g:bufExplorerSplitVertSize = [width]
The default is 0, which is to use half the existing width.
- *g:bufExplorerSplitHorzSize*
-To control the height of the window When opening a new window horizontally
-use: >
- let g:bufExplorerSplitHorzSize = [height]
-The default is 0, which is to use half the existing height.
-
- *g:bufExplorerSortDirection*
-To control whether to sort the buffers in forward or reverse order, use: >
- let g:bufExplorerSortDirection=1 " Sort in forward order.
- let g:bufExplorerSortDirection=-1 " Sort in reverse order.
-The default is to sort forwards.
-
- *g:bufExplorerSplitOutPathName*
-To control whether to split out the path and file name or not, use: >
- let g:bufExplorerSplitOutPathName=1 " Split the path and file name.
- let g:bufExplorerSplitOutPathName=0 " Don't split the path and file
- " name.
-The default is to split the path and file name.
-
- *g:bufExplorerShowDirectories*
-Directories usually show up in the list from using a command like ":e .".
-To control whether to show directories in the buffer list or not, use: >
- let g:bufExplorerShowDirectories=1 " Show directories.
- let g:bufExplorerShowDirectories=0 " Don't show directories.
-Note: This is only available when using vim 7.0 and above.
-
- *g:bufExplorerShowRelativePath*
-To control whether to show absolute paths or relative to the current
-directory, use: >
- let g:bufExplorerShowRelativePath=0 " Show absolute paths.
- let g:bufExplorerShowRelativePath=1 " Show relative paths.
-The default is to show absolute paths.
+ *g:bufExplorerUseCurrentWindow*
+To control where the selected buffer is opened, use: >
+ let g:bufExplorerUseCurrentWindow=0 " Open in new window.
+ let g:bufExplorerUseCurrentWindow=1 " Open using current window.
+The default is to use a new window.
===============================================================================
CHANGE LOG *bufexplorer-changelog*
+7.0.15 - Thanks to Mark Smithfield for suggesting bufexplorer needed to handle
+ the ':args' command.
+ Fixed issue reported by Liu Jiaping on non Windows systems, which was
+ ...
+ Open file1, open file2, modify file1, open bufexplorer, you get the
+ following error:
+
+ --------8<--------
+ Error detected while processing function
+ <SNR>14_StartBufExplorer..<SNR>14_SplitOpen:
+ line 4:
+ E37: No write since last change (add ! to override)
+
+ But the worse thing is, when I want to save the current buffer and
+ type ':w', I get another error message:
+ E382: Cannot write, 'buftype' option is set
+ --------8<--------
+7.0.14 - Thanks to Randall Hansen for removing the requirement of terminal
+ versions to be recompiled with 'gui' support so the 'drop' command
+ would work. The 'drop' command is really not needed in terminal
+ versions.
+7.0.13 - Fixed integration with WinManager.
+ Thanks to Dave Eggum for another update.
+ - Fix: The detailed help didn't display the mapping for toggling
+ the split type, even though the split type is displayed.
+ - Fixed incorrect description in the detailed help for toggling
+ relative or full paths.
+ - Deprecated s:ExtractBufferNbr(). Vim's str2nr() does the same
+ thing.
+ - Created a s:Set() function that sets a variable only if it hasn't
+ already been defined. It's useful for initializing all those
+ default settings.
+ - Removed checks for repetitive command definitions. They were
+ unnecessary.
+ - Made the help highlighting a little more fancy.
+ - Minor reverse compatibility issue: Changed ambiguous setting
+ names to be more descriptive of what they do (also makes the code
+ easier to follow):
+ Changed bufExplorerSortDirection to bufExplorerReverseSort
+ Changed bufExplorerSplitType to bufExplorerSplitVertical
+ Changed bufExplorerOpenMode to bufExplorerUseCurrentWindow
+ - When the BufExplorer window closes, all the file-local marks are
+ now deleted. This may have the benefit of cleaning up some of the
+ jumplist.
+ - Changed the name of the parameter for StartBufExplorer from
+ "split" to "open". The parameter is a string which specifies how
+ the buffer will be open, not if it is split or not.
+ - Deprecated DoAnyMoreBuffersExist() - it is a one line function
+ only used in one spot.
+ - Created four functions (SplitOpen(), RebuildBufferList(),
+ UpdateHelpStatus() and ReSortListing()) all with one purpose - to
+ reduce repeated code.
+ - Changed the name of AddHeader() to CreateHelp() to be more
+ descriptive of what it does. It now returns an array instead of
+ updating the window directly. This has the benefit of making the
+ code more efficient since the text the function returns is used a
+ little differently in the two places the function is called.
+ - Other minor simplifications.
7.0.12 - MAJOR Update.
This version will ONLY run with Vim version 7.0 or greater.
Dave Eggum has made some 'significant' updates to this latest
@@ -298,8 +363,6 @@
- Erwin Waterlander suggestion of being able to open the explorer with one
buffer.
-- Once the ability to save and restore a jumplist is added to Vim, we need
- prevent the jumplist from updating when the user searches in bufexplorer.
===============================================================================
CREDITS *bufexplorer-credits*
Modified: trunk/packages/vim-scripts/doc/taglist.txt
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/doc/taglist.txt?rev=958&op=diff
==============================================================================
--- trunk/packages/vim-scripts/doc/taglist.txt (original)
+++ trunk/packages/vim-scripts/doc/taglist.txt Thu Jun 21 10:27:19 2007
@@ -2,7 +2,7 @@
Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
For Vim version 6.0 and above
-Last change: 2006 April 12
+Last change: 2007 May 24
1. Overview |taglist-intro|
2. Taglist on the internet |taglist-internet|
@@ -14,7 +14,8 @@
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*
@@ -63,7 +64,7 @@
The home page of the taglist plugin is at:
>
- http://www.geocities.com/yegappan/taglist
+ http://vim-taglist.sourceforge.net/
<
You can subscribe to the taglist mailing list to post your questions or
suggestions for improvement or to send bug reports. Visit the following page
@@ -75,23 +76,26 @@
*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. You can download the exuberant ctags utility from
+generate the tag listing. The exuberant ctags utility must be installed in
+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
<
-The exuberant ctags utility must be installed in your system to use this
-plugin. You should use exuberant ctags version 5.0 and above. This plugin
-doesn't use or create a tags file and there is no need to create a tags file
-to use this plugin. The taglist plugin will not work with the GNU ctags or the
-Unix ctags utility. The exuberant ctags utility is shipped with most of the
-Linux distributions.
+The taglist plugin doesn't use or create a tags file and there is no need to
+create a tags file to use this plugin. The taglist plugin will not work with
+the GNU ctags or the Unix ctags utility.
This plugin relies on the Vim "filetype" detection mechanism to determine the
type of the current file. You have to turn on the Vim filetype detection by
@@ -118,15 +122,16 @@
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
topics.
-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
- utility (not to the directory) in the .vimrc file.
+3. If the exuberant ctags utility is not present in one of the directories in
+ the PATH environment variable, then set the 'Tlist_Ctags_Cmd' variable to
+ point to the location of the exuberant ctags utility (not to the directory)
+ in the .vimrc file.
4. If you are running a terminal/console version of Vim and the terminal
doesn't support changing the window width then set the
'Tlist_Inc_Winwidth' variable to 0 in the .vimrc file.
@@ -135,9 +140,45 @@
window. You can use the ":help taglist" command to get more information
about using the taglist plugin.
+To uninstall the taglist plugin, remove the plugin/taglist.vim and
+doc/taglist.txt files from the $HOME/.vim or $HOME/vimfiles directory.
+
==============================================================================
*taglist-using*
5. Usage~
+
+The taglist plugin can be used in several different ways.
+
+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
+ processes the tags defined in newly edited files. You can then open the
+ taglist window only when you need to select a tag and then automatically
+ close the taglist window after selecting the tag.
+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 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
+ plugin to process the tags defined in a file always.
+6. You can save the tags defined in multiple files to a taglist session file
+ and load it when needed. You can also configure the taglist plugin to not
+ update the taglist window when editing new files. You can then manually add
+ files to the taglist window.
Opening the taglist window~
You can open the taglist window using the ":TlistOpen" or the ":TlistToggle"
@@ -152,11 +193,13 @@
>
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
<
@@ -174,12 +217,27 @@
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).
-
-You can open a file by pressing the <Enter> key or by double clicking the file
-name using the mouse.
+single mouse click set the 'Tlist_Use_SingleClick' variable to 1.
+
+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
@@ -252,8 +310,8 @@
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~
@@ -300,8 +358,9 @@
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
@@ -319,11 +378,16 @@
:TlistShowPrototype
:TlistShowPrototype myfile.c 50
<
+In the taglist window, when the mouse is moved over a tag name, the tag
+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
@@ -424,11 +488,13 @@
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:
->
- :highlight TagListTagName guifg=DarkGreen ctermfg=DarkGreen
+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 MyTagListTagName guifg=blue ctermfg=blue
<
Controlling the taglist window~
To use a horizontally split taglist window, instead of a vertically split
@@ -469,8 +535,12 @@
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
@@ -507,7 +577,9 @@
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
@@ -614,14 +686,14 @@
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~
@@ -644,12 +716,15 @@
>
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
<
@@ -670,9 +745,9 @@
The exuberant ctags tool can be installed under different names. When the
taglist plugin starts up, if the 'Tlist_Ctags_Cmd' variable is not set, it
-checks for the names exuberant-ctags, ctags, ctags.exe and tags in the PATH
-environment variable. If any one of the named executable is found, then the
-Tlist_Ctags_Cmd variable is set to that name.
+checks for the names exuberant-ctags, exctags, ctags, ctags.exe and tags in
+the PATH environment variable. If any one of the named executable is found,
+then the Tlist_Ctags_Cmd variable is set to that name.
If exuberant ctags is not present in one of the directories specified in the
PATH environment variable, then set this variable to point to the location of
@@ -680,7 +755,7 @@
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'
@@ -726,10 +801,9 @@
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, if a
-Vim buffer is no longer displayed in a Vim window, the corresponding tags tree
-in the taglist window will be collapsed/folded. When a buffer is loaded in a
-Vim window, the corresponding tags tree will be opened.
+'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
<
@@ -758,10 +832,10 @@
*'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
@@ -986,9 +1060,9 @@
*:TlistMessages*
:TlistMessages
- Display the logged debug messages from the taglist plugin.
- This command works only when logging to a script-local
- variable.
+ Display the logged debug messages from the taglist plugin
+ in a window. This command works only when logging to a
+ script-local variable.
*:TlistOpen*
:TlistOpen Open and jump to the taglist window. Creates the taglist
@@ -1126,52 +1200,64 @@
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.
-
-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 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 to add support for new languages and also
+modify the support for the above listed languages.
+
+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 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.
-
-For example, to list only the classes and functions defined in a C++
-language file, add the following lines to your .vimrc file
->
+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:
+
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
@@ -1180,23 +1266,32 @@
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.
-
-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.
+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.
+
+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',
@@ -1222,12 +1317,23 @@
>
$ 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:
>
:filetype
<
+ The output of the above command should contain "filetype detection:ON".
To turn on the filetype detection, add the following line to the .vimrc or
_vimrc file:
>
@@ -1248,19 +1354,34 @@
Do you have the |'shellslash'| option set? You can try disabling the
|'shellslash'| option. When the taglist plugin invokes the exuberant ctags
utility with the path to the file, if the incorrect slashes are used, then
- you will see errors.
+ you will see errors.
+
+ Check the shell related Vim options values using the following command:
+>
+ :set shell? shellcmdflag? shellpipe?
+ :set shellquote? shellredir? shellxquote?
+<
+ If these options are set in your .vimrc or _vimrc file, try removing those
+ lines.
Are you using a Unix shell in a MS-Windows environment? For example,
the Unix shell from the MKS-toolkit. Do you have the SHELL environment
set to point to this shell? You can try resetting the SHELL environment
variable.
+ If you are using a Unix shell on MS-Windows, you should try to use
+ exuberant ctags that is compiled for Unix-like environments so that
+ exuberant ctags will understand path names with forward slash characters.
+
Is your filetype supported by the exuberant ctags utility? The file types
supported by the exuberant ctags utility are listed in the ctags help. If a
- file type is not supported, you have to extend exuberant ctags.
-
- Run the following command from the shell and see whether you see
- your tags in the output from exuberant ctags:
+ file type is not supported, you have to extend exuberant ctags. You can use
+ the following command to list the filetypes supported by exuberant ctags:
+>
+ ctags --list-languages
+<
+ Run the following command from the shell prompt and check whether the tags
+ defined in your file are listed in the output from exuberant ctags:
>
ctags -f - --format=2 --excmd=pattern --fields=nks <filename>
<
@@ -1292,6 +1413,13 @@
>
let Tlist_Ctags_Cmd='C:\Progra~1\Ctags\ctags.exe'
<
+ If you are using a cygwin compiled version of exuberant ctags on MS-Windows,
+ make sure that either you have the cygwin compiled sort utility installed
+ and available in your PATH or compile exuberant ctags with internal sort
+ support. Otherwise, when exuberant ctags sorts the tags output by invoking
+ the sort utility, it may end up invoking the MS-Windows version of
+ sort.exe, thereby resulting in failure.
+
Q. When I try to open the taglist window, I am seeing the following error
message. How do I fix this problem?
@@ -1344,8 +1472,18 @@
|'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
Modified: trunk/packages/vim-scripts/doc/vcscommand.txt
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/doc/vcscommand.txt?rev=958&op=diff
==============================================================================
--- trunk/packages/vim-scripts/doc/vcscommand.txt (original)
+++ trunk/packages/vim-scripts/doc/vcscommand.txt Thu Jun 21 10:27:19 2007
@@ -1,6 +1,23 @@
*vcscommand.txt* vcscommand
-
-TODO: Change installation
+Copyright (c) 2007 Bob Hiestand
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.
For instructions on installing this file, type
:help add-local-help
@@ -23,19 +40,20 @@
2. vcscommand Installation *vcscommand-install*
-The vcscommand plugin comprises two files, vcscommand.vim and vcscommand.txt
-(this file). In order to install the plugin, place the vcscommand.vim file
-into a plugin' directory in your runtime path (please see |add-global-plugin|
-and |'runtimepath'|.
-
-vcscommand may be customized by setting variables, creating maps, and
-specifying event handlers. Please see |vcscommand-customize| for more
-details.
+The vcscommand plugin comprises five files: vcscommand.vim, vcssvn.vim,
+vcscvs.vim, vcssvk.vim and vcscommand.txt (this file). In order to install
+the plugin, place the vcscommand.vim, vcssvn.vim, vcssvk.vim, and vcscvs.vim
+files into a plugin directory in your runtime path (please see
+|add-global-plugin| and |'runtimepath'|.
This help file can be included in the VIM help system by copying it into a
'doc' directory in your runtime path and then executing the |:helptags|
command, specifying the full path of the 'doc' directory. Please see
|add-local-help| for more details.
+
+vcscommand may be customized by setting variables, creating maps, and
+specifying event handlers. Please see |vcscommand-customize| for more
+details.
==============================================================================
@@ -82,6 +100,7 @@
|:VCSAdd|
|:VCSAnnotate|
|:VCSCommit|
+|:VCSDelete|
|:VCSDiff|
|:VCSGotoOriginal|
|:VCSLog|
@@ -103,14 +122,11 @@
|:CVSWatchRemove|
|:CVSWatchers|
-The following commands are specific to SVN files:
-
-|:SVNInfo|
-
:VCSAdd *:VCSAdd*
This command adds the current file to source control. Please note, this does
-not commit the newly-added file.
+not commit the newly-added file. All parameters to the command are passed to
+the underlying VCS.
:VCSAnnotate *:VCSAnnotate*
@@ -121,9 +137,14 @@
CVS control). Additionally, if the current buffer is a VCSAnnotate buffer
already, the version number on the current line is used.
-The filetype of the vcscommand scratch buffer is set to either 'CVSAnnotate'
-or 'SVNAnnotate' as appropriate, to take advantage of the bundled syntax
-files.
+For CVS buffers, the 'VCSCommandCVSAnnotateParent' option, if set to non-zero,
+will cause the above behavior to change. Instead of annotating the version on
+the current line, the parent revision is used instead, crossing branches if
+necessary.
+
+The filetype of the vcscommand scratch buffer is set to one of 'CVSAnnotate',
+'SVNAnnotate', or 'SVKAnnotate' as appropriate, to take advantage of the
+bundled syntax files.
:VCSCommit[!] *:VCSCommit*
@@ -144,6 +165,11 @@
is useful if the |VCSCommandCommitOnWrite| variable is set to 0 to disable the
normal commit-on-write behavior.
+:VCSDelete *:VCSDelete*
+
+Deletes the current file and removes it from source control. All parameters
+to the command are passed to the underlying VCS.
+
:VCSDiff *:VCSDiff*
With no arguments, this displays the differences between the current file and
@@ -161,6 +187,8 @@
For SVN, this command uses the |VCSCommandSVNDiffOpt| variable to specify diff
options. If that variable does not exist, the SVN default is used.
+Additionally, |VCSCommandSVNDiffExt| can be used to select an external diff
+application.
:VCSGotoOriginal *:VCSGotoOriginal*
@@ -172,17 +200,24 @@
Like ":VCSGotoOriginal" but also executes :bufwipeout on all VCS scrach
buffers associated with the original file.
+:VCSInfo *:VCSInfo*
+
+This command displays extended information about the current file in a new
+scratch buffer.
+
:VCSLock *:VCSLock*
This command locks the current file in order to prevent other users from
concurrently modifying it. The exact semantics of this command depend on the
-underlying VCS. This does nothing in CVS.
+underlying VCS. This does nothing in CVS. All parameters are passed to the
+underlying VCS.
:VCSLog *:VCSLog*
-Displays the version history of the current file in a new scratch buffer. Any
-options are taken as revision parameters to be passed through to the
-underlying VCS.
+Displays the version history of the current file in a new scratch buffer. If
+there is one parameter supplied, it is taken as as a revision parameters to be
+passed through to the underlying VCS. Otherwise, all parameters are passed to
+the underlying VCS.
:VCSRevert *:VCSRevert*
@@ -198,14 +233,14 @@
:VCSStatus *:VCSStatus*
Displays versioning information about the current file in a new scratch
-buffer.
+buffer. All parameters are passed to the underlying VCS.
:VCSUnlock *:VCSUnlock*
Unlocks the current file in order to allow other users from concurrently
modifying it. The exact semantics of this command depend on the underlying
-VCS.
+VCS. All parameters are passed to the underlying VCS.
:VCSUpdate *:VCSUpdate*
@@ -274,10 +309,6 @@
This command performs "cvs watchers" on the current file.
-:SVNInfo *:SVNInfo*
-
-This command performs "svn info" on the current file.
-
4.2 Mappings *vcscommand-mappings*
By default, a mapping is defined for each command. These mappings execute the
@@ -289,6 +320,7 @@
<Leader>cd VCSDiff
<Leader>cg VCSGotoOriginal
<Leader>cG VCSGotoOriginal!
+<Leader>ci VCSInfo
<Leader>cl VCSLog
<Leader>cr VCSReview
<Leader>cs VCSStatus
@@ -298,7 +330,7 @@
Only for CVS buffers:
<Leader>ce CVSEdit
-<Leader>ci CVSEditors
+<Leader>cE CVSEditors
<Leader>ct CVSUnedit
<Leader>cwv CVSWatchers
<Leader>cwa CVSWatchAdd
@@ -306,10 +338,6 @@
<Leader>cwf CVSWatchOff
<Leader>cwf CVSWatchRemove
-Only for SVN buffers:
-
-<Leader>ci SVNInfo
-
*vcscommand-mappings-override*
The default mappings can be overriden by user-provided instead by mapping to
@@ -372,11 +400,15 @@
|VCSCommandCVSExec|
|VCSCommandDeleteOnHide|
|VCSCommandDiffSplit|
+|VCSCommandDisableMappings|
+|VCSCommandDisableExtensionMappings|
|VCSCommandEdit|
|VCSCommandEnableBufferSetup|
|VCSCommandResultBufferNameExtension|
|VCSCommandResultBufferNameFunction|
|VCSCommandSplit|
+|VCSCommandSVKExec|
+|VCSCommandSVNDiffExt|
|VCSCommandSVNDiffOpt|
|VCSCommandSVNExec|
@@ -406,6 +438,17 @@
This variable overrides the |VCSCommandSplit| variable, but only for buffers
created with |:VCSVimDiff|.
+
+VCSCommandDisableMappings *VCSCommandDisableMappings*
+
+This variable, if set to a non-zero value, prevents the default command
+mappings from being set. This supercedes
+|VCSCommandDisableExtensionMappings|.
+
+VCSCommandDisableExtensionMappings *VCSCommandDisableExtensionMappings*
+
+This variable, if set to a non-zero value, prevents the default command
+mappings from being set for commands specific to an individual VCS.
VCSCommandEdit *VCSCommandEdit*
@@ -452,6 +495,16 @@
side-by-side. If not set, it defaults to 'horizontal' for all but
VCSVimDiff windows.
+VCSCommandSVKExec *VCSCommandSVKExec*
+
+This variable controls the executable used for all SVK commands If not set,
+it defaults to "svk".
+
+VCSCommandSVNDiffExt *VCSCommandSVNDiffExt*
+
+This variable, if set, is passed to SVN via the --diff-cmd command to select
+an external application for performing the diff.
+
VCSCommandSVNDiffOpt *VCSCommandSVNDiffOpt*
This variable, if set, determines the options passed with the '-x' parameter
@@ -644,31 +697,8 @@
too often.
==============================================================================
-9. Tips *vcscommand-tips*
-
-9.1 Split window annotation, by Michael Anderson
-
-:nmap <Leader>cN :vs<CR><C-w>h<Leader>cn:vertical res 40<CR>
- \ggdddd:set scb<CR>:set nowrap<CR><C-w>lgg:set scb<CR>
- \:set nowrap<CR>
-
-This splits the buffer vertically, puts an annotation on the left (minus the
-header) with the width set to 40. An editable/normal copy is placed on the
-right. The two versions are scroll locked so they move as one. and wrapping
-is turned off so that the lines line up correctly. The advantages are...
-
-1) You get a versioning on the right.
-2) You can still edit your own code.
-3) Your own code still has syntax highlighting.
-
-Note, this only works if the 'VCSCommandEdit' option is set to 'edit'.
-Additionally, this is intended for use with unedited files, as otherwise the
-annotated copy from the repository will be out-of-sync with respect to the
-edited version.
-
-==============================================================================
-
-8. Known bugs *vcscommand-bugs*
+
+7. Known bugs *vcscommand-bugs*
Please let me know if you run across any.
Modified: trunk/packages/vim-scripts/plugin/NERD_comments.vim
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/plugin/NERD_comments.vim?rev=958&op=diff
==============================================================================
--- trunk/packages/vim-scripts/plugin/NERD_comments.vim (original)
+++ trunk/packages/vim-scripts/plugin/NERD_comments.vim Thu Jun 21 10:27:19 2007
@@ -1,16 +1,15 @@
" vim global plugin that provides easy code commenting for various file types
-" Last Change: 9 september 2006
+" Last Change: 16 may 2007
" Maintainer: Martin Grenfell <martin_grenfell at msn.com>
-let s:NERD_comments_version = 1.69
-
-
-" For help documentation type :help NERD_comments. If this fails, Restart vim
+let s:NERD_commenter_version = 2.0.5
+
+" For help documentation type :help NERD_commenter. If this fails, Restart vim
" and try again. If it sill doesnt work... the help page is at the bottom
" of this file.
" Section: script init stuff {{{1
if exists("loaded_nerd_comments")
- finish
+ finish
endif
let loaded_nerd_comments = 1
@@ -44,8 +43,8 @@
" 1 if the var is set, 0 otherwise
function s:InitVariable(var, value)
if !exists(a:var)
- exec 'let ' . a:var . ' = ' . "'" . a:value . "'"
- return 1
+ exec 'let ' . a:var . ' = ' . "'" . a:value . "'"
+ return 1
endif
return 0
endfunction
@@ -57,86 +56,44 @@
let s:spaceStr = ' '
let s:lenSpaceStr = strlen(s:spaceStr)
-
" Section: variable init calls {{{2
-call s:InitVariable("g:NERD_use_ada_with_spaces", 0)
-call s:InitVariable("g:NERD_use_c_style_acedb_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_ch_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_clean_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_clipper_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_cpp_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_cs_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_dot_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_dylan_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_h_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_hercules_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_idl_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_ishd_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_java_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_javascript_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_kscript_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_mel_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_named_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_pccts_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_pike_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_pilrc_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_plm_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_pov_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_prolog_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_rc_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_tads_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_tsalt_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_uc_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_verilog_comments", 0)
-call s:InitVariable("g:NERD_use_dash_dash_simula_comments", 0)
-call s:InitVariable("g:NERD_use_dnl_style_automake_comments", 0)
-call s:InitVariable("g:NERD_use_hash_samba_comments", 0)
-call s:InitVariable("g:NERD_use_c_style_php_comments", 0)
-call s:InitVariable("g:NERD_use_long_haskell_comments", 0)
-call s:InitVariable("g:NERD_use_long_lisp_comments", 0)
-call s:InitVariable("g:NERD_use_long_lua_comments", 0)
-call s:InitVariable("g:NERD_use_nested_comments_default", 0)
-call s:InitVariable("g:NERD_use_paren_star_pascal_comments", 0)
-call s:InitVariable("g:NERD_use_REM_basic_comments", 0)
-call s:InitVariable("g:NERD_use_single_part_c_comments", 0)
-
-call s:InitVariable("g:NERD_allow_any_visual_delims_regexp", ".*")
-call s:InitVariable("g:NERD_block_com_after_right", 0)
-call s:InitVariable("g:NERD_comment_whole_lines_in_v_mode", 0)
-call s:InitVariable("g:NERD_create_h_filetype", 0)
-call s:InitVariable("g:NERD_menu_mode", 2)
-call s:InitVariable("g:NERD_dont_remove_alt_coms", 0)
-call s:InitVariable("g:NERD_dont_remove_spaces_regexp", "^python$")
-call s:InitVariable("g:NERD_left_align_regexp", "^$")
-call s:InitVariable("g:NERD_lPlace", "[>")
-call s:InitVariable("g:NERD_place_holder_regexp", ".*")
-call s:InitVariable("g:NERD_right_align_regexp", "^$")
-call s:InitVariable("g:NERD_rPlace", "<]")
-call s:InitVariable("g:NERD_shut_up", '0')
-call s:InitVariable("g:NERD_space_delim_filetype_regexp", "^$")
-call s:InitVariable("g:NERD_use_compact_sexy_com_regexp", "^$")
+call s:InitVariable("g:NERDAllowAnyVisualDelims", 1)
+call s:InitVariable("g:NERDBlockComIgnoreEmpty", 0)
+call s:InitVariable("g:NERDCommentWholeLinesInVMode", 0)
+call s:InitVariable("g:NERDCompactSexyComs", 0)
+call s:InitVariable("g:NERDDefaultNesting", 0)
+call s:InitVariable("g:NERDMenuMode", 3)
+call s:InitVariable("g:NERDLPlace", "[>")
+call s:InitVariable("g:NERDUsePlaceHolders", 1)
+call s:InitVariable("g:NERDRemoveAltComs", 1)
+call s:InitVariable("g:NERDRemoveExtraSpaces", 0)
+call s:InitVariable("g:NERDRPlace", "<]")
+call s:InitVariable("g:NERDShutUp", '0')
+call s:InitVariable("g:NERDSpaceDelims", 0)
call s:InitVariable("g:mapleader", '\')
-call s:InitVariable("g:NERD_mapleader", g:mapleader . 'c')
-
-call s:InitVariable("g:NERD_alt_com_map", g:NERD_mapleader . 'a')
-call s:InitVariable("g:NERD_append_com_map", g:NERD_mapleader . 'A')
-call s:InitVariable("g:NERD_com_align_both_map", g:NERD_mapleader . 'b')
-call s:InitVariable("g:NERD_com_align_left_map", g:NERD_mapleader . 'l')
-call s:InitVariable("g:NERD_com_align_right_map", g:NERD_mapleader . 'r')
-call s:InitVariable("g:NERD_com_in_insert_map", '<C-c>')
-call s:InitVariable("g:NERD_com_line_invert_map", g:NERD_mapleader . 'i')
-call s:InitVariable("g:NERD_com_line_map", g:NERD_mapleader . 'c')
-call s:InitVariable("g:NERD_com_line_nest_map", g:NERD_mapleader . 'n')
-call s:InitVariable("g:NERD_com_line_sexy_map", g:NERD_mapleader . 's')
-call s:InitVariable("g:NERD_com_line_toggle_map", g:NERD_mapleader . '<space>')
-call s:InitVariable("g:NERD_com_line_minimal_map", g:NERD_mapleader . 'm')
-call s:InitVariable("g:NERD_com_line_yank_map", g:NERD_mapleader . 'y')
-call s:InitVariable("g:NERD_com_to_end_of_line_map", g:NERD_mapleader . '$')
-call s:InitVariable("g:NERD_prepend_com_map", g:NERD_mapleader . 'I')
-call s:InitVariable("g:NERD_uncom_line_map", g:NERD_mapleader . 'u')
-
-" Section: Comment mapping functions and autocommands {{{1
+call s:InitVariable("g:NERDMapleader", g:mapleader . 'c')
+
+call s:InitVariable("g:NERDAltComMap", g:NERDMapleader . 'a')
+call s:InitVariable("g:NERDAppendComMap", g:NERDMapleader . 'A')
+call s:InitVariable("g:NERDComAlignBothMap", g:NERDMapleader . 'b')
+call s:InitVariable("g:NERDComAlignLeftMap", g:NERDMapleader . 'l')
+call s:InitVariable("g:NERDComAlignRightMap", g:NERDMapleader . 'r')
+call s:InitVariable("g:NERDComInInsertMap", '<C-c>')
+call s:InitVariable("g:NERDComLineInvertMap", g:NERDMapleader . 'i')
+call s:InitVariable("g:NERDComLineMap", g:NERDMapleader . 'c')
+call s:InitVariable("g:NERDComLineNestMap", g:NERDMapleader . 'n')
+call s:InitVariable("g:NERDComLineSexyMap", g:NERDMapleader . 's')
+call s:InitVariable("g:NERDComLineToggleMap", g:NERDMapleader . '<space>')
+call s:InitVariable("g:NERDComLineMinimalMap", g:NERDMapleader . 'm')
+call s:InitVariable("g:NERDComLineYankMap", g:NERDMapleader . 'y')
+call s:InitVariable("g:NERDComToEOLMap", g:NERDMapleader . '$')
+call s:InitVariable("g:NERDPrependComMap", g:NERDMapleader . 'I')
+call s:InitVariable("g:NERDUncomLineMap", g:NERDMapleader . 'u')
+
+let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\"
+
+" Section: Comment mapping functions, autocommands and commands {{{1
" ============================================================================
" Section: Comment enabler autocommands {{{2
" ============================================================================
@@ -145,12 +102,6 @@
let nerd_autocmds_loaded=1
augroup commentEnablers
-
- if g:NERD_create_h_filetype == 1
- " some versions of vim dont have an h filetype... so we set it
- " ourselves, we also set syntax highlighting to c++ style
- autocmd BufEnter *.h :setfiletype h | :set syntax=cpp
- endif
"if the user enters a buffer or reads a buffer then we gotta set up
"the comment delimiters for that new filetype
@@ -158,6 +109,7 @@
augroup END
endif
+
" Function: s:SetUpForNewFiletype(filetype) function {{{2
" This function is responsible for setting up buffer scoped variables for the
@@ -187,9 +139,9 @@
elseif a:filetype == "abc"
call s:MapDelimiters('%', '')
elseif a:filetype == "acedb"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_acedb_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "ada"
- call s:MapDelimitersWithAlternative('--','', '-- ', '', g:NERD_use_ada_with_spaces)
+ call s:MapDelimitersWithAlternative('--','', '-- ', '')
elseif a:filetype == "ahdl"
call s:MapDelimiters('--', '')
elseif a:filetype == "amiga"
@@ -207,23 +159,25 @@
elseif a:filetype == "asm68k"
call s:MapDelimiters(';', '')
elseif a:filetype == "asm"
- call s:MapDelimiters(';', '')
- elseif a:filetype == "asm"
- call s:MapDelimiters('!','')
+ call s:MapDelimitersWithAlternative(';', '', '#', '')
elseif a:filetype == "asn"
call s:MapDelimiters('--', '')
elseif a:filetype == "aspvbs"
call s:MapDelimiters('''', '')
elseif a:filetype == "atlas"
call s:MapDelimiters('C','$')
+ elseif a:filetype == "autohotkey"
+ call s:MapDelimiters(';','')
+ elseif a:filetype == "autoit"
+ call s:MapDelimiters(';','')
elseif a:filetype == "automake"
- call s:MapDelimitersWithAlternative('#','', 'dnl ', '', g:NERD_use_dnl_style_automake_comments)
+ call s:MapDelimitersWithAlternative('#','', 'dnl ', '')
elseif a:filetype == "ave"
call s:MapDelimiters(''','')
elseif a:filetype == "awk"
call s:MapDelimiters('#','')
elseif a:filetype == "basic"
- call s:MapDelimitersWithAlternative(''','', 'REM ', '', g:NERD_use_REM_basic_comments)
+ call s:MapDelimitersWithAlternative(''','', 'REM ', '')
elseif a:filetype == "b"
call s:MapDelimiters('/*','*/')
elseif a:filetype == "bc"
@@ -231,9 +185,11 @@
elseif a:filetype == "bdf"
call s:MapDelimiters('COMMENT ', '')
elseif a:filetype == "bib"
- call s:MapDelimiters('','')
+ call s:MapDelimiters('%','')
elseif a:filetype == "bindzone"
call s:MapDelimiters(';', '')
+ elseif a:filetype == "bst"
+ call s:MapDelimiters('%', '')
elseif a:filetype == "btm"
call s:MapDelimiters('::', '')
elseif a:filetype == "caos"
@@ -241,19 +197,23 @@
elseif a:filetype == "catalog"
call s:MapDelimiters('--','--')
elseif a:filetype == "c"
- call s:MapDelimitersWithAlternative('/*','*/', '//', '', g:NERD_use_single_part_c_comments)
+ call s:MapDelimitersWithAlternative('/*','*/', '//', '')
elseif a:filetype == "cfg"
call s:MapDelimiters('#', '')
elseif a:filetype == "cg"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', 0)
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "ch"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_ch_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
+ elseif a:filetype == "changelog"
+ call s:MapDelimiters('','')
elseif a:filetype == "cl"
call s:MapDelimiters('#', '')
elseif a:filetype == "clean"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_clean_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "clipper"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_clipper_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
+ elseif a:filetype == "cmake"
+ call s:MapDelimiters('#','')
elseif a:filetype == "conf"
call s:MapDelimiters('#', '')
elseif a:filetype == "config"
@@ -261,11 +221,11 @@
elseif a:filetype == "context"
call s:MapDelimiters('%','')
elseif a:filetype == "cpp"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_cpp_comments)
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "crontab"
call s:MapDelimiters('#', '')
elseif a:filetype == "cs"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_cs_comments)
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "csc"
call s:MapDelimiters('/*','*/')
elseif a:filetype == "csp"
@@ -276,6 +236,8 @@
call s:MapDelimiters('*', '')
elseif a:filetype == "cupl"
call s:MapDelimiters('/*','*/')
+ elseif a:filetype == "csv"
+ call s:MapDelimiters('','')
elseif a:filetype == "cvs"
call s:MapDelimiters('CVS:','')
elseif a:filetype == "dcl"
@@ -286,6 +248,10 @@
call s:MapDelimiters(';', '')
elseif a:filetype == "diff"
call s:MapDelimiters('#', '')
+ elseif a:filetype == "django"
+ call s:MapDelimitersWithAlternative('<!--','-->', '{#', '#}')
+ elseif a:filetype == "docbk"
+ call s:MapDelimiters('<!--', '-->')
elseif a:filetype == "dns"
call s:MapDelimiters(';', '')
elseif a:filetype == "dosbatch"
@@ -293,7 +259,7 @@
elseif a:filetype == "dosini"
call s:MapDelimiters(';', '')
elseif a:filetype == "dot"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_dot_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "dracula"
call s:MapDelimiters(';', '')
elseif a:filetype == "dsl"
@@ -303,7 +269,7 @@
elseif a:filetype == "dtml"
call s:MapDelimiters('<dtml-comment>','</dtml-comment>')
elseif a:filetype == "dylan"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_dylan_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "ecd"
call s:MapDelimiters('#', '')
elseif a:filetype == "eiffel"
@@ -315,12 +281,14 @@
elseif a:filetype == "erlang"
call s:MapDelimiters('%', '')
elseif a:filetype == "eruby"
- call s:MapDelimitersWithAlternative('#', '', '<!--', '-->', 0)
+ call s:MapDelimitersWithAlternative('<!--', '-->', '<%#', '%>')
elseif a:filetype == "eterm"
call s:MapDelimiters('#', '')
elseif a:filetype == "expect"
call s:MapDelimiters('#', '')
elseif a:filetype == "exports"
+ call s:MapDelimiters('#', '')
+ elseif a:filetype == "fetchmail"
call s:MapDelimiters('#', '')
elseif a:filetype == "fgl"
call s:MapDelimiters('#', '')
@@ -332,34 +300,44 @@
call s:MapDelimiters('!', '')
elseif a:filetype == "foxpro"
call s:MapDelimiters('*', '')
+ elseif a:filetype == "fstab"
+ call s:MapDelimiters('#', '')
elseif a:filetype == "fvwm"
call s:MapDelimiters('#', '')
elseif a:filetype == "fx"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', 0)
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "gdb"
call s:MapDelimiters('#', '')
elseif a:filetype == "gdmo"
call s:MapDelimiters('--', '')
elseif a:filetype == "geek"
call s:MapDelimiters('GEEK_COMMENT:', '')
+ elseif a:filetype == 'gentoo-package-keywords'
+ call s:MapDelimiters('#', '')
+ elseif a:filetype == 'gentoo-package-mask'
+ call s:MapDelimiters('#', '')
+ elseif a:filetype == 'gentoo-package-use'
+ call s:MapDelimiters('#', '')
elseif a:filetype == "gnuplot"
call s:MapDelimiters('#','')
elseif a:filetype == "gtkrc"
call s:MapDelimiters('#', '')
elseif a:filetype == "haskell"
- call s:MapDelimitersWithAlternative('--','', '{-', '-}', g:NERD_use_long_haskell_comments)
+ call s:MapDelimitersWithAlternative('--','', '{-', '-}')
elseif a:filetype == "hb"
call s:MapDelimiters('#', '')
elseif a:filetype == "h"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_h_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "help"
call s:MapDelimiters('"','')
elseif a:filetype == "hercules"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_hercules_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "hog"
call s:MapDelimiters('#', '')
elseif a:filetype == "html"
- call s:MapDelimitersWithAlternative('<!--','-->', '//', '', 0)
+ call s:MapDelimitersWithAlternative('<!--','-->', '//', '')
+ elseif a:filetype == "htmldjango"
+ call s:MapDelimitersWithAlternative('<!--','-->', '{#', '#}')
elseif a:filetype == "htmlos"
call s:MapDelimiters('#','/#')
elseif a:filetype == "ia64"
@@ -369,7 +347,7 @@
elseif a:filetype == "idlang"
call s:MapDelimiters(';', '')
elseif a:filetype == "idl"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_idl_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "indent"
call s:MapDelimiters('/*','*/')
elseif a:filetype == "inform"
@@ -377,7 +355,7 @@
elseif a:filetype == "inittab"
call s:MapDelimiters('#', '')
elseif a:filetype == "ishd"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_ishd_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "iss"
call s:MapDelimiters(';', '')
elseif a:filetype == "ist"
@@ -385,9 +363,9 @@
elseif a:filetype == "jam"
call s:MapDelimiters('/*','*/')
elseif a:filetype == "java"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_java_comments)
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "javascript"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_javascript_comments)
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "jess"
call s:MapDelimiters(';', '')
elseif a:filetype == "jgraph"
@@ -398,10 +376,12 @@
call s:MapDelimiters('#','')
elseif a:filetype == "jsp"
call s:MapDelimiters('<%--', '--%>')
+ elseif a:filetype == "kconfig"
+ call s:MapDelimiters('#', '')
elseif a:filetype == "kix"
call s:MapDelimiters(';', '')
elseif a:filetype == "kscript"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_kscript_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "lace"
call s:MapDelimiters('--', '')
elseif a:filetype == "lex"
@@ -413,7 +393,7 @@
elseif a:filetype == "lilo"
call s:MapDelimiters('#', '')
elseif a:filetype == "lisp"
- call s:MapDelimitersWithAlternative(';','', '#|', '|#', g:NERD_use_long_lisp_comments)
+ call s:MapDelimitersWithAlternative(';','', '#|', '|#')
elseif a:filetype == "lite"
call s:MapDelimiters('/*','*/')
elseif a:filetype == "lotos"
@@ -427,7 +407,7 @@
elseif a:filetype == "lss"
call s:MapDelimiters('#', '')
elseif a:filetype == "lua"
- call s:MapDelimitersWithAlternative('--','', '--[[', ']]', g:NERD_use_long_lua_comments)
+ call s:MapDelimitersWithAlternative('--','', '--[[', ']]')
elseif a:filetype == "lynx"
call s:MapDelimiters('#', '')
elseif a:filetype == "m4"
@@ -445,7 +425,7 @@
elseif a:filetype == "matlab"
call s:MapDelimiters('%', '')
elseif a:filetype == "mel"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_mel_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "mf"
call s:MapDelimiters('%', '')
elseif a:filetype == "mib"
@@ -467,7 +447,7 @@
elseif a:filetype == "muttrc"
call s:MapDelimiters('#', '')
elseif a:filetype == "named"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_named_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "nasm"
call s:MapDelimiters(';', '')
elseif a:filetype == "nastran"
@@ -476,50 +456,62 @@
call s:MapDelimiters('/*', '')
elseif a:filetype == "ncf"
call s:MapDelimiters(';', '')
+ elseif a:filetype == "netdict"
+ call s:MapDelimiters('', '')
elseif a:filetype == "netrw"
call s:MapDelimiters('', '')
elseif a:filetype == "nqc"
call s:MapDelimiters('/*','*/')
+ elseif a:filetype == "nroff"
+ call s:MapDelimiters('\"', '')
elseif a:filetype == "nsis"
call s:MapDelimiters('#', '')
elseif a:filetype == "ocaml"
+ call s:MapDelimiters('(*','*)')
+ elseif a:filetype == "occam"
+ call s:MapDelimiters('--','')
+ elseif a:filetype == "omlet"
call s:MapDelimiters('(*','*)')
elseif a:filetype == "omnimark"
call s:MapDelimiters(';', '')
elseif a:filetype == "openroad"
call s:MapDelimiters('//', '')
elseif a:filetype == "opl"
- call <sid>mapdelimiters("REM", "")
+ call s:MapDelimiters("REM", "")
elseif a:filetype == "ora"
call s:MapDelimiters('#', '')
+ elseif a:filetype == "otl"
+ call s:MapDelimiters('', '')
elseif a:filetype == "ox"
call s:MapDelimiters('//', '')
elseif a:filetype == "pascal"
- call s:MapDelimitersWithAlternative('{','}', '(*', '*)', g:NERD_use_paren_star_pascal_comments)
+ call s:MapDelimitersWithAlternative('{','}', '(*', '*)')
+ elseif a:filetype == "passwd"
+ call s:MapDelimitersWith('','')
elseif a:filetype == "pcap"
call s:MapDelimiters('#', '')
elseif a:filetype == "pccts"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_pccts_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "perl"
call s:MapDelimiters('#', '')
elseif a:filetype == "pfmain"
call s:MapDelimiters('//', '')
elseif a:filetype == "php"
- call s:MapDelimitersWithAlternative('//','','/*', '*/', g:NERD_use_c_style_php_comments)
+ call s:MapDelimitersWithAlternative('//','','/*', '*/')
elseif a:filetype == "phtml"
call s:MapDelimiters('/*','*/')
elseif a:filetype == "pic"
call s:MapDelimiters(';', '')
elseif a:filetype == "pike"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_pike_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "pilrc"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_pilrc_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "pine"
call s:MapDelimiters('#', '')
elseif a:filetype == "plaintex"
call s:MapDelimiters('%','')
elseif a:filetype == "plm"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_plm_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "plsql"
call s:MapDelimiters('--', '')
elseif a:filetype == "po"
@@ -527,7 +519,7 @@
elseif a:filetype == "postscr"
call s:MapDelimiters('%', '')
elseif a:filetype == "pov"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_pov_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "povini"
call s:MapDelimiters(';', '')
elseif a:filetype == "ppd"
@@ -539,7 +531,7 @@
elseif a:filetype == "progress"
call s:MapDelimiters('/*','*/')
elseif a:filetype == "prolog"
- call s:MapDelimitersWithAlternative('%','','/*','*/', g:NERD_use_c_style_prolog_comments)
+ call s:MapDelimitersWithAlternative('%','','/*','*/')
elseif a:filetype == "psf"
call s:MapDelimiters('#', '')
elseif a:filetype == "ptcap"
@@ -548,6 +540,8 @@
call s:MapDelimiters('#', '')
elseif a:filetype == "python"
call s:MapDelimiters('#','')
+ elseif a:filetype == "qf"
+ call s:MapDelimiters('','')
elseif a:filetype == "radiance"
call s:MapDelimiters('#', '')
elseif a:filetype == "ratpoison"
@@ -555,7 +549,7 @@
elseif a:filetype == "r"
call s:MapDelimiters('#', '')
elseif a:filetype == "rc"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_rc_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "readline"
call s:MapDelimiters('#', '')
elseif a:filetype == "rebol"
@@ -570,12 +564,14 @@
call s:MapDelimiters('#', '')
elseif a:filetype == "rpl"
call s:MapDelimiters('/*','*/')
+ elseif a:filetype == "rtf"
+ call s:MapDelimiters('', '')
elseif a:filetype == "ruby"
call s:MapDelimiters('#','')
elseif a:filetype == "sa"
call s:MapDelimiters('--','')
elseif a:filetype == "samba"
- call s:MapDelimitersWithAlternative(';','', '#', '', g:NERD_use_hash_samba_comments)
+ call s:MapDelimitersWithAlternative(';','', '#', '')
elseif a:filetype == "sas"
call s:MapDelimiters('/*','*/')
elseif a:filetype == "sather"
@@ -592,6 +588,8 @@
call s:MapDelimiters('/*','*/')
elseif a:filetype == "sed"
call s:MapDelimiters('#', '')
+ elseif a:filetype == "selectbuf"
+ call s:MapDelimiters('', '')
elseif a:filetype == "sgml"
call s:MapDelimiters('<!','>')
elseif a:filetype == "sgmldecl"
@@ -601,7 +599,7 @@
elseif a:filetype == "sicad"
call s:MapDelimiters('*', '')
elseif a:filetype == "simula"
- call s:MapDelimitersWithAlternative('%', '', '--', '', g:NERD_use_dash_dash_simula_comments)
+ call s:MapDelimitersWithAlternative('%', '', '--', '')
elseif a:filetype == "sinda"
call s:MapDelimiters('$', '')
elseif a:filetype == "skill"
@@ -614,6 +612,8 @@
call s:MapDelimiters('%', '')
elseif a:filetype == "sm"
call s:MapDelimiters('#', '')
+ elseif a:filetype == "smarty"
+ call s:MapDelimiters('{*', '*}')
elseif a:filetype == "smil"
call s:MapDelimiters('<!','>')
elseif a:filetype == "smith"
@@ -652,8 +652,10 @@
call s:MapDelimiters('/*','*/')
elseif a:filetype == "svn"
call s:MapDelimiters('','')
+ elseif a:filetype == "systemverilog"
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "tads"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_tads_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "taglist"
call s:MapDelimiters('', '')
elseif a:filetype == "tags"
@@ -671,7 +673,7 @@
elseif a:filetype == "plaintex"
call s:MapDelimiters('%','')
elseif a:filetype == "texinfo"
- call <sid>mapdelimiters("@c ", "")
+ call s:MapDelimiters("@c ", "")
elseif a:filetype == "texmf"
call s:MapDelimiters('%', '')
elseif a:filetype == "tf"
@@ -681,29 +683,35 @@
elseif a:filetype == "tli"
call s:MapDelimiters('#', '')
elseif a:filetype == "trasys"
- call <sid>mapdelimiters("$", "")
+ call s:MapDelimiters("$", "")
elseif a:filetype == "tsalt"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_tsalt_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "tsscl"
call s:MapDelimiters('#', '')
elseif a:filetype == "tssgm"
call s:MapDelimiters('comment = '',''')
elseif a:filetype == "uc"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_uc_comments )
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "uil"
call s:MapDelimiters('!', '')
elseif a:filetype == "vb"
call s:MapDelimiters("'","")
elseif a:filetype == "verilog"
- call s:MapDelimitersWithAlternative('//','', '/*','*/', g:NERD_use_c_style_verilog_comments)
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
+ elseif a:filetype == "verilog_systemverilog"
+ call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "vgrindefs"
call s:MapDelimiters('#', '')
elseif a:filetype == "vhdl"
call s:MapDelimiters('--', '')
elseif a:filetype == "vim"
call s:MapDelimiters('"','')
+ elseif a:filetype == "viminfo"
+ call s:MapDelimiters('','')
elseif a:filetype == "virata"
call s:MapDelimiters('%', '')
+ elseif a:filetype == "vo_base"
+ call s:MapDelimiters('', '')
elseif a:filetype == "vrml"
call s:MapDelimiters('#', '')
elseif a:filetype == "vsejcl"
@@ -748,19 +756,19 @@
call s:MapDelimiters(';', '')
elseif a:filetype == ""
- call s:MapDelimitersWithAlternative("","", "", "", 0)
-
- "we have not hardcoded the comment delimiters to use for this filetype so
- "get them from &commentstring.
+ call s:MapDelimitersWithAlternative("","", "", "")
+
+ "we have not hardcoded the comment delimiters to use for this filetype so
+ "get them from &commentstring.
else
- "print a disclaimer to the user :)
- call s:NerdEcho("NERD_comments:Unknown filetype '".a:filetype."', setting delimiters by &commentstring.\nPleeeeease email the author of the NERD_commenter with this filetype\nand its delimiters!", 0)
-
+ "print a disclaimer to the user :)
+ call s:NerdEcho("Unknown filetype '".a:filetype."', setting delimiters by &commentstring.\nPleeeeease email the author of the NERD commenter with this filetype\nand its delimiters!", 0)
+
"extract the delims from &commentstring
- let left= substitute(&commentstring, '\(.*\)%s.*', '\1', '')
- let right= substitute(&commentstring, '.*%s\(.*\)', '\1', 'g')
-
- call s:MapDelimiters(left,right)
+ let left= substitute(&commentstring, '\(.*\)%s.*', '\1', '')
+ let right= substitute(&commentstring, '.*%s\(.*\)', '\1', 'g')
+
+ call s:MapDelimiters(left,right)
endif
endfunction
@@ -772,10 +780,10 @@
" -left: the left comment delimiter
" -right: the right comment delimiter
function s:MapDelimiters(left, right)
- call s:MapDelimitersWithAlternative(a:left, a:right, "", "", 0)
-endfunction
-
-" Function: s:MapDelimitersWithAlternative(left, right, leftAlt, rightAlt, useAlt) function {{{2
+ call s:MapDelimitersWithAlternative(a:left, a:right, "", "")
+endfunction
+
+" Function: s:MapDelimitersWithAlternative(left, right, leftAlt, rightAlt) function {{{2
" this function sets up the comment delimiter buffer variables
"
" Args:
@@ -783,13 +791,8 @@
" -right: the string defining the comment end delimiter
" -leftAlt: the string for the alternative comment style defining the comment start delimiter
" -rightAlt: the string for the alternative comment style defining the comment end delimiter
-" -useAlt: a flag specifying whether to use the alternative comment style 0 is
-" false
-function s:MapDelimitersWithAlternative(left, right, leftAlt, rightAlt, useAlt)
-
- " if the useAlt flag is not set then we use a:left and a:right
- " as the left and right comment delimiters
- if a:useAlt == 0
+function s:MapDelimitersWithAlternative(left, right, leftAlt, rightAlt)
+ if !exists('g:NERD_' . &filetype . '_alt_style')
let b:left = a:left
let b:right = a:right
let b:leftAlt = a:leftAlt
@@ -815,10 +818,10 @@
"if both of the alternative delimiters are empty then there is no
"alternative comment style so bail out
if (b:leftAlt=="" && b:rightAlt=="")
- if a:printMsgs
- call s:NerdEcho("NERD_comments:Cannot use alternative delimiters, none are specified", 0)
- endif
- return 0
+ if a:printMsgs
+ call s:NerdEcho("Cannot use alternative delimiters, none are specified", 0)
+ endif
+ return 0
endif
"save the current delimiters
@@ -828,16 +831,16 @@
"swap current delimiters for alternative
let b:left = b:leftAlt
let b:right = b:rightAlt
-
+
"set the previously current delimiters to be the new alternative ones
let b:leftAlt = tempLeft
let b:rightAlt = tempRight
"tell the user what comment delimiters they are now using
if a:printMsgs
- let leftNoEsc = b:left
- let rightNoEsc = b:right
- call s:NerdEcho("NERD_comments:Now using " . leftNoEsc . " " . rightNoEsc . " to delimit comments", 1)
+ let leftNoEsc = b:left
+ let rightNoEsc = b:right
+ call s:NerdEcho("Now using " . leftNoEsc . " " . rightNoEsc . " to delimit comments", 1)
endif
return 1
@@ -854,7 +857,7 @@
" get the len of the right delim
let lenRight = strlen(right)
-
+
let isLineEmpty = strlen(getline(".")) == 0
let insOrApp = (isLineEmpty==1 ? 'i' : 'A')
@@ -866,12 +869,12 @@
" by the len of the right delimiter so we insert between the delimiters
if lenRight > 0
let leftMoveAmount = lenRight
- execute ":normal " . leftMoveAmount . "h"
+ execute ":normal " . leftMoveAmount . "h"
endif
startinsert
endfunction
-" Function: s:CommentBlock(top, bottom, lSide, rSide, forceNested ) range {{{2
+" Function: s:CommentBlock(top, bottom, lSide, rSide, forceNested ) {{{2
" This function is used to comment out a region of code. This region is
" specified as a bounding box by arguments to the function. Note that the
" range keyword is specified for this function. This is because this function
@@ -883,7 +886,7 @@
" -lSide: the column number for the left most column in the region
" -rSide: the column number for the right most column in the region
" -forceNested: a flag indicating whether comments should be nested
-function s:CommentBlock(top, bottom, lSide, rSide, forceNested ) range
+function s:CommentBlock(top, bottom, lSide, rSide, forceNested )
" we need to create local copies of these arguments so we can modify them
let top = a:top
let bottom = a:bottom
@@ -895,21 +898,21 @@
let topline = getline(top)
let bottomline = getline(bottom)
if topline =~ '^\t\t*' || bottomline =~ '^\t\t*'
- "find out how many tabs are in the top line and adjust the left
- "boundary accordingly
- let numTabs = strlen(substitute(topline, '^\(\t*\).*$', '\1', ""))
- if lSide < numTabs
- let lSide = s:spacesPerTab * lSide
- else
- let lSide = (lSide - numTabs) + (s:spacesPerTab * numTabs)
- endif
-
- "find out how many tabs are in the bottom line and adjust the right
- "boundary accordingly
- let numTabs = strlen(substitute(bottomline, '^\(\t*\).*$', '\1', ""))
- let rSide = (rSide - numTabs) + (s:spacesPerTab * numTabs)
- endif
-
+ "find out how many tabs are in the top line and adjust the left
+ "boundary accordingly
+ let numTabs = strlen(substitute(topline, '^\(\t*\).*$', '\1', ""))
+ if lSide < numTabs
+ let lSide = s:spacesPerTab * lSide
+ else
+ let lSide = (lSide - numTabs) + (s:spacesPerTab * numTabs)
+ endif
+
+ "find out how many tabs are in the bottom line and adjust the right
+ "boundary accordingly
+ let numTabs = strlen(substitute(bottomline, '^\(\t*\).*$', '\1', ""))
+ let rSide = (rSide - numTabs) + (s:spacesPerTab * numTabs)
+ endif
+
"we must check that bottom IS actually below top, if it is not then we
"swap top and bottom. Similarly for left and right.
if bottom < top
@@ -929,10 +932,10 @@
let didSwitchDelims = -1
"if the right delim isnt empty then we can use it for this comment
- if b:right != '' || &filetype !~ g:NERD_allow_any_visual_delims_regexp
+ if b:right != '' || !g:NERDAllowAnyVisualDelims
let didSwitchDelims = 0
- "if the alternative comment right delimiter isnt null then we can use the
- "alternative right delims
+ "if the alternative comment right delimiter isnt null then we can use the
+ "alternative right delims
elseif b:rightAlt != ''
let didSwitchDelims = 1
call <sid>SwitchToAlternativeDelimiters(0)
@@ -945,7 +948,7 @@
"we need the len of leftNoEsc soon
let lenLeftNoEsc = strlen(leftNoEsc)
-
+
"we need the len of rightNoEsc soon
let lenRightNoEsc = strlen(rightNoEsc)
@@ -954,140 +957,140 @@
let currentLine=top
while currentLine <= bottom
- "check if we are allowed to comment this line
- if s:GetCanCommentLine(a:forceNested, currentLine)
-
- "convert the leading tabs into spaces
- let theLine = getline(currentLine)
+ "check if we are allowed to comment this line
+ if s:GetCanCommentLine(a:forceNested, currentLine)
+
+ "convert the leading tabs into spaces
+ let theLine = getline(currentLine)
let lineHasLeadTabs = s:HasLeadingTab(theLine)
if lineHasLeadTabs
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
endif
- "dont comment lines that begin after the right boundary of the
- "block unless the user has specified to do so
- if theLine !~ '^ \{' . rSide . '\}' || g:NERD_block_com_after_right==1
-
- "lineLSide and lineRSide are used as indexes into theLine. They
- "are used to point to index where the left and right
- "delimiters will be placed on the current line. The position
- "of the delimiters may be altered if the current left position
- "is in the middle of a delimiter.
- let lineLSide = lSide
- let lineRSide = rSide
-
- "If the left or right boundaries are inside an existing
- "delimiter then adjust lineLSide and lineRSide appropriately so
- "that they are just after/before these delimiters
- let offset = s:GetIndxInSubstr(lSide-1, leftNoEsc, theLine)
- if offset > 0
- let lineLSide = lSide + lenLeftNoEsc - offset
- endif
- let offset = s:GetIndxInSubstr(lSide-1, rightNoEsc, theLine)
- if offset > 0
- let lineLSide = lSide - offset
- endif
-
- let offset = s:GetIndxInSubstr(rSide, rightNoEsc, theLine)
- if offset > 0
- let lineRSide = rSide + lenRightNoEsc - offset
- endif
- let offset = s:GetIndxInSubstr(rSide, leftNoEsc, theLine)
- if offset > 0
- let lineRSide = rSide + lenLeftNoEsc - offset
- endif
-
- let offset = s:GetIndxInSubstr(lSide-1, g:NERD_lPlace, theLine)
- if offset > 0
- let lineLSide = lSide + strlen(g:NERD_lPlace) - offset
- endif
- let offset = s:GetIndxInSubstr(lSide-1, g:NERD_rPlace, theLine)
- if offset > 0
- let lineLSide = lSide - offset
- endif
-
- let offset = s:GetIndxInSubstr(rSide, g:NERD_rPlace, theLine)
- if offset > 0
- let lineRSide = rSide + strlen(g:NERD_rPlace) - offset
- endif
- let offset = s:GetIndxInSubstr(rSide, g:NERD_lPlace, theLine)
- if offset > 0
- let lineRSide = rSide + strlen(g:NERD_lPlace) - offset
- endif
-
- if b:leftAlt != ""
- let leftANoEsc = b:leftAlt
- let rightANoEsc = b:rightAlt
- let lenRightANoEsc = strlen(rightANoEsc)
- let lenLeftANoEsc = strlen(leftANoEsc)
-
- let offset = s:GetIndxInSubstr(lSide-1, leftANoEsc, theLine)
- if offset > 0
- let lineLSide = lSide + lenLeftANoEsc - offset
- endif
- let offset = s:GetIndxInSubstr(lSide-1, rightANoEsc, theLine)
- if offset > 0
- let lineLSide = lSide - offset
- endif
-
- let offset = s:GetIndxInSubstr(rSide, rightANoEsc, theLine)
- if offset > 0
- let lineRSide = rSide + lenRightNoEsc - offset
- endif
- let offset = s:GetIndxInSubstr(rSide, leftANoEsc, theLine)
- if offset > 0
- let lineRSide = rSide + lenLeftANoEsc - offset
- endif
- endif
-
- "attempt to place the cursor in on the left of the boundary box,
- "then check if we were successful, if not then we cant comment this
- "line
+ "dont comment lines that begin after the right boundary of the
+ "block unless the user has specified to do so
+ if theLine !~ '^ \{' . rSide . '\}' || !g:NERDBlockComIgnoreEmpty
+
+ "lineLSide and lineRSide are used as indexes into theLine. They
+ "are used to point to index where the left and right
+ "delimiters will be placed on the current line. The position
+ "of the delimiters may be altered if the current left position
+ "is in the middle of a delimiter.
+ let lineLSide = lSide
+ let lineRSide = rSide
+
+ "If the left or right boundaries are inside an existing
+ "delimiter then adjust lineLSide and lineRSide appropriately so
+ "that they are just after/before these delimiters
+ let offset = s:GetIndxInSubstr(lSide-1, leftNoEsc, theLine)
+ if offset > 0
+ let lineLSide = lSide + lenLeftNoEsc - offset
+ endif
+ let offset = s:GetIndxInSubstr(lSide-1, rightNoEsc, theLine)
+ if offset > 0
+ let lineLSide = lSide - offset
+ endif
+
+ let offset = s:GetIndxInSubstr(rSide, rightNoEsc, theLine)
+ if offset > 0
+ let lineRSide = rSide + lenRightNoEsc - offset
+ endif
+ let offset = s:GetIndxInSubstr(rSide, leftNoEsc, theLine)
+ if offset > 0
+ let lineRSide = rSide + lenLeftNoEsc - offset
+ endif
+
+ let offset = s:GetIndxInSubstr(lSide-1, g:NERDLPlace, theLine)
+ if offset > 0
+ let lineLSide = lSide + strlen(g:NERDLPlace) - offset
+ endif
+ let offset = s:GetIndxInSubstr(lSide-1, g:NERDRPlace, theLine)
+ if offset > 0
+ let lineLSide = lSide - offset
+ endif
+
+ let offset = s:GetIndxInSubstr(rSide, g:NERDRPlace, theLine)
+ if offset > 0
+ let lineRSide = rSide + strlen(g:NERDRPlace) - offset
+ endif
+ let offset = s:GetIndxInSubstr(rSide, g:NERDLPlace, theLine)
+ if offset > 0
+ let lineRSide = rSide + strlen(g:NERDLPlace) - offset
+ endif
+
+ if b:leftAlt != ""
+ let leftANoEsc = b:leftAlt
+ let rightANoEsc = b:rightAlt
+ let lenRightANoEsc = strlen(rightANoEsc)
+ let lenLeftANoEsc = strlen(leftANoEsc)
+
+ let offset = s:GetIndxInSubstr(lSide-1, leftANoEsc, theLine)
+ if offset > 0
+ let lineLSide = lSide + lenLeftANoEsc - offset
+ endif
+ let offset = s:GetIndxInSubstr(lSide-1, rightANoEsc, theLine)
+ if offset > 0
+ let lineLSide = lSide - offset
+ endif
+
+ let offset = s:GetIndxInSubstr(rSide, rightANoEsc, theLine)
+ if offset > 0
+ let lineRSide = rSide + lenRightNoEsc - offset
+ endif
+ let offset = s:GetIndxInSubstr(rSide, leftANoEsc, theLine)
+ if offset > 0
+ let lineRSide = rSide + lenLeftANoEsc - offset
+ endif
+ endif
+
+ "attempt to place the cursor in on the left of the boundary box,
+ "then check if we were successful, if not then we cant comment this
+ "line
call setline(currentLine, theLine)
- call cursor(currentLine, lineLSide)
- if col(".") == lineLSide && line(".") == currentLine
+ call cursor(currentLine, lineLSide)
+ if col(".") == lineLSide && line(".") == currentLine
let leftSpaced = s:GetLeft(0,1,0)
let rightSpaced = s:GetRight(0,1,0)
- "stick the left delimiter down
- let theLine = strpart(theLine, 0, lineLSide-1) . leftSpaced . strpart(theLine, lineLSide-1)
-
- "attempt to go the right boundary to place the right
- "delimiter, if we cant go to the right boundary then the
- "comment delimiter will be placed on the EOL.
- if rightNoEsc != ''
- call cursor(currentLine, lineRSide+strlen(leftSpaced))
-
- "stick the right delimiter down
- let theLine = strpart(theLine, 0, lineRSide+strlen(leftSpaced)) . rightSpaced . strpart(theLine, lineRSide+strlen(rightSpaced))
-
- "get the first/last indexes of the delimiters and get
- "the string between them and call it searchStr
- let firstLeftDelim = s:FindDelimiterIndex(leftNoEsc, theLine)
- let lastRightDelim = s:GetLastIndexOfDelim(rightNoEsc, theLine)
-
- "if the user has placed somewhere so that
- "NERD_comments doesnt recognise it as a comment
- "delimiter then dont try to use place-holders as we'd
- "probably just screw it up more
- if firstLeftDelim != -1 && lastRightDelim != -1
- let searchStr = strpart(theLine, 0, lastRightDelim)
- let searchStr = strpart(searchStr, firstLeftDelim+strlen(leftNoEsc))
-
- "replace the outter most delims in searchStr with
- "place-holders
- let theLineWithPlaceHolders = s:ReplaceDelims(leftNoEsc, rightNoEsc, g:NERD_lPlace, g:NERD_rPlace, searchStr)
-
- "add the right delimiter onto the line
- let theLine = strpart(theLine, 0, firstLeftDelim+strlen(leftNoEsc)) . theLineWithPlaceHolders . strpart(theLine, lastRightDelim)
- endif
-
- endif
-
-
- endif
- endif
+ "stick the left delimiter down
+ let theLine = strpart(theLine, 0, lineLSide-1) . leftSpaced . strpart(theLine, lineLSide-1)
+
+ "attempt to go the right boundary to place the right
+ "delimiter, if we cant go to the right boundary then the
+ "comment delimiter will be placed on the EOL.
+ if rightNoEsc != ''
+ call cursor(currentLine, lineRSide+strlen(leftSpaced))
+
+ "stick the right delimiter down
+ let theLine = strpart(theLine, 0, lineRSide+strlen(leftSpaced)) . rightSpaced . strpart(theLine, lineRSide+strlen(rightSpaced))
+
+ "get the first/last indexes of the delimiters and get
+ "the string between them and call it searchStr
+ let firstLeftDelim = s:FindDelimiterIndex(leftNoEsc, theLine)
+ let lastRightDelim = s:GetLastIndexOfDelim(rightNoEsc, theLine)
+
+ "if the user has placed somewhere so that
+ "NERDCommenter doesnt recognise it as a comment
+ "delimiter then dont try to use place-holders as we'd
+ "probably just screw it up more
+ if firstLeftDelim != -1 && lastRightDelim != -1
+ let searchStr = strpart(theLine, 0, lastRightDelim)
+ let searchStr = strpart(searchStr, firstLeftDelim+strlen(leftNoEsc))
+
+ "replace the outter most delims in searchStr with
+ "place-holders
+ let theLineWithPlaceHolders = s:ReplaceDelims(leftNoEsc, rightNoEsc, g:NERDLPlace, g:NERDRPlace, searchStr)
+
+ "add the right delimiter onto the line
+ let theLine = strpart(theLine, 0, firstLeftDelim+strlen(leftNoEsc)) . theLineWithPlaceHolders . strpart(theLine, lastRightDelim)
+ endif
+
+ endif
+
+
+ endif
+ endif
"restore tabs if needed
if lineHasLeadTabs
@@ -1101,14 +1104,14 @@
"move onto the next line
let currentLine = currentLine + 1
endwhile
-
+
"if we switched delims then we gotta go back to what they were before
if didSwitchDelims == 1
call s:SwitchToAlternativeDelimiters(0)
endif
endfunction
-" Function: s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine) range {{{2
+" Function: s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine) {{{2
" This function comments a range of lines.
"
" Args:
@@ -1117,7 +1120,7 @@
" -alignRight/alignLeft: 0/1 if the comments delimiters should/shouldnt be
" aligned left/right
" -firstLine/lastLine: the top and bottom lines to comment
-function s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine) range
+function s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine)
" we need to get the left and right indexes of the leftmost char in the
" block of of lines and the right most char so that we can do alignment of
" the delimiters if the user has specified
@@ -1132,23 +1135,23 @@
let currentLine = a:firstLine
while currentLine <= a:lastLine
- " get the next line, check commentability and convert spaces to tabs
- let theLine = getline(currentLine)
+ " get the next line, check commentability and convert spaces to tabs
+ let theLine = getline(currentLine)
let lineHasLeadingTabs = s:HasLeadingTab(theLine)
- let theLine = s:ConvertLeadingTabsToSpaces(theLine)
- if s:GetCanCommentLine(a:forceNested, currentLine)
+ let theLine = s:ConvertLeadingTabsToSpaces(theLine)
+ if s:GetCanCommentLine(a:forceNested, currentLine)
"if the user has specified forceNesting then we check to see if we
"need to switch delimiters for place-holders
- if a:forceNested && &filetype =~ g:NERD_place_holder_regexp
+ if a:forceNested && g:NERDUsePlaceHolders
let theLine = s:SwapOutterMultiPartDelimsForPlaceHolders(theLine)
endif
-
+
" find out if the line is commented using normal delims and/or
" alternate ones
let isCommented = s:IsCommented(b:left, b:right, theLine) || s:IsCommented(b:leftAlt, b:rightAlt, theLine)
-
+
" check if we can comment this line
- if !isCommented || &filetype =~ g:NERD_place_holder_regexp || b:right==""
+ if !isCommented || g:NERDUsePlaceHolders || b:right==""
if a:alignLeft
let theLine = s:AddLeftDelimAligned(b:left, theLine, leftAlignIndx)
else
@@ -1163,41 +1166,44 @@
endif
" restore leading tabs if appropriate
- if lineHasLeadingTabs
- let theLine = s:ConvertLeadingSpacesToTabs(theLine)
- endif
-
- " we are done with this line
- call setline(currentLine, theLine)
- let currentLine = currentLine + 1
+ if lineHasLeadingTabs
+ let theLine = s:ConvertLeadingSpacesToTabs(theLine)
+ endif
+
+ " we are done with this line
+ call setline(currentLine, theLine)
+ let currentLine = currentLine + 1
endwhile
endfunction
-" Function: s:CommentLinesMinimal(firstLine, lastLine) range {{{2
+" Function: s:CommentLinesMinimal(firstLine, lastLine) {{{2
" This function comments a range of lines in a minimal style. I
"
" Args:
" -firstLine/lastLine: the top and bottom lines to comment
-function s:CommentLinesMinimal(firstLine, lastLine) range
+function s:CommentLinesMinimal(firstLine, lastLine)
+ "check that minimal comments can be done on this filetype
+ if b:right == '' && b:rightAlt == ''
+ throw 'NERDCommenter.Delimiters exception: Minimal comments can only be used for filetypes that have multipart delimiters'
+ endif
+
"if we need to use place holders for the comment, make sure they are
"enabled for this filetype
- if &filetype !~ g:NERD_place_holder_regexp && s:DoesBlockHaveMultipartDelim(a:firstLine, a:lastLine)
- call s:NerdEcho("NERD_comments: comment aborted. Place holders are required but disabled.",1)
- return
+ if !g:NERDUsePlaceHolders && s:DoesBlockHaveMultipartDelim(a:firstLine, a:lastLine)
+ throw 'NERDCommenter.Settings exception: Placeoholders are required but disabled.'
endif
"get the left and right delims to smack on
- let useSpaceStr = &filetype =~ g:NERD_space_delim_filetype_regexp
- let left = s:GetSexyComLeft(useSpaceStr,0)
- let right = s:GetSexyComRight(useSpaceStr,0)
+ let left = s:GetSexyComLeft(g:NERDSpaceDelims,0)
+ let right = s:GetSexyComRight(g:NERDSpaceDelims,0)
"make sure all multipart delims on the lines are replaced with
"placeholders to prevent illegal syntax
let currentLine = a:firstLine
while(currentLine <= a:lastLine)
let theLine = getline(currentLine)
- let theLine = s:ReplaceDelims(left, right, g:NERD_lPlace, g:NERD_rPlace, theLine)
+ let theLine = s:ReplaceDelims(left, right, g:NERDLPlace, g:NERDRPlace, theLine)
call setline(currentLine, theLine)
let currentLine = currentLine + 1
endwhile
@@ -1231,15 +1237,20 @@
" Args:
" -topline: the line num of the top line in the sexy comment
" -bottomline: the line num of the bottom line in the sexy comment
-function s:CommentLinesSexy(topline, bottomline) range
-
+function s:CommentLinesSexy(topline, bottomline)
let left = s:GetSexyComLeft(0, 0)
let right = s:GetSexyComRight(0, 0)
"check if we can do a sexy comment with the available delimiters
if left == -1 || right == -1
- return -1
- endif
+ throw 'NERDCommenter.Delimiters exception: cannot perform sexy comments with available delimiters.'
+ endif
+
+ "make sure the lines arent already commented sexually
+ if !s:GetCanSexyCommentLines(a:topline, a:bottomline)
+ throw 'NERDCommenter.Nesting exception: cannot nest sexy comments'
+ endif
+
let sexyComMarker = s:GetSexyComMarker(0,0)
let sexyComMarkerSpaced = s:GetSexyComMarker(1,0)
@@ -1248,28 +1259,27 @@
" we jam the comment as far to the right as possible
let leftAlignIndx = s:GetLeftMostIndx(1, 1, a:topline, a:bottomline)
- "check whether the user has specified that this filetype use compact sexy
- "delimiters: i.e that the left/right delimiters should appear on the first
- "and last lines of the code and not on separate lines above/below the
- "first/last lines of code
- if &filetype =~ g:NERD_use_compact_sexy_com_regexp
- let spaceString = (&filetype =~ g:NERD_space_delim_filetype_regexp ? s:spaceStr : '')
-
- "comment the top line
- let theLine = getline(a:topline)
+ "check if we should use the compact style i.e that the left/right
+ "delimiters should appear on the first and last lines of the code and not
+ "on separate lines above/below the first/last lines of code
+ if g:NERDCompactSexyComs
+ let spaceString = (g:NERDSpaceDelims ? s:spaceStr : '')
+
+ "comment the top line
+ let theLine = getline(a:topline)
let lineHasTabs = s:HasLeadingTab(theLine)
if lineHasTabs
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
endif
let theLine = s:SwapOutterMultiPartDelimsForPlaceHolders(theLine)
- let theLine = s:AddLeftDelimAligned(left . spaceString, theLine, leftAlignIndx)
+ let theLine = s:AddLeftDelimAligned(left . spaceString, theLine, leftAlignIndx)
if lineHasTabs
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
- call setline(a:topline, theLine)
-
- "comment the bottom line
- let theLine = getline(a:bottomline)
+ call setline(a:topline, theLine)
+
+ "comment the bottom line
+ let theLine = getline(a:bottomline)
let lineHasTabs = s:HasLeadingTab(theLine)
if lineHasTabs
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
@@ -1279,34 +1289,34 @@
if lineHasTabs
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
- call setline(a:bottomline, theLine)
+ call setline(a:bottomline, theLine)
else
- " add the left delimiter one line above the lines that are to be commented
- call cursor(a:topline, 1)
- execute 'normal! O'
- call setline(a:topline, strpart(s:spaces, 0, leftAlignIndx) . left )
-
- " add the right delimiter after bottom line (we have to add 1 cos we moved
- " the lines down when we added the left delim
- call cursor(a:bottomline+1, 1)
- execute 'normal! o'
- call setline(a:bottomline+2, strpart(s:spaces, 0, leftAlignIndx) . strpart(s:spaces, 0, strlen(left)-strlen(sexyComMarker)) . right )
+ " add the left delimiter one line above the lines that are to be commented
+ call cursor(a:topline, 1)
+ execute 'normal! O'
+ call setline(a:topline, strpart(s:spaces, 0, leftAlignIndx) . left )
+
+ " add the right delimiter after bottom line (we have to add 1 cos we moved
+ " the lines down when we added the left delim
+ call cursor(a:bottomline+1, 1)
+ execute 'normal! o'
+ call setline(a:bottomline+2, strpart(s:spaces, 0, leftAlignIndx) . strpart(s:spaces, 0, strlen(left)-strlen(sexyComMarker)) . right )
endif
" go thru each line adding the sexyComMarker marker to the start of each
" line in the appropriate place to align them with the comment delims
let currentLine = a:topline+1
- while currentLine <= a:bottomline + (&filetype !~ g:NERD_use_compact_sexy_com_regexp)
- " get the line and convert the tabs to spaces
- let theLine = getline(currentLine)
+ while currentLine <= a:bottomline + !g:NERDCompactSexyComs
+ " get the line and convert the tabs to spaces
+ let theLine = getline(currentLine)
let lineHasTabs = s:HasLeadingTab(theLine)
if lineHasTabs
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
endif
- let theLine = s:SwapOutterMultiPartDelimsForPlaceHolders(theLine)
+ let theLine = s:SwapOutterMultiPartDelimsForPlaceHolders(theLine)
" add the sexyComMarker
let theLine = strpart(s:spaces, 0, leftAlignIndx) . strpart(s:spaces, 0, strlen(left)-strlen(sexyComMarker)) . sexyComMarkerSpaced . strpart(theLine, leftAlignIndx)
@@ -1323,87 +1333,42 @@
endfunction
-" Function: s:CommentLinesToggle(forceNested, alignLeft, alignRight, firstLine, lastLine) range {{{2
+" Function: s:CommentLinesToggle(forceNested, firstLine, lastLine) {{{2
" Applies "toggle" commenting to the given range of lines
"
" Args:
" -forceNested: a flag indicating whether the called is requesting the comment
" to be nested if need be
-" -alignRight/alignLeft: 0/1 if the comments delimiters should/shouldnt be
-" aligned left/right
" -firstLine/lastLine: the top and bottom lines to comment
-function s:CommentLinesToggle(forceNested, alignLeft, alignRight, firstLine, lastLine) range
- " we need to get the left and right indexes of the leftmost char in the
- " block of of lines and the right most char so that we can do alignment of
- " the delimiters if the user has specified
- let leftAlignIndx = s:GetLeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine)
- let rightAlignIndx = s:GetRightMostIndx(a:forceNested, 0, a:firstLine, a:lastLine)
-
- " gotta add the length of the left delimiter onto the rightAlignIndx cos
- " we'll be adding a left delim to the line
- let rightAlignIndx = rightAlignIndx + strlen(s:GetLeft(0, 1, 0))
-
+function s:CommentLinesToggle(forceNested, firstLine, lastLine)
" now we actually comment the lines. Do it line by line
let currentLine = a:firstLine
while currentLine <= a:lastLine
- " get the next line, check commentability and convert spaces to tabs
- let theLine = getline(currentLine)
+ " get the next line, check commentability and convert spaces to tabs
+ let theLine = getline(currentLine)
let lineHasLeadingTabs = s:HasLeadingTab(theLine)
- let theLine = s:ConvertLeadingTabsToSpaces(theLine)
+ let theLine = s:ConvertLeadingTabsToSpaces(theLine)
if s:GetCanToggleCommentLine(a:forceNested, currentLine)
"if the user has specified forceNesting then we check to see if we
"need to switch delimiters for place-holders
- if &filetype =~ g:NERD_place_holder_regexp
+ if g:NERDUsePlaceHolders
let theLine = s:SwapOutterMultiPartDelimsForPlaceHolders(theLine)
endif
- if a:alignLeft
- " let theLine = s:AddLeftDelimAligned(b:left, theLine, leftAlignIndx)
- let theLine = s:AddLeftDelimAligned(s:GetLeft(0,1,0), theLine, leftAlignIndx)
- else
- let theLine = s:AddLeftDelim(s:GetLeft(0, 1, 0), theLine)
- endif
- if a:alignRight
- let theLine = s:AddRightDelimAligned(s:GetRight(0, 1, 0), theLine, rightAlignIndx)
- else
- let theLine = s:AddRightDelim(s:GetRight(0, 1, 0), theLine)
- endif
-
- "re-align the delims existing if needed
- elseif (a:alignLeft || a:alignRight) && !a:forceNested && (s:IsCommentedFromStartOfLine(b:left, theLine) || s:IsCommentedFromStartOfLine(b:leftAlt, theLine))
- "get the delims the line is commented with
- if s:IsCommentedFromStartOfLine(b:left, theLine)
- let l:left = s:GetLeft(0, 1, 0)
- let l:right = s:GetRight(0, 1, 0)
- else
- let l:left = s:GetLeft(1, 1, 0)
- let l:right = s:GetRight(1, 1, 0)
- endif
- let theLine = s:UncommentLineNormal(theLine)
-
- if a:alignLeft
- let theLine = s:AddLeftDelimAligned(l:left, theLine, leftAlignIndx)
- else
- let theLine = s:AddLeftDelim(l:left, theLine)
- endif
- if a:alignRight
- let theLine = s:AddRightDelimAligned(l:right, theLine, rightAlignIndx)
- else
- let theLine = s:AddRightDelim(l:right, theLine)
- endif
-
+ let theLine = s:AddLeftDelim(s:GetLeft(0, 1, 0), theLine)
+ let theLine = s:AddRightDelim(s:GetRight(0, 1, 0), theLine)
endif
" restore leading tabs if appropriate
- if lineHasLeadingTabs
- let theLine = s:ConvertLeadingSpacesToTabs(theLine)
- endif
-
- " we are done with this line
- call setline(currentLine, theLine)
- let currentLine = currentLine + 1
+ if lineHasLeadingTabs
+ let theLine = s:ConvertLeadingSpacesToTabs(theLine)
+ endif
+
+ " we are done with this line
+ call setline(currentLine, theLine)
+ let currentLine = currentLine + 1
endwhile
endfunction
@@ -1418,16 +1383,16 @@
" -bottomCol: the bottom right col for this comment
" -forceNested: whether the caller wants comments to be nested if the
" line(s) are already commented
-function s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested) range
+function s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested)
"we may need to switch to the alt delims if the current ones arent
"multi-part.
let didSwitchDelims = -1
"if the right delim isnt empty then we can use it for this comment
- if b:right != '' || &filetype !~ g:NERD_allow_any_visual_delims_regexp
+ if b:right != '' || !g:NERDAllowAnyVisualDelims
let didSwitchDelims = 0
- "if the alternative comment right delimiter isnt null then we can use the
- "alternative right delims
+ "if the alternative comment right delimiter isnt null then we can use the
+ "alternative right delims
elseif b:rightAlt != ''
let didSwitchDelims = 1
call <sid>SwitchToAlternativeDelimiters(0)
@@ -1436,12 +1401,11 @@
"if there is only one line in the comment then just do it
if a:topLine == a:bottomLine
call s:CommentBlock(a:topLine, a:bottomLine, a:topCol, a:bottomCol, a:forceNested)
-
+
"there are multiple lines in the comment
else
"comment the top line
call s:CommentBlock(a:topLine, a:topLine, a:topCol, strlen(getline(a:topLine)), a:forceNested)
-
"comment out all the lines in the middle of the comment
let topOfRange = a:topLine+1
let bottomOfRange = a:bottomLine-1
@@ -1457,90 +1421,16 @@
endif
"stick the cursor back on the char it was on before the comment
- call cursor(a:topLine, a:topCol + strlen(b:left) + &filetype =~ g:NERD_space_delim_filetype_regexp)
-
+ call cursor(a:topLine, a:topCol + strlen(b:left) + g:NERDSpaceDelims)
+
"if we switched delims then we gotta go back to what they were before
if didSwitchDelims == 1
call s:SwitchToAlternativeDelimiters(0)
endif
-
-
-endfunction
-
-
-" Function: s:DoComment(forceNested, isVisual, alignLeft, alignRight, type) function {{{2
-" This function is a Wrapper for the main commenting functions
-"
-" Args:
-" -forceNested: a flag indicating whether comments should be nested
-" -isVisual: a flag indicating whether the comment is requested in visual
-" mode or not
-" -alignLeft/alignRight: flags indicating whether the comment delimiters should be
-" aligned left/right
-" -type: the type of commenting requested. Can be "sexy", "invert",
-" "minimal", "toggle" or "norm"
-function s:DoComment(forceNested, isVisual, alignLeft, alignRight, type) range
- " we want case sensitivity when commenting
- let prevIgnoreCase = &ignorecase
- set noignorecase
-
- " remember where the cursor was initially so we can move it back
- if a:isVisual
- normal! gv
- endif
- call s:SaveCursorPosition()
-
- if a:type == 'norm'
- if a:isVisual && visualmode() == ""
- call s:CommentBlock(line("'<"), line("'>"), col("'<"), col("'>"), a:forceNested)
- elseif a:isVisual && visualmode() == "v" && (g:NERD_comment_whole_lines_in_v_mode==0 || (g:NERD_comment_whole_lines_in_v_mode==2 && s:HasMultipartDelims()))
- call s:CommentRegion(line("'<"), col("'<"), line("'>"), col("'>"), a:forceNested)
- else
- call s:CommentLines(a:forceNested, a:alignLeft, a:alignRight, a:firstline, a:lastline)
- endif
- elseif a:type == 'invert'
- call s:InvertComment(a:firstline, a:lastline)
- elseif a:type == 'sexy'
- " see if the selected regions have any sexy comments
- let currentLine = a:firstline
- let foundSexyCom=0
- while(currentLine <= a:lastline)
- if(s:FindBoundingLinesOfSexyCom(currentLine) != -1)
- let foundSexyCom=1
- break
- endif
- let currentLine = currentLine + 1
- endwhile
-
- " we dont allow nested comments yet..
- if foundSexyCom
- call s:NerdEcho("NERD_comments: Sexy comment aborted. Nested sexy commenting not supported yet..", 0)
- else
- call s:CommentLinesSexy(a:firstline, a:lastline)
- endif
-
- " check if the user requested a toggle comment
- elseif a:type == 'toggle'
- let theLine = getline(a:firstline)
- if s:FindBoundingLinesOfSexyCom(a:firstline)!=-1 || s:IsCommentedFromStartOfLine(b:left, theLine) || s:IsCommentedFromStartOfLine(b:leftAlt, theLine)
- execute ':' . a:firstline . ',' . a:lastline .'call s:UncommentLines(1)'
- else
- call s:CommentLinesToggle(a:forceNested, a:alignLeft, a:alignRight, a:firstline, a:lastline)
- endif
- elseif a:type == 'minimal'
- "check that minimal comments can be done on this filetype
- if b:right == '' && b:rightAlt == ''
- call s:NerdEcho('Minimal comments can only be used for filetypes that have multipart delimiters', 0)
- return
- endif
- call s:CommentLinesMinimal(a:firstline, a:lastline)
- endif
-
- let &ignorecase = prevIgnoreCase
-
- " move the cursor back to where it was
- call s:RestoreCursorPostion()
-endfunction
+
+
+endfunction
+
" Function: s:InvertComment(firstLine, lastLine) function {{{2
" Inverts the comments on the lines between and including the given line
@@ -1548,7 +1438,7 @@
" Args:
" -firstLine: the top of the range of lines to be inverted
" -lastLine: the bottom of the range of lines to be inverted
-function s:InvertComment(firstLine, lastLine) range
+function s:InvertComment(firstLine, lastLine)
" go thru all lines in the given range
let currentLine = a:firstLine
@@ -1559,7 +1449,7 @@
" if the line is commented normally, uncomment it
if s:IsCommentedFromStartOfLine(b:left, theLine) || s:IsCommentedFromStartOfLine(b:leftAlt, theLine)
- execute ':' currentLine . ',' . currentLine . 'call s:UncommentLines(1)'
+ call s:UncommentLines(1, currentLine, currentLine)
let currentLine = currentLine + 1
" check if the line is commented sexually
@@ -1575,11 +1465,102 @@
" the line isnt commented
else
- call s:CommentLinesToggle(1, 0, 0, currentLine, currentLine)
+ call s:CommentLinesToggle(1, currentLine, currentLine)
let currentLine = currentLine + 1
endif
endwhile
+endfunction
+
+" Function: NERDComment(isVisual, alignLeft, alignRight, type) function {{{2
+" This function is a Wrapper for the main commenting functions
+"
+" Args:
+" -isVisual: a flag indicating whether the comment is requested in visual
+" mode or not
+" -type: the type of commenting requested. Can be 'sexy', 'invert',
+" 'minimal', 'toggle', 'alignLeft', 'alignRight', 'alignBoth', 'norm',
+" 'nested', 'toEOL', 'prepend', 'append', 'insert', 'uncomment'
+function! NERDComment(isVisual, type)
+ " we want case sensitivity when commenting
+ let prevIgnoreCase = &ignorecase
+ set noignorecase
+
+ if a:isVisual
+ let firstLine = line("'<")
+ let lastLine = line("'>")
+ let firstCol = col("'<")
+ let lastCol = col("'>")
+ else
+ let firstLine = line(".")
+ let lastLine = firstLine
+ endif
+
+ let forceNested = (a:type == 'nested' || g:NERDDefaultNesting)
+
+ if a:type == 'norm' || a:type == 'nested'
+ if a:isVisual && visualmode() == ""
+ call s:CommentBlock(firstLine, lastLine, firstCol, lastCol, forceNested)
+ elseif a:isVisual && visualmode() == "v" && (g:NERDCommentWholeLinesInVMode==0 || (g:NERDCommentWholeLinesInVMode==2 && s:HasMultipartDelims()))
+ call s:CommentRegion(firstLine, firstCol, lastLine, lastCol, forceNested)
+ else
+ call s:CommentLines(forceNested, 0, 0, firstLine, lastLine)
+ endif
+
+ elseif a:type == 'alignLeft' || a:type == 'alignRight' || a:type == 'alignBoth'
+ let alignLeft = (a:type == 'alignLeft' || a:type == 'alignBoth')
+ let alignRight = (a:type == 'alignRight' || a:type == 'alignBoth')
+ call s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine)
+
+ elseif a:type == 'invert'
+ call s:InvertComment(firstLine, lastLine)
+
+ elseif a:type == 'sexy'
+ try
+ call s:CommentLinesSexy(firstLine, lastLine)
+ catch /NERDCommenter.Delimiters/
+ call s:NerdEcho("Sexy comments cannot be done with the available delimiters", 0)
+ catch /NERDCommenter.Nesting/
+ call s:NerdEcho("Sexy comment aborted. Nested sexy cannot be nested", 0)
+ endtry
+
+ elseif a:type == 'toggle'
+ let theLine = getline(firstLine)
+
+ if s:FindBoundingLinesOfSexyCom(firstLine)!=-1 || s:IsCommentedFromStartOfLine(b:left, theLine) || s:IsCommentedFromStartOfLine(b:leftAlt, theLine)
+ call s:UncommentLines(1, firstLine, lastLine)
+ else
+ call s:CommentLinesToggle(forceNested, firstLine, lastLine)
+ endif
+
+ elseif a:type == 'minimal'
+ try
+ call s:CommentLinesMinimal(firstLine, lastLine)
+ catch /NERDCommenter.Delimiters/
+ call s:NerdEcho("Minimal comments can only be used for filetypes that have multipart delimiters.", 0)
+ catch /NERDCommenter.Settings/
+ call s:NerdEcho("Place holders are required but disabled.", 0)
+ endtry
+
+ elseif a:type == 'toEOL'
+ call s:SaveScreenState()
+ call s:CommentBlock(firstLine, firstLine, col("."), col("$")-1, 1)
+ call s:RestoreScreenState()
+
+ elseif a:type == 'prepend'
+ call s:PrependCommentToLine()
+
+ elseif a:type == 'append'
+ call s:AppendCommentToLine()
+
+ elseif a:type == 'insert'
+ call s:PlaceDelimitersAndInsBetween()
+
+ elseif a:type == 'uncomment'
+ call s:UncommentLines(0, firstLine, lastLine)
+ endif
+
+ let &ignorecase = prevIgnoreCase
endfunction
" Function: s:PlaceDelimitersAndInsBetween() function {{{2
@@ -1624,7 +1605,7 @@
endif
endif
normal l
-
+
"if needed convert spaces back to tabs and adjust the cursors col
"accordingly
if lineHasLeadTabs
@@ -1635,7 +1616,7 @@
startinsert
endfunction
-
+
" Function: s:PrependCommentToLine(){{{2
" This function prepends comment delimiters to the start of line and places
" the cursor in position to start typing the comment
@@ -1663,7 +1644,7 @@
" by the len of the right delimiter so we insert between the delimiters
if lenRight > 0
let leftMoveAmount = lenRight
- execute ":normal " . leftMoveAmount . "h"
+ execute ":normal " . leftMoveAmount . "h"
endif
normal l
@@ -1696,8 +1677,8 @@
let lenLeft = strlen(left)
let lenRight = strlen(right)
- let delimsSpaced = (&filetype =~ g:NERD_space_delim_filetype_regexp || &filetype !~ g:NERD_dont_remove_spaces_regexp)
-
+ let delimsSpaced = (g:NERDSpaceDelims || g:NERDRemoveExtraSpaces)
+
let line = a:line
"look for the left delimiter, if we find it, remove it.
@@ -1705,11 +1686,11 @@
if leftIndx != -1
let line = strpart(line, 0, leftIndx) . strpart(line, leftIndx+lenLeft)
- "if the user has specified that there is a space after the left delim
- "then check for the space and remove it if it is there
- if delimsSpaced && strpart(line, leftIndx, s:lenSpaceStr) == s:spaceStr
- let line = strpart(line, 0, leftIndx) . strpart(line, leftIndx+s:lenSpaceStr)
- endif
+ "if the user has specified that there is a space after the left delim
+ "then check for the space and remove it if it is there
+ if delimsSpaced && strpart(line, leftIndx, s:lenSpaceStr) == s:spaceStr
+ let line = strpart(line, 0, leftIndx) . strpart(line, leftIndx+s:lenSpaceStr)
+ endif
endif
"look for the right delimiter, if we find it, remove it
@@ -1717,36 +1698,40 @@
if rightIndx != -1
let line = strpart(line, 0, rightIndx) . strpart(line, rightIndx+lenRight)
- "if the user has specified that there is a space before the right delim
- "then check for the space and remove it if it is there
- if delimsSpaced && strpart(line, rightIndx-s:lenSpaceStr, s:lenSpaceStr) == s:spaceStr && right != ''
- let line = strpart(line, 0, rightIndx-s:lenSpaceStr) . strpart(line, rightIndx)
- endif
+ "if the user has specified that there is a space before the right delim
+ "then check for the space and remove it if it is there
+ if delimsSpaced && strpart(line, rightIndx-s:lenSpaceStr, s:lenSpaceStr) == s:spaceStr && right != ''
+ let line = strpart(line, 0, rightIndx-s:lenSpaceStr) . strpart(line, rightIndx)
+ endif
endif
return line
endfunction
-" Function: s:UncommentLines(onlyWholeLineComs) {{{2
-" Args:
+" Function: s:UncommentLines(onlyWholeLineComs, topLine, bottomLine) {{{2
" This function uncomments the given lines
-function s:UncommentLines(onlyWholeLineComs) range
+"
+" Args:
+" onlyWholeLineComs: should be 1 for toggle style uncommenting
+" topLine: the top line of the visual selection to uncomment
+" bottomLine: the bottom line of the visual selection to uncomment
+function s:UncommentLines(onlyWholeLineComs, topLine, bottomLine)
"make local copies of a:firstline and a:lastline and, if need be, swap
"them around if the top line is below the bottom
- let l:firstline = a:firstline
- let l:lastline = a:lastline
+ let l:firstline = a:topLine
+ let l:lastline = a:bottomLine
if firstline > lastline
- let firstline = lastline
- let lastline = a:firstline
+ let firstline = lastline
+ let lastline = a:topLine
endif
"go thru each line uncommenting each line removing sexy comments
let currentLine = firstline
while currentLine <= lastline
- "check the current line to see if it is part of a sexy comment
- let sexyComBounds = s:FindBoundingLinesOfSexyCom(currentLine)
- if sexyComBounds != -1
+ "check the current line to see if it is part of a sexy comment
+ let sexyComBounds = s:FindBoundingLinesOfSexyCom(currentLine)
+ if sexyComBounds != -1
"we need to store the num lines in the buf before the comment is
"removed so we know how many lines were removed when the sexy com
@@ -1764,17 +1749,17 @@
let numLinesRemoved = numLinesBeforeSexyComRemoved - numLinesAfterSexyComRemoved
let currentLine = bottomBound - numLinesRemoved + 1
let lastline = lastline - numLinesRemoved
-
- "no sexy com was detected so uncomment the line as normal
- else
- let theLine = getline(currentLine)
- if a:onlyWholeLineComs && (s:IsCommentedFromStartOfLine(b:left, theLine) || s:IsCommentedFromStartOfLine(b:leftAlt, theLine))
- call s:UncommentLinesNormal(currentLine, currentLine)
- elseif !a:onlyWholeLineComs
- call s:UncommentLinesNormal(currentLine, currentLine)
- endif
+
+ "no sexy com was detected so uncomment the line as normal
+ else
+ let theLine = getline(currentLine)
+ if a:onlyWholeLineComs && (s:IsCommentedFromStartOfLine(b:left, theLine) || s:IsCommentedFromStartOfLine(b:leftAlt, theLine))
+ call s:UncommentLinesNormal(currentLine, currentLine)
+ elseif !a:onlyWholeLineComs
+ call s:UncommentLinesNormal(currentLine, currentLine)
+ endif
let currentLine = currentLine + 1
- endif
+ endif
endwhile
endfunction
@@ -1792,7 +1777,7 @@
"check if it is even possible for sexy comments to exist with the
"available delimiters
if left == -1 || right == -1
- return -1
+ throw 'NERDCommenter.Delimiters exception: cannot uncomment sexy comments with available delimiters.'
endif
let leftUnEsc = s:GetSexyComLeft(0,0)
@@ -1800,8 +1785,6 @@
let sexyComMarker = s:GetSexyComMarker(0, 1)
let sexyComMarkerUnEsc = s:GetSexyComMarker(0, 0)
-
- let removeSpace = (&filetype =~ g:NERD_space_delim_filetype_regexp || &filetype !~ g:NERD_dont_remove_spaces_regexp)
"the markerOffset is how far right we need to move the sexyComMarker to
"line it up with the end of the left delim
@@ -1817,7 +1800,7 @@
" remove the sexy comment marker from the line. We also remove the
" space after it if there is one and if appropriate options are set
let sexyComMarkerIndx = stridx(theLine, sexyComMarkerUnEsc)
- if strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc), s:lenSpaceStr) == s:spaceStr && removeSpace
+ if strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc), s:lenSpaceStr) == s:spaceStr && g:NERDSpaceDelims
let theLine = strpart(theLine, 0, sexyComMarkerIndx - markerOffset) . strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc)+s:lenSpaceStr)
else
let theLine = strpart(theLine, 0, sexyComMarkerIndx - markerOffset) . strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc))
@@ -1838,24 +1821,24 @@
let theLine = getline(a:topline)
" if the first line contains only the left delim then just delete it
- if theLine =~ '^[ \t]*' . left . '[ \t]*$' && &filetype !~ g:NERD_use_compact_sexy_com_regexp
- call cursor(a:topline, 1)
- normal dd
- let bottomline = bottomline - 1
-
+ if theLine =~ '^[ \t]*' . left . '[ \t]*$' && !g:NERDCompactSexyComs
+ call cursor(a:topline, 1)
+ normal dd
+ let bottomline = bottomline - 1
+
" topline contains more than just the left delim
else
- " remove the delim. If there is a space after it
- " then remove this too if appropriate
- let delimIndx = stridx(theLine, leftUnEsc)
- if strpart(theLine, delimIndx+strlen(leftUnEsc), s:lenSpaceStr) == s:spaceStr && removeSpace
+ " remove the delim. If there is a space after it
+ " then remove this too if appropriate
+ let delimIndx = stridx(theLine, leftUnEsc)
+ if strpart(theLine, delimIndx+strlen(leftUnEsc), s:lenSpaceStr) == s:spaceStr && g:NERDSpaceDelims
let theLine = strpart(theLine, 0, delimIndx) . strpart(theLine, delimIndx+strlen(leftUnEsc)+s:lenSpaceStr)
else
let theLine = strpart(theLine, 0, delimIndx) . strpart(theLine, delimIndx+strlen(leftUnEsc))
- endif
- let theLine = s:SwapOutterPlaceHoldersForMultiPartDelims(theLine)
- call setline(a:topline, theLine)
+ endif
+ let theLine = s:SwapOutterPlaceHoldersForMultiPartDelims(theLine)
+ call setline(a:topline, theLine)
endif
" get the last line so we can remove the right delim
@@ -1863,36 +1846,36 @@
" if the bottomline contains only the right delim then just delete it
if theLine =~ '^[ \t]*' . right . '[ \t]*$'
- call cursor(bottomline, 1)
- normal dd
+ call cursor(bottomline, 1)
+ normal dd
" the last line contains more than the right delim
else
- " remove the right delim. If there is a space after it and
- " if the appropriate options are set then remove this too.
- let delimIndx = s:GetLastIndexOfDelim(rightUnEsc, theLine)
- if strpart(theLine, delimIndx+strlen(leftUnEsc), s:lenSpaceStr) == s:spaceStr && removeSpace
+ " remove the right delim. If there is a space after it and
+ " if the appropriate options are set then remove this too.
+ let delimIndx = s:GetLastIndexOfDelim(rightUnEsc, theLine)
+ if strpart(theLine, delimIndx+strlen(leftUnEsc), s:lenSpaceStr) == s:spaceStr && g:NERDSpaceDelims
let theLine = strpart(theLine, 0, delimIndx) . strpart(theLine, delimIndx+strlen(rightUnEsc)+s:lenSpaceStr)
else
let theLine = strpart(theLine, 0, delimIndx) . strpart(theLine, delimIndx+strlen(rightUnEsc))
- endif
-
- " if the last line also starts with a sexy comment marker then we
- " remove this as well
- if theLine =~ '^[ \t]*' . sexyComMarker
-
- " remove the sexyComMarker. If there is a space after it then
+ endif
+
+ " if the last line also starts with a sexy comment marker then we
+ " remove this as well
+ if theLine =~ '^[ \t]*' . sexyComMarker
+
+ " remove the sexyComMarker. If there is a space after it then
" remove that too
- let sexyComMarkerIndx = stridx(theLine, sexyComMarkerUnEsc)
- if strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc), s:lenSpaceStr) == s:spaceStr && removeSpace
+ let sexyComMarkerIndx = stridx(theLine, sexyComMarkerUnEsc)
+ if strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc), s:lenSpaceStr) == s:spaceStr && g:NERDSpaceDelims
let theLine = strpart(theLine, 0, sexyComMarkerIndx - markerOffset ) . strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc)+s:lenSpaceStr)
else
let theLine = strpart(theLine, 0, sexyComMarkerIndx - markerOffset ) . strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc))
- endif
- endif
-
- let theLine = s:SwapOutterPlaceHoldersForMultiPartDelims(theLine)
- call setline(bottomline, theLine)
+ endif
+ endif
+
+ let theLine = s:SwapOutterPlaceHoldersForMultiPartDelims(theLine)
+ call setline(bottomline, theLine)
endif
endfunction
@@ -1909,15 +1892,14 @@
"it is commented with b:left and b:right so remove these delims
if lineCommentStatus == 1
let line = s:RemoveDelimiters(b:leftAlt, b:rightAlt, line)
-
+
"it is commented with b:leftAlt and b:rightAlt so remove these delims
- elseif lineCommentStatus == 2 && g:NERD_dont_remove_alt_coms==0
+ elseif lineCommentStatus == 2 && g:NERDRemoveAltComs
let line = s:RemoveDelimiters(b:left, b:right, line)
-
+
"it is not properly commented with any delims so we check if it has
"any random left or right delims on it and remove the outtermost ones
else
-
"get the positions of all delim types on the line
let indxLeft = s:FindDelimiterIndex(b:left, line)
let indxLeftAlt = s:FindDelimiterIndex(b:leftAlt, line)
@@ -1942,11 +1924,11 @@
let indxLeft = s:FindDelimiterIndex(b:left, line)
let indxLeftAlt = s:FindDelimiterIndex(b:leftAlt, line)
- let indxLeftPlace = s:FindDelimiterIndex(g:NERD_lPlace, line)
-
- let indxRightPlace = s:FindDelimiterIndex(g:NERD_rPlace, line)
+ let indxLeftPlace = s:FindDelimiterIndex(g:NERDLPlace, line)
+
+ let indxRightPlace = s:FindDelimiterIndex(g:NERDRPlace, line)
let indxRightAlt = s:FindDelimiterIndex(b:rightAlt, line)
- let indxRightPlace = s:FindDelimiterIndex(g:NERD_rPlace, line)
+ let indxRightPlace = s:FindDelimiterIndex(g:NERDRPlace, line)
let right = b:right
let left = b:left
@@ -1961,11 +1943,11 @@
"real delimiters
if indxLeftPlace != -1
if (indxLeftPlace < indxLeft || indxLeft==-1) && (indxLeftPlace < indxLeftAlt || indxLeftAlt==-1)
- let line = s:ReplaceDelims(g:NERD_lPlace, g:NERD_rPlace, left, right, line)
+ let line = s:ReplaceDelims(g:NERDLPlace, g:NERDRPlace, left, right, line)
endif
elseif indxRightPlace != -1
if (indxRightPlace < indxLeft || indxLeft==-1) && (indxLeftPlace < indxLeftAlt || indxLeftAlt==-1)
- let line = s:ReplaceDelims(g:NERD_lPlace, g:NERD_rPlace, left, right, line)
+ let line = s:ReplaceDelims(g:NERDLPlace, g:NERDRPlace, left, right, line)
endif
endif
@@ -2048,9 +2030,9 @@
function s:ConvertLeadingSpacesToTabs(line)
let toReturn = a:line
while toReturn =~ '^\t*' . s:tabSpace . '\(.*\)$'
- let toReturn = substitute(toReturn, '^\(\t*\)' . s:tabSpace . '\(.*\)$' , '\1\t\2' , "")
+ let toReturn = substitute(toReturn, '^\(\t*\)' . s:tabSpace . '\(.*\)$' , '\1\t\2' , "")
endwhile
-
+
return toReturn
endfunction
@@ -2064,9 +2046,9 @@
function s:ConvertLeadingTabsToSpaces(line)
let toReturn = a:line
while toReturn =~ '^\( *\)\t'
- let toReturn = substitute(toReturn, '^\( *\)\t', '\1' . s:tabSpace , "")
+ let toReturn = substitute(toReturn, '^\( *\)\t', '\1' . s:tabSpace , "")
endwhile
-
+
return toReturn
endfunction
@@ -2081,7 +2063,6 @@
function s:CountNonESCedOccurances(str, searchstr, escChar)
"get the index of the first occurrence of searchstr
let indx = stridx(a:str, a:searchstr)
-
"if there is an instance of searchstr in str process it
if indx != -1
@@ -2148,13 +2129,13 @@
" -delimiter: the delimiter we are looking to find the index of
" -line: the line we are looking for delimiter on
function s:FindDelimiterIndex(delimiter, line)
-
+
"make sure the delimiter isnt empty otherwise we go into an infinite loop.
if a:delimiter == ""
return -1
endif
- "get the delimiter without esc chars and its length
+
let l:delimiter = a:delimiter
let lenDel = strlen(l:delimiter)
@@ -2210,13 +2191,13 @@
let left = ''
let right = ''
if b:right != ''
- let left = s:GetLeft(0,0,1)
- let right = s:GetRight(0,0,1)
+ let left = s:GetLeft(0,0,1)
+ let right = s:GetRight(0,0,1)
elseif b:rightAlt != ''
- let left = s:GetLeft(1,0,1)
- let right = s:GetRight(1,0,1)
+ let left = s:GetLeft(1,0,1)
+ let right = s:GetRight(1,0,1)
else
- return -1
+ return -1
endif
let sexyComMarker = s:GetSexyComMarker(0, 1)
@@ -2227,44 +2208,44 @@
let currentLine = a:lineNum
while top == -1 || bottom == -1
- let theLine = getline(currentLine)
-
- "check if the current line is the top of the sexy comment
- if theLine =~ '^[ \t]*' . left && theLine !~ '.*' . right
- let top = currentLine
- let currentLine = a:lineNum
-
- "check if the current line is the bottom of the sexy comment
- elseif theLine =~ '^[ \t]*' . right && theLine !~ '.*' . left
- let bottom = currentLine
-
- "the right delimiter is on the same line as the last sexyComMarker
- elseif theLine =~ '^[ \t]*' . sexyComMarker . '.*' . right
- let bottom = currentLine
-
- "we have not found the top or bottom line so we assume currentLine is an
- "intermediate line and look to prove otherwise
- else
-
- "if the line doesnt start with a sexyComMarker then it is not a sexy
- "comment
- if theLine !~ '^[ \t]*' . sexyComMarker
- return -1
- endif
-
- endif
-
- "if top is -1 then we havent found the top yet so keep looking up
- if top == -1
- let currentLine = currentLine - 1
- "if we have found the top line then go down looking for the bottom
- else
- let currentLine = currentLine + 1
- endif
-
+ let theLine = getline(currentLine)
+
+ "check if the current line is the top of the sexy comment
+ if theLine =~ '^[ \t]*' . left && theLine !~ '.*' . right
+ let top = currentLine
+ let currentLine = a:lineNum
+
+ "check if the current line is the bottom of the sexy comment
+ elseif theLine =~ '^[ \t]*' . right && theLine !~ '.*' . left
+ let bottom = currentLine
+
+ "the right delimiter is on the same line as the last sexyComMarker
+ elseif theLine =~ '^[ \t]*' . sexyComMarker . '.*' . right
+ let bottom = currentLine
+
+ "we have not found the top or bottom line so we assume currentLine is an
+ "intermediate line and look to prove otherwise
+ else
+
+ "if the line doesnt start with a sexyComMarker then it is not a sexy
+ "comment
+ if theLine !~ '^[ \t]*' . sexyComMarker
+ return -1
+ endif
+
+ endif
+
+ "if top is -1 then we havent found the top yet so keep looking up
+ if top == -1
+ let currentLine = currentLine - 1
+ "if we have found the top line then go down looking for the bottom
+ else
+ let currentLine = currentLine + 1
+ endif
+
endwhile
- "encode the answer in a string and return it
+ "encode the answer in a string and return it
return top . ',' . bottom
endfunction
@@ -2282,30 +2263,42 @@
" make sure we don't comment lines that are just spaces or tabs or empty.
if theLine =~ "^[ \t]*$"
- return 0
- endif
-
+ return 0
+ endif
+
"if the line is part of a sexy comment then just flag it...
if s:FindBoundingLinesOfSexyCom(a:lineNum) != -1
- return 0
+ return 0
endif
let isCommented = s:IsCommentedNormOrSexy(a:lineNum)
- let canUsePlaceHolders = (&filetype =~ g:NERD_place_holder_regexp)
"if the line isnt commented return true
if !isCommented
- return 1
+ return 1
endif
"if the line is commented but nesting is allowed then return true
- if a:forceNested && (b:right=='' || canUsePlaceHolders)
- return 1
+ if a:forceNested && (b:right=='' || g:NERDUsePlaceHolders)
+ return 1
endif
return 0
endfunction
+" Function: s:GetCanSexyCommentLines(topline, bottomline) {{{2
+" Return: 1 if the given lines can be commented sexually, 0 otherwise
+function s:GetCanSexyCommentLines(topline, bottomline)
+ " see if the selected regions have any sexy comments
+ let currentLine = a:topline
+ while(currentLine <= a:bottomline)
+ if(s:FindBoundingLinesOfSexyCom(currentLine) != -1)
+ return 0
+ endif
+ let currentLine = currentLine + 1
+ endwhile
+ return 1
+endfunction
" Function: s:GetCanToggleCommentLine(forceNested, line) {{{2
"This function is used to determine whether the given line can be toggle commented.
"It returns 1 if it can be and 0 otherwise
@@ -2320,12 +2313,12 @@
" make sure we don't comment lines that are just spaces or tabs or empty.
if theLine =~ "^[ \t]*$"
- return 0
- endif
-
+ return 0
+ endif
+
"if the line is part of a sexy comment then just flag it...
if s:FindBoundingLinesOfSexyCom(a:lineNum) != -1
- return 0
+ return 0
endif
return 1
@@ -2344,7 +2337,7 @@
function s:GetIndxInSubstr(indx, substr, str)
"validate params
if a:substr=="" || a:str=="" || a:indx<0
- return -1
+ return -1
endif
let lenSubstr = strlen(a:substr)
@@ -2354,22 +2347,22 @@
"substsr
let i = 0
let i2 = 0
-
+
"keep looping till there are no more instances of substr left
while i != -1
- "get the indx of the next occurrence of substr
- let i = stridx(strpart(a:str, i2), a:substr)
- let i2 = i2 + i
-
- "if indx lies inside this instance of substr return its relative
- "position inside the substr
- if i != -1 && a:indx < i2+lenSubstr && a:indx >= i2
- return a:indx - i2
- endif
-
- "move past this instance of substr
- let i2 = i2 + lenSubstr
+ "get the indx of the next occurrence of substr
+ let i = stridx(strpart(a:str, i2), a:substr)
+ let i2 = i2 + i
+
+ "if indx lies inside this instance of substr return its relative
+ "position inside the substr
+ if i != -1 && a:indx < i2+lenSubstr && a:indx >= i2
+ return a:indx - i2
+ endif
+
+ "move past this instance of substr
+ let i2 = i2 + lenSubstr
endwhile
@@ -2393,24 +2386,24 @@
"bail
let indx = s:FindDelimiterIndex(delim, a:str)
if indx == -1
- return -1
+ return -1
endif
"keep moving to the next instance of delim in str till there is none left
while 1
-
- "search for the next delim after the previous one
- let searchStr = strpart(a:str, indx+lenDelim)
- let indx2 = s:FindDelimiterIndex(delim, searchStr)
-
- "if we find a delim update indx to record the position of it, if we
- "dont find another delim then indx is the last one so break out of
- "this loop
- if indx2 != -1
- let indx = indx + indx2 + lenDelim
- else
- break
- endif
+
+ "search for the next delim after the previous one
+ let searchStr = strpart(a:str, indx+lenDelim)
+ let indx2 = s:FindDelimiterIndex(delim, searchStr)
+
+ "if we find a delim update indx to record the position of it, if we
+ "dont find another delim then indx is the last one so break out of
+ "this loop
+ if indx2 != -1
+ let indx = indx + indx2 + lenDelim
+ else
+ break
+ endif
endwhile
return indx
@@ -2427,7 +2420,7 @@
" -topline: the top line to be checked
" -bottomline: the bottom line to be checked
function s:GetLeftMostIndx(countCommentedLines, countEmptyLines, topline, bottomline)
-
+
" declare the left most index as an extreme value
let leftMostIndx = 1000
@@ -2435,10 +2428,10 @@
let currentLine = a:topline
while currentLine <= a:bottomline
- " get the next line and if it is allowed to be commented, or is not
- " commented, check it
- let theLine = getline(currentLine)
- if a:countEmptyLines || theLine !~ '^[ \t]*$'
+ " get the next line and if it is allowed to be commented, or is not
+ " commented, check it
+ let theLine = getline(currentLine)
+ if a:countEmptyLines || theLine !~ '^[ \t]*$'
if a:countCommentedLines || (!s:IsCommented(b:left, b:right, theLine) && !s:IsCommented(b:leftAlt, b:rightAlt, theLine))
" convert spaces to tabs and get the number of leading spaces for
" this line and update leftMostIndx if need be
@@ -2448,16 +2441,16 @@
let leftMostIndx = leadSpaceOfLine
endif
endif
- endif
-
- " move on to the next line
- let currentLine = currentLine + 1
+ endif
+
+ " move on to the next line
+ let currentLine = currentLine + 1
endwhile
if leftMostIndx == 1000
- return 0
+ return 0
else
- return leftMostIndx
+ return leftMostIndx
endif
endfunction
@@ -2466,8 +2459,7 @@
" Args:
" -alt: specifies whether to get left or left-alternative delim
" -space: specifies whether the delim should be spaced or not
-" (the space string will only be added if NERD_space_delim_filetype_regexp
-" is specified for the current filetype)
+" (the space string will only be added if NERDSpaceDelims is set)
" -esc: specifies whether the tricky chars in the delim should be ESCed
function s:GetLeft(alt, space, esc)
let delim = b:left
@@ -2483,7 +2475,7 @@
return ''
endif
- if a:space && &filetype =~ g:NERD_space_delim_filetype_regexp
+ if a:space && g:NERDSpaceDelims
let delim = delim . s:spaceStr
endif
@@ -2499,8 +2491,7 @@
" Args:
" -alt: specifies whether to get right or right-alternative delim
" -space: specifies whether the delim should be spaced or not
-" (the space string will only be added if NERD_space_delim_filetype_regexp
-" is specified for the current filetype)
+" (the space string will only be added if NERDSpaceDelims is set)
" -esc: specifies whether the tricky chars in the delim should be ESCed
function s:GetRight(alt, space, esc)
let delim = b:right
@@ -2516,7 +2507,7 @@
return ''
endif
- if a:space && &filetype =~ g:NERD_space_delim_filetype_regexp
+ if a:space && g:NERDSpaceDelims
let delim = s:spaceStr . delim
endif
@@ -2544,10 +2535,10 @@
let currentLine = a:topline
while currentLine <= a:bottomline
- " get the next line and see if it is commentable, otherwise it doesnt
- " count
- let theLine = getline(currentLine)
- if a:countEmptyLines || theLine !~ '^[ \t]*$'
+ " get the next line and see if it is commentable, otherwise it doesnt
+ " count
+ let theLine = getline(currentLine)
+ if a:countEmptyLines || theLine !~ '^[ \t]*$'
if a:countCommentedLines || (!s:IsCommented(b:left, b:right, theLine) && !s:IsCommented(b:leftAlt, b:rightAlt, theLine))
@@ -2558,12 +2549,12 @@
let rightMostIndx = lineLen
endif
endif
- endif
-
- " move on to the next line
- let currentLine = currentLine + 1
+ endif
+
+ " move on to the next line
+ let currentLine = currentLine + 1
endwhile
-
+
return rightMostIndx
endfunction
@@ -2582,13 +2573,11 @@
"
" Args:
" -space: specifies whether the marker is to have a space string after it
-" (the space string will only be added if NERD_space_delim_filetype_regexp
-" is specified for the current filetype)
+" (the space string will only be added if NERDSpaceDelims is set)
" -esc: specifies whether the tricky chars in the marker are to be ESCed
function s:GetSexyComMarker(space, esc)
let sexyComMarker = b:sexyComMarker
-
"if there is no hardcoded marker then we find one
if sexyComMarker == ''
@@ -2616,7 +2605,7 @@
endif
endif
- if a:space && &filetype =~ g:NERD_space_delim_filetype_regexp
+ if a:space && g:NERDSpaceDelims
let sexyComMarker = sexyComMarker . s:spaceStr
endif
@@ -2632,8 +2621,7 @@
" there is none. C style sexy comments are used if possible
" Args:
" -space: specifies if the delim has a space string on the end
-" (the space string will only be added if NERD_space_delim_filetype_regexp
-" is specified for the current filetype)
+" (the space string will only be added if NERDSpaceDelims is set)
" -esc: specifies whether the tricky chars in the string are ESCed
function s:GetSexyComLeft(space, esc)
let lenLeft = strlen(b:left)
@@ -2654,7 +2642,7 @@
endif
endif
- if a:space
+ if a:space && g:NERDSpaceDelims
let left = left . s:spaceStr
endif
@@ -2670,7 +2658,7 @@
" there is none. C style sexy comments are used if possible.
" Args:
" -space: specifies if the delim has a space string on the start
-" (the space string will only be added if NERD_space_delim_filetype_regexp
+" (the space string will only be added if NERDSpaceDelims
" is specified for the current filetype)
" -esc: specifies whether the tricky chars in the string are ESCed
function s:GetSexyComRight(space, esc)
@@ -2692,7 +2680,7 @@
endif
endif
- if a:space
+ if a:space && g:NERDSpaceDelims
let right = s:spaceStr . right
endif
@@ -2758,9 +2746,9 @@
function s:InstallDocumentation(full_name, revision)
" Name of the document path based on the system we use:
if has("vms")
- " No chance that this script will work with
- " VMS - to much pathname juggling here.
- return 1
+ " No chance that this script will work with
+ " VMS - to much pathname juggling here.
+ return 1
elseif (has("unix"))
" On UNIX like system, using forward slash:
let l:slash_char = '/'
@@ -2779,7 +2767,7 @@
let l:vim_plugin_path = fnamemodify(a:full_name, ':h')
let l:vim_doc_path = fnamemodify(a:full_name, ':h:h') . l:doc_path
if (!(filewritable(l:vim_doc_path) == 2))
- "Doc path: " . l:vim_doc_path
+ "Doc path: " . l:vim_doc_path
call s:NerdEcho("Doc path: " . l:vim_doc_path, 0)
execute l:mkdir_cmd . '"' . l:vim_doc_path . '"'
if (!(filewritable(l:vim_doc_path) == 2))
@@ -2789,8 +2777,7 @@
execute l:mkdir_cmd . '"' . l:vim_doc_path . '"'
if (!(filewritable(l:vim_doc_path) == 2))
" Put a warning:
- call s:NerdEcho("Unable to open documentation directory", 0)
- call s:NerdEcho(" type :help add-local-help for more informations.", 0)
+ call s:NerdEcho("Unable to open documentation directory \ntype :help add-local-help for more information.", 0)
echo l:vim_doc_path
return 0
endif
@@ -2824,7 +2811,7 @@
" Create a new buffer & read in the plugin file (me):
setl nomodeline
exe 'enew!'
- exe 'r ' . l:plugin_file
+ exe 'r ' . escape(l:plugin_file,s:NERDFileNameEscape)
setl modeline
let l:buf = bufnr("%")
@@ -2843,7 +2830,7 @@
/^=\{3,}\s\+END_DOC\C/,$ d
" Remove fold marks:
- norm :%s/{\{3}[1-9]/ /
+ :%s/{\{3}[1-9]/ /
" Add modeline for help doc: the modeline string is mangled intentionally
" to avoid it be recognized by VIM:
@@ -2855,12 +2842,12 @@
exe "normal :%s/#version#/ v" . a:revision . "/\<CR>"
" Save the help document:
- exe 'w! ' . l:doc_file
+ exe 'w! ' . escape(l:doc_file,s:NERDFileNameEscape)
exe l:go_back
exe 'bw ' . l:buf
" Build help tags:
- exe 'helptags ' . l:vim_doc_path
+ exe 'helptags ' . escape(l:vim_doc_path,s:NERDFileNameEscape)
return 1
endfunction
@@ -2877,12 +2864,12 @@
"if the line is commented normally return 1
if s:IsCommented(b:left, b:right, theLine) || s:IsCommented(b:leftAlt, b:rightAlt, theLine)
- return 1
+ return 1
endif
"if the line is part of a sexy comment return 1
if s:FindBoundingLinesOfSexyCom(a:lineNum) != -1
- return 1
+ return 1
endif
return 0
endfunction
@@ -2897,7 +2884,7 @@
function s:IsCommented(left, right, line)
"if the line isnt commented return true
if s:FindDelimiterIndex(a:left, a:line) != -1 && (s:FindDelimiterIndex(a:right, a:line) != -1 || a:right == "")
- return 1
+ return 1
endif
return 0
endfunction
@@ -2940,19 +2927,19 @@
"check if the line has a left delim before a leftAlt delim
if (indxLeft <= indxLeftAlt || indxLeftAlt == -1) && indxLeft != -1
- "check if the line has a right delim after any rightAlt delim
- if (indxRight > indxRightAlt && indxRight > indxLeft) || a:right == ''
- return 1
- endif
-
- "check if the line has a leftAlt delim before a left delim
+ "check if the line has a right delim after any rightAlt delim
+ if (indxRight > indxRightAlt && indxRight > indxLeft) || a:right == ''
+ return 1
+ endif
+
+ "check if the line has a leftAlt delim before a left delim
elseif (indxLeftAlt <= indxLeft || indxLeft == -1) && indxLeftAlt != -1
- "check if the line has a rightAlt delim after any right delim
- if (indxRightAlt > indxRight && indxRightAlt > indxLeftAlt) || a:rightAlt == ''
- return 2
- endif
+ "check if the line has a rightAlt delim after any right delim
+ if (indxRightAlt > indxRight && indxRightAlt > indxLeftAlt) || a:rightAlt == ''
+ return 2
+ endif
else
- return 0
+ return 0
endif
return 0
@@ -3003,15 +2990,15 @@
if s:IsEscaped(a:line, a:delIndx, "\\")
return 0
endif
-
+
"vim comments are so fuckin stupid!! Why the hell do they have comment
"delimiters that are used elsewhere in the syntax?!?! We need to check
"some conditions especially for vim
if &filetype == "vim"
- if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\"))
- return 0
- endif
-
+ if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\"))
+ return 0
+ endif
+
"if the delimiter is on the very first char of the line or is the
"first non-tab/space char on the line then it is a valid comment delimiter
if a:delIndx == 0 || a:line =~ "^[ \t]\\{" . a:delIndx . "\\}\".*$"
@@ -3023,7 +3010,7 @@
"if the quote is inside brackets then assume it isnt a comment
if numLeftParen > numRightParen
- return 0
+ return 0
endif
"if the line has an even num of unescaped "'s then we can assume that
@@ -3061,7 +3048,7 @@
"keep going back thru str until we either reach the start of the str or
"run out of esc chars
while curIndx >= 0 && strpart(a:str, curIndx, 1) == a:escChar
-
+
"we have found another esc char so add one to the count and move left
"one char
let numEscChars = numEscChars + 1
@@ -3086,47 +3073,47 @@
let left = ''
let right = ''
if b:right != ''
- let left = b:left
- let right = b:right
+ let left = b:left
+ let right = b:right
elseif b:rightAlt != ''
- let left = b:leftAlt
- let right = b:rightAlt
+ let left = b:leftAlt
+ let right = b:rightAlt
else
- return 0
+ return 0
endif
"swap the top and bottom line numbers around if need be
let topline = a:topline
let bottomline = a:bottomline
if bottomline < topline
- topline = bottomline
- bottomline = a:topline
+ topline = bottomline
+ bottomline = a:topline
endif
"if there is < 2 lines in the comment it cannot be sexy
if (bottomline - topline) <= 0
- return 0
+ return 0
endif
"if the top line doesnt begin with a left delim then the comment isnt sexy
if getline(a:topline) !~ '^[ \t]*' . left
- return 0
+ return 0
endif
"if there is a right delim on the top line then this isnt a sexy comment
if s:FindDelimiterIndex(right, getline(a:topline)) != -1
- return 0
- endif
-
+ return 0
+ endif
+
"if there is a left delim on the bottom line then this isnt a sexy comment
if s:FindDelimiterIndex(left, getline(a:bottomline)) != -1
- return 0
+ return 0
endif
"if the bottom line doesnt begin with a right delim then the comment isnt
"sexy
if getline(a:bottomline) !~ '^.*' . right . '$'
- return 0
+ return 0
endif
let sexyComMarker = s:GetSexyComMarker(0, 1)
@@ -3135,45 +3122,44 @@
"sexyComMarker
let currentLine = a:topline+1
while currentLine < a:bottomline
- let theLine = getline(currentLine)
-
- if theLine !~ '^[ \t]*' . sexyComMarker
+ let theLine = getline(currentLine)
+
+ if theLine !~ '^[ \t]*' . sexyComMarker
return 0
- endif
-
- "if there is a right delim in an intermediate line then the block isnt
- "a sexy comment
- if s:FindDelimiterIndex(right, theLine) != -1
+ endif
+
+ "if there is a right delim in an intermediate line then the block isnt
+ "a sexy comment
+ if s:FindDelimiterIndex(right, theLine) != -1
return 0
- endif
-
- let currentLine = currentLine + 1
+ endif
+
+ let currentLine = currentLine + 1
endwhile
"we have not found anything to suggest that this isnt a sexy comment so
- "return 1
return 1
endfunction
" Function: s:NerdEcho(msg, typeOfMsg) {{{2
-" Echos the given message in the given style iff the NERD_shut_up option is
+" Echos the given message in the given style iff the NERDShutUp option is
" not set
" Args:
" -msg: the message to echo
" -typeOfMsg: 0 = warning message
" 1 = normal message
function s:NerdEcho(msg, typeOfMsg)
- if g:NERD_shut_up
+ if g:NERDShutUp
return
endif
if a:typeOfMsg == 0
echohl WarningMsg
- echo a:msg
+ echo 'NERDCommenter:' . a:msg
echohl None
elseif a:typeOfMsg == 1
- echo a:msg
+ echo 'NERDCommenter:' . a:msg
endif
endfunction
@@ -3210,8 +3196,8 @@
"if there IS an occurrence of toReplace in str then replace it and return
"the resulting string
if indxToReplace != -1
- let line = strpart(a:str, 0, indxToReplace) . replacor . strpart(a:str, indxToReplace+strlen(toReplace))
- return line
+ let line = strpart(a:str, 0, indxToReplace) . replacor . strpart(a:str, indxToReplace+strlen(toReplace))
+ return line
endif
return a:str
@@ -3237,37 +3223,32 @@
"if there IS a delimiter in str, replace it and return the result
let line = a:str
if indxToReplace != -1
- let line = strpart(a:str, 0, indxToReplace) . replacor . strpart(a:str, indxToReplace+strlen(toReplace))
+ let line = strpart(a:str, 0, indxToReplace) . replacor . strpart(a:str, indxToReplace+strlen(toReplace))
endif
return line
endfunction
-" Function: s:RestoreCursorPosition() {{{2
-" Restores where the cursor is using the s and t registers. See also
-" RestoreCursorPostion(). Sets the s and t registers back to their original
-" values before SaveCursorPosition was called
-function s:RestoreCursorPostion()
- " see :h restore-position for details of how this works
- let @s=b:old_s_reg
- let @t=b:old_t_reg
- normal! `t
- normal! zt
- normal! `s
-
- "not sure how to save/restore the marks, so just del them
- delmarks s t
-endfunction
-" Function: s:SaveCursorPosition() {{{2
-" Saves where the cursor is using the s and t registers. See also
-" RestoreCursorPostion()
-function s:SaveCursorPosition()
- " see :h restore-position for details of how this works
- let b:old_s_reg=@s
- let b:old_t_reg=@t
- normal! ms
- normal! H
- normal! mt
- normal! ``
+"FUNCTION: s:RestoreScreenState() {{{2
+"
+"Sets the screen state back to what it was when s:SaveScreenState was last
+"called.
+"
+function s:RestoreScreenState()
+ if !exists("t:NERDComOldTopLine") || !exists("t:NERDComOldPos")
+ throw 'NERDCommenter exception: cannot restore screen'
+ endif
+
+ call cursor(t:NERDComOldTopLine, 0)
+ normal zt
+ call setpos(".", t:NERDComOldPos)
+endfunction
+
+"FUNCTION: s:SaveScreenState() {{{2
+"Saves the current cursor position in the current buffer and the window
+"scroll position
+function s:SaveScreenState()
+ let t:NERDComOldPos = getpos(".")
+ let t:NERDComOldTopLine = line("w0")
endfunction
" Function: s:SwapOutterMultiPartDelimsForPlaceHolders(line) {{{2
@@ -3287,12 +3268,12 @@
"if the line is commented and there is a right delimiter, replace
"the delims with place-holders
if isCommented && b:right != ""
- let line2 = s:ReplaceDelims(b:left, b:right, g:NERD_lPlace, g:NERD_rPlace, a:line)
-
+ let line2 = s:ReplaceDelims(b:left, b:right, g:NERDLPlace, g:NERDRPlace, a:line)
+
"similarly if the line is commented with the alternative
"delimiters
elseif isCommentedAlt && b:rightAlt != ""
- let line2 = s:ReplaceDelims(b:leftAlt, b:rightAlt, g:NERD_lPlace, g:NERD_rPlace, a:line)
+ let line2 = s:ReplaceDelims(b:leftAlt, b:rightAlt, g:NERDLPlace, g:NERDRPlace, a:line)
endif
return line2
@@ -3309,14 +3290,14 @@
let left = ''
let right = ''
if b:right != ''
- let left = b:left
- let right = b:right
+ let left = b:left
+ let right = b:right
elseif b:rightAlt != ''
- let left = b:leftAlt
- let right = b:rightAlt
- endif
-
- let line = s:ReplaceDelims(g:NERD_lPlace, g:NERD_rPlace, left, right, a:line)
+ let left = b:leftAlt
+ let right = b:rightAlt
+ endif
+
+ let line = s:ReplaceDelims(g:NERDLPlace, g:NERDRPlace, left, right, a:line)
return line
endfunction
" Function: s:UnEsc(str, escChar) {{{2
@@ -3334,131 +3315,136 @@
" mappings.
" set up the mapping to switch to/from alternative delimiters
-execute 'nnoremap <silent>' . g:NERD_alt_com_map . ' :call <SID>SwitchToAlternativeDelimiters(1)<cr>'
+execute 'nnoremap <silent>' . g:NERDAltComMap . ' :call <SID>SwitchToAlternativeDelimiters(1)<cr>'
" set up the mappings to comment out lines
-execute 'nnoremap <silent>' . g:NERD_com_line_map . ' :call <SID>DoComment(g:NERD_use_nested_comments_default, 0, 0, 0, "norm")<cr><ESC>'
-execute 'vnoremap <silent>' . g:NERD_com_line_map . ' :call <SID>DoComment(g:NERD_use_nested_comments_default, 1, &filetype =~ g:NERD_left_align_regexp, &filetype =~ g:NERD_right_align_regexp, "norm")<cr><ESC>'
+execute 'nnoremap <silent>' . g:NERDComLineMap . ' :call NERDComment(0, "norm")<cr>'
+execute 'vnoremap <silent>' . g:NERDComLineMap . ' <ESC>:call NERDComment(1, "norm")<cr>'
" set up the mappings to do toggle comments
-execute 'nnoremap <silent>' . g:NERD_com_line_toggle_map . ' :call <SID>DoComment(g:NERD_use_nested_comments_default, 0, &filetype =~ g:NERD_left_align_regexp, &filetype =~ g:NERD_right_align_regexp, "toggle")<cr><ESC>'
-execute 'vnoremap <silent>' . g:NERD_com_line_toggle_map . ' :call <SID>DoComment(g:NERD_use_nested_comments_default, 1, &filetype =~ g:NERD_left_align_regexp, &filetype =~ g:NERD_right_align_regexp, "toggle")<cr><ESC>'
+execute 'nnoremap <silent>' . g:NERDComLineToggleMap . ' :call NERDComment(0, "toggle")<cr>'
+execute 'vnoremap <silent>' . g:NERDComLineToggleMap . ' <ESC>:call NERDComment(1, "toggle")<cr>'
" set up the mapp to do minimal comments
-execute 'nnoremap <silent>' . g:NERD_com_line_minimal_map . ' :call <SID>DoComment(g:NERD_use_nested_comments_default, 0, &filetype =~ g:NERD_left_align_regexp, &filetype =~ g:NERD_right_align_regexp, "minimal")<cr><ESC>'
-execute 'vnoremap <silent>' . g:NERD_com_line_minimal_map . ' :call <SID>DoComment(g:NERD_use_nested_comments_default, 1, &filetype =~ g:NERD_left_align_regexp, &filetype =~ g:NERD_right_align_regexp, "minimal")<cr><ESC>'
+execute 'nnoremap <silent>' . g:NERDComLineMinimalMap . ' :call NERDComment(0, "minimal")<cr>'
+execute 'vnoremap <silent>' . g:NERDComLineMinimalMap . ' <ESC>:call NERDComment(1, "minimal")<cr>'
" set up the mappings to comment out lines sexily
-execute 'nnoremap <silent>' . g:NERD_com_line_sexy_map . ' :call <SID>DoComment(0, 0, 0, 0, "sexy")<CR>'
-execute 'vnoremap <silent>' . g:NERD_com_line_sexy_map . ' :call <SID>DoComment(0, 1, 0, 0, "sexy")<CR>'
+execute 'nnoremap <silent>' . g:NERDComLineSexyMap . ' :call NERDComment(0, "sexy")<CR>'
+execute 'vnoremap <silent>' . g:NERDComLineSexyMap . ' <ESC>:call NERDComment(1, "sexy")<CR>'
" set up the mappings to do invert comments
-execute 'nnoremap <silent>' . g:NERD_com_line_invert_map . ' :call <SID>DoComment(0, 0, 0, 0, "invert")<CR>'
-execute 'vnoremap <silent>' . g:NERD_com_line_invert_map . ' :call <SID>DoComment(0, 1, 0, 0, "invert")<CR>'
+execute 'nnoremap <silent>' . g:NERDComLineInvertMap . ' :call NERDComment(0, "invert")<CR>'
+execute 'vnoremap <silent>' . g:NERDComLineInvertMap . ' <ESC>:call NERDComment(1, "invert")<CR>'
" set up the mappings to yank then comment out lines
-execute 'nmap <silent>' . g:NERD_com_line_yank_map . ' "0Y' . g:NERD_com_line_map
-execute 'vmap <silent>' . g:NERD_com_line_yank_map . ' "0ygv' . g:NERD_com_line_map
+execute 'nmap <silent>' . g:NERDComLineYankMap . ' "0Y' . g:NERDComLineMap
+execute 'vmap <silent>' . g:NERDComLineYankMap . ' "0ygv' . g:NERDComLineMap
" set up the mappings for left aligned comments
-execute 'nnoremap <silent>' . g:NERD_com_align_left_map . ' :call <SID>DoComment(1, 0, 1, 0, "norm")<cr><ESC>'
-execute 'vnoremap <silent>' . g:NERD_com_align_left_map . ' :call <SID>DoComment(1, 1, 1, 0, "norm")<cr><ESC>'
+execute 'nnoremap <silent>' . g:NERDComAlignLeftMap . ' :call NERDComment(0, "alignLeft")<cr>'
+execute 'vnoremap <silent>' . g:NERDComAlignLeftMap . ' <ESC>:call NERDComment(1, "alignLeft")<cr>'
" set up the mappings for right aligned comments
-execute 'nnoremap <silent>' . g:NERD_com_align_right_map . ' :call <SID>DoComment(1, 0, 0, 1, "norm")<cr><ESC>'
-execute 'vnoremap <silent>' . g:NERD_com_align_right_map . ' :call <SID>DoComment(1, 1, 0, 1, "norm")<cr><ESC>'
+execute 'nnoremap <silent>' . g:NERDComAlignRightMap . ' :call NERDComment(0, "alignRight")<cr>'
+execute 'vnoremap <silent>' . g:NERDComAlignRightMap . ' <ESC>:call NERDComment(1, "alignRight")<cr>'
" set up the mappings for left and right aligned comments
-execute 'nnoremap <silent>' . g:NERD_com_align_both_map . ' :call <SID>DoComment(1, 0, 1, 1, "norm")<cr><ESC>'
-execute 'vnoremap <silent>' . g:NERD_com_align_both_map . ' :call <SID>DoComment(1, 1, 1, 1, "norm")<cr><ESC>'
+execute 'nnoremap <silent>' . g:NERDComAlignBothMap . ' :call NERDComment(0, "alignBoth")<cr>'
+execute 'vnoremap <silent>' . g:NERDComAlignBothMap . ' <ESC>:call NERDComment(1, "alignBoth")<cr>'
" set up the mappings to do nested comments
-execute 'nnoremap <silent>' . g:NERD_com_line_nest_map . ' :call <SID>DoComment(1, 0, 0, 0, "norm")<cr><ESC>'
-execute 'vnoremap <silent>' . g:NERD_com_line_nest_map . ' :call <SID>DoComment(1, 1, &filetype =~ g:NERD_left_align_regexp, &filetype =~ g:NERD_right_align_regexp, "norm")<cr><ESC>'
+execute 'nnoremap <silent>' . g:NERDComLineNestMap . ' :call NERDComment(0, "nested")<cr>'
+execute 'vnoremap <silent>' . g:NERDComLineNestMap . ' <ESC>:call NERDComment(1, "nested")<cr>'
" set up the mapping to uncomment a line
-execute 'nnoremap <silent>' . g:NERD_uncom_line_map . ' :call <SID>UncommentLines(0)<cr><ESC>'
-execute 'vnoremap <silent>' . g:NERD_uncom_line_map . ' :call <SID>UncommentLines(0)<cr> gv'
+execute 'nnoremap <silent>' . g:NERDUncomLineMap . ' :call NERDComment(0, "uncomment")<cr>'
+execute 'vnoremap <silent>' . g:NERDUncomLineMap . ' :call NERDComment(1, "uncomment")<cr>'
" set up the mapping to comment out to the end of the line
-execute 'nnoremap <silent>' . g:NERD_com_to_end_of_line_map . ' :call <SID>SaveCursorPosition()<cr>:call <SID>CommentBlock(line("."), line("."), col("."), col("$")-1, 1)<cr>:call <SID>RestoreCursorPostion()<cr><ESC>'
+execute 'nnoremap <silent>' . g:NERDComToEOLMap . ' :call NERDComment(0, "toEOL")<cr>'
" set up the mappings to append comments to the line
-execute 'nmap <silent>' . g:NERD_append_com_map . ' :call <SID>AppendCommentToLine()<cr>'
+execute 'nmap <silent>' . g:NERDAppendComMap . ' :call NERDComment(0, "append")<cr>'
" set up the mappings to append comments to the line
-execute 'nmap <silent>' . g:NERD_prepend_com_map . ' :call <SID>PrependCommentToLine()<cr>'
-
-" set up the mapping to insert comment delims at the cursor position in insert
-" mode
-execute 'inoremap <silent>' . g:NERD_com_in_insert_map . ' ' . '<SPACE><BS><ESC>:call <SID>PlaceDelimitersAndInsBetween()<CR>'
+execute 'nmap <silent>' . g:NERDPrependComMap . ' :call NERDComment(0, "prepend")<cr>'
+
+" set up the mapping to insert comment delims at the cursor position in insert mode
+execute 'inoremap <silent>' . g:NERDComInInsertMap . ' ' . '<SPACE><BS><ESC>:call NERDComment(0, "insert")<CR>'
" Section: Menu item setup {{{1
" ===========================================================================
"check if the user wants the menu to be displayed
-if g:NERD_menu_mode != 0
-
- "determine whether the user wants the menu to have a keyboard shortcut and
- "set the menu root accordingly.
- let s:menuRoot = g:NERD_menu_mode == 1 ? "comment" : "&comment"
-
- execute 'nmenu <silent> '. s:menuRoot .'.Comment<TAB>' . escape(g:NERD_com_line_map, '\') . ' :call <SID>DoComment(g:NERD_use_nested_comments_default, 0, &filetype =~ g:NERD_left_align_regexp, &filetype =~ g:NERD_right_align_regexp, "norm")<CR><ESC>'
- execute 'vmenu <silent> '. s:menuRoot .'.Comment<TAB>' . escape(g:NERD_com_line_map, '\') . ' :call <SID>DoComment(g:NERD_use_nested_comments_default, 1, &filetype =~ g:NERD_left_align_regexp, &filetype =~ g:NERD_right_align_regexp, "norm")<CR><ESC>'
-
- execute 'nmenu <silent> '. s:menuRoot .'.Comment\ Toggle<TAB>' . escape(g:NERD_com_line_toggle_map, '\') . ' :call <SID>DoComment(g:NERD_use_nested_comments_default, 0, &filetype =~ g:NERD_left_align_regexp, &filetype =~ g:NERD_right_align_regexp, "toggle")<CR><ESC>'
- execute 'vmenu <silent> '. s:menuRoot .'.Comment\ Toggle<TAB>' . escape(g:NERD_com_line_toggle_map, '\') . ' :call <SID>DoComment(g:NERD_use_nested_comments_default, 1, &filetype =~ g:NERD_left_align_regexp, &filetype =~ g:NERD_right_align_regexp, "toggle")<CR><ESC>'
-
- execute 'nmenu <silent> '. s:menuRoot .'.Comment\ Minimal<TAB>' . escape(g:NERD_com_line_minimal_map, '\') . ' :call <SID>DoComment(0, 0, 0, 0, "minimal")<CR><ESC>'
- execute 'vmenu <silent> '. s:menuRoot .'.Comment\ Minimal<TAB>' . escape(g:NERD_com_line_minimal_map, '\') . ' :call <SID>DoComment(0, 1, 0, 0, "minimal")<CR><ESC>'
-
- execute 'nmenu <silent> '. s:menuRoot .'.Comment\ Nested<TAB>' . escape(g:NERD_com_line_nest_map, '\') . ' :call <SID>DoComment(1, 0, &filetype =~ g:NERD_left_align_regexp, &filetype =~ g:NERD_right_align_regexp, "norm")<CR><ESC>'
- execute 'vmenu <silent> '. s:menuRoot .'.Comment\ Nested<TAB>' . escape(g:NERD_com_line_nest_map, '\') . ' :call <SID>DoComment(1, 1, &filetype =~ g:NERD_left_align_regexp, &filetype =~ g:NERD_right_align_regexp, "norm")<CR><ESC>'
-
- execute 'nmenu <silent> '. s:menuRoot .'.Comment\ To\ EOL<TAB>' . escape(g:NERD_com_to_end_of_line_map, '\') . ' :call <SID>SaveCursorPosition()<cr>:call <SID>CommentBlock(line("."), line("."), col("."), col("$")-1, 1)<cr>:call <SID>RestoreCursorPostion()<cr><ESC>'
-
- execute 'nmenu <silent> '. s:menuRoot .'.Comment\ Invert<TAB>' . escape(g:NERD_com_line_invert_map, '\') . ' :call <SID>DoComment(0,0,0,0,"invert")<CR>'
- execute 'vmenu <silent> '. s:menuRoot .'.Comment\ Invert<TAB>' . escape(g:NERD_com_line_invert_map, '\') . ' :call <SID>DoComment(0,1,0,0,"invert")<CR>'
-
- execute 'nmenu <silent> '. s:menuRoot .'.Comment\ Sexily<TAB>' . escape(g:NERD_com_line_sexy_map, '\') . ' :call <SID>DoComment(0,0,0,0,"sexy")<CR>'
- execute 'vmenu <silent> '. s:menuRoot .'.Comment\ Sexily<TAB>' . escape(g:NERD_com_line_sexy_map, '\') . ' :call <SID>DoComment(0,1,0,0,"sexy")<CR>'
-
- execute 'nmenu <silent> '. s:menuRoot .'.Yank\ line(s)\ then\ comment<TAB>' . escape(g:NERD_com_line_yank_map, '\') . ' "0Y' . g:NERD_com_line_map
- execute 'vmenu <silent> '. s:menuRoot .'.Yank\ line(s)\ then\ comment<TAB>' . escape(g:NERD_com_line_yank_map, '\') . ' "0ygv' . g:NERD_com_line_map
-
- execute 'nmenu <silent> '. s:menuRoot .'.Append\ Comment\ to\ Line<TAB>' . escape(g:NERD_append_com_map, '\') . ' :call <SID>AppendCommentToLine()<cr>'
- execute 'nmenu <silent> '. s:menuRoot .'.Prepend\ Comment\ to\ Line<TAB>' . escape(g:NERD_prepend_com_map, '\') . ' :call <SID>PrependCommentToLine()<cr>'
-
- execute 'menu <silent> '. s:menuRoot .'.-Sep- :'
-
- execute 'nmenu <silent> '. s:menuRoot .'.Comment\ Align\ Left\ (nested)<TAB>' . escape(g:NERD_com_align_left_map, '\') . ' :call <SID>DoComment(1, 0, 1, 0, "norm")<CR><ESC>'
- execute 'vmenu <silent> '. s:menuRoot .'.Comment\ Align\ Left\ (nested)<TAB>' . escape(g:NERD_com_align_left_map, '\') . ' :call <SID>DoComment(1, 1, 1, 0, "norm")<CR><ESC>'
-
- execute 'nmenu <silent> '. s:menuRoot .'.Comment\ Align\ Right\ (nested)<TAB>' . escape(g:NERD_com_align_right_map, '\') . ' :call <SID>DoComment(1, 0, 0, 1, "norm")<CR><ESC>'
- execute 'vmenu <silent> '. s:menuRoot .'.Comment\ Align\ Right\ (nested)<TAB>' . escape(g:NERD_com_align_right_map, '\') . ' :call <SID>DoComment(1, 1, 0, 1, "norm")<CR><ESC>'
-
- execute 'nmenu <silent> '. s:menuRoot .'.Comment\ Align\ Both\ (nested)<TAB>' . escape(g:NERD_com_align_both_map, '\') . ' :call <SID>DoComment(1, 0, 1, 1, "norm")<CR><ESC>'
- execute 'vmenu <silent> '. s:menuRoot .'.Comment\ Align\ Both\ (nested)<TAB>' . escape(g:NERD_com_align_both_map, '\') . ' :call <SID>DoComment(1, 1, 1, 1, "norm")<CR><ESC>'
-
- execute 'menu <silent> '. s:menuRoot .'.-Sep2- :'
-
- execute 'menu <silent> '. s:menuRoot .'.Uncomment<TAB>' . escape(g:NERD_uncom_line_map, '\') . ' :call <SID>UncommentLines(0)<CR>gv'
-
- execute 'menu <silent> '. s:menuRoot .'.-Sep3- :'
-
- execute 'nmenu <silent> '. s:menuRoot .'.Use\ Alternative\ Delimiters<TAB>' . escape(g:NERD_alt_com_map, '\') . ' :call <SID>SwitchToAlternativeDelimiters(1)<CR>'
-
-
- execute 'imenu <silent> '. s:menuRoot .'.Insert\ Delims<TAB>' . escape(g:NERD_com_in_insert_map, '\') . ' <SPACE><BS><ESC>:call <SID>PlaceDelimitersAndInsBetween()<CR>'
-
- execute 'menu '. s:menuRoot .'.-Sep4- :'
-
- execute 'menu <silent>'. s:menuRoot .'.Help<TAB>:help\ NERD_comments-contents :help NERD_comments-contents<CR>'
+if g:NERDMenuMode != 0
+
+ let menuRoot = ""
+ if g:NERDMenuMode == 1
+ let menuRoot = 'comment'
+ elseif g:NERDMenuMode == 2
+ let menuRoot = '&comment'
+ elseif g:NERDMenuMode == 3
+ let menuRoot = '&Plugin.&comment'
+ endif
+
+ execute 'nmenu <silent> '. menuRoot .'.Comment<TAB>' . escape(g:NERDComLineMap, '\') . ' :call NERDComment(0, "norm")<CR>'
+ execute 'vmenu <silent> '. menuRoot .'.Comment<TAB>' . escape(g:NERDComLineMap, '\') . ' <ESC>:call NERDComment(1, "norm")<CR>'
+
+ execute 'nmenu <silent> '. menuRoot .'.Comment\ Toggle<TAB>' . escape(g:NERDComLineToggleMap, '\') . ' :call NERDComment(0, "toggle")<CR>'
+ execute 'vmenu <silent> '. menuRoot .'.Comment\ Toggle<TAB>' . escape(g:NERDComLineToggleMap, '\') . ' <ESC>:call NERDComment(1, "toggle")<CR>'
+
+ execute 'nmenu <silent> '. menuRoot .'.Comment\ Minimal<TAB>' . escape(g:NERDComLineMinimalMap, '\') . ' :call NERDComment(0, "minimal")<CR>'
+ execute 'vmenu <silent> '. menuRoot .'.Comment\ Minimal<TAB>' . escape(g:NERDComLineMinimalMap, '\') . ' <ESC>:call NERDComment(1, "minimal")<CR>'
+
+ execute 'nmenu <silent> '. menuRoot .'.Comment\ Nested<TAB>' . escape(g:NERDComLineNestMap, '\') . ' :call NERDComment(0, "nested")<CR>'
+ execute 'vmenu <silent> '. menuRoot .'.Comment\ Nested<TAB>' . escape(g:NERDComLineNestMap, '\') . ' <ESC>:call NERDComment(1, "nested")<CR>'
+
+ execute 'nmenu <silent> '. menuRoot .'.Comment\ To\ EOL<TAB>' . escape(g:NERDComToEOLMap, '\') . ' :call NERDComment(0, "toEOL")<cr>'
+
+ execute 'nmenu <silent> '. menuRoot .'.Comment\ Invert<TAB>' . escape(g:NERDComLineInvertMap, '\') . ' :call NERDComment(0,"invert")<CR>'
+ execute 'vmenu <silent> '. menuRoot .'.Comment\ Invert<TAB>' . escape(g:NERDComLineInvertMap, '\') . ' <ESC>:call NERDComment(1,"invert")<CR>'
+
+ execute 'nmenu <silent> '. menuRoot .'.Comment\ Sexily<TAB>' . escape(g:NERDComLineSexyMap, '\') . ' :call NERDComment(0,"sexy")<CR>'
+ execute 'vmenu <silent> '. menuRoot .'.Comment\ Sexily<TAB>' . escape(g:NERDComLineSexyMap, '\') . ' <ESC>:call NERDComment(1,"sexy")<CR>'
+
+ execute 'nmenu <silent> '. menuRoot .'.Yank\ line(s)\ then\ comment<TAB>' . escape(g:NERDComLineYankMap, '\') . ' "0Y' . g:NERDComLineMap
+ execute 'vmenu <silent> '. menuRoot .'.Yank\ line(s)\ then\ comment<TAB>' . escape(g:NERDComLineYankMap, '\') . ' "0ygv' . g:NERDComLineMap
+
+ execute 'nmenu <silent> '. menuRoot .'.Append\ Comment\ to\ Line<TAB>' . escape(g:NERDAppendComMap, '\') . ' :call NERDComment(0, "append")<cr>'
+ execute 'nmenu <silent> '. menuRoot .'.Prepend\ Comment\ to\ Line<TAB>' . escape(g:NERDPrependComMap, '\') . ' :call NERDComment(0, "prepend")<cr>'
+
+ execute 'menu <silent> '. menuRoot .'.-Sep- :'
+
+ execute 'nmenu <silent> '. menuRoot .'.Comment\ Align\ Left\ (nested)<TAB>' . escape(g:NERDComAlignLeftMap, '\') . ' :call NERDComment(0, "alignLeft")<CR>'
+ execute 'vmenu <silent> '. menuRoot .'.Comment\ Align\ Left\ (nested)<TAB>' . escape(g:NERDComAlignLeftMap, '\') . ' <ESC>:call NERDComment(1, "alignLeft")<CR>'
+
+ execute 'nmenu <silent> '. menuRoot .'.Comment\ Align\ Right\ (nested)<TAB>' . escape(g:NERDComAlignRightMap, '\') . ' :call NERDComment(0, "alignRight")<CR>'
+ execute 'vmenu <silent> '. menuRoot .'.Comment\ Align\ Right\ (nested)<TAB>' . escape(g:NERDComAlignRightMap, '\') . ' <ESC>:call NERDComment(1, "alignRight")<CR>'
+
+ execute 'nmenu <silent> '. menuRoot .'.Comment\ Align\ Both\ (nested)<TAB>' . escape(g:NERDComAlignBothMap, '\') . ' :call NERDComment(0, "alignBoth")<CR>'
+ execute 'vmenu <silent> '. menuRoot .'.Comment\ Align\ Both\ (nested)<TAB>' . escape(g:NERDComAlignBothMap, '\') . ' <ESC>:call NERDComment(1, "alignBoth")<CR>'
+
+ execute 'menu <silent> '. menuRoot .'.-Sep2- :'
+
+ execute 'menu <silent> '. menuRoot .'.Uncomment<TAB>' . escape(g:NERDUncomLineMap, '\') . ' :call NERDComment(0, "uncomment")<cr>'
+ execute 'vmenu <silent>' . menuRoot.'.Uncomment<TAB>' . escape(g:NERDUncomLineMap, '\') . ' <esc>:call NERDComment(1, "uncomment")<cr>'
+
+ execute 'menu <silent> '. menuRoot .'.-Sep3- :'
+
+ execute 'nmenu <silent> '. menuRoot .'.Use\ Alternative\ Delimiters<TAB>' . escape(g:NERDAltComMap, '\') . ' :call <SID>SwitchToAlternativeDelimiters(1)<CR>'
+
+
+ execute 'imenu <silent> '. menuRoot .'.Insert\ Delims<TAB>' . escape(g:NERDComInInsertMap, '\') . ' <SPACE><BS><ESC>:call NERDComment(0, "insert")<CR>'
+
+ execute 'menu '. menuRoot .'.-Sep4- :'
+
+ execute 'menu <silent>'. menuRoot .'.Help<TAB>:help\ NERD_commenter-contents :help NERD_commenter-contents<CR>'
endif
" Section: Doc installation call {{{1
-silent call s:InstallDocumentation(expand('<sfile>:p'), s:NERD_comments_version)
+silent call s:InstallDocumentation(expand('<sfile>:p'), s:NERD_commenter_version)
finish
"=============================================================================
@@ -3466,19 +3452,19 @@
" Title {{{2
" ============================================================================
=== START_DOC
-*NERD_comments.txt* Plugin for commenting code #version#
-
-
- NERD_COMMENTS REFERENCE MANUAL~
+*NERD_commenter.txt* Plugin for commenting code #version#
+
+
+ NERD COMMENTER REFERENCE MANUAL~
==============================================================================
-CONTENTS {{{2 *NERD_comments-contents*
-
- 1.Intro...................................|NERD_comments|
+CONTENTS {{{2 *NERD_commenter-contents*
+
+ 1.Intro...................................|NERD_commenter|
2.Functionality provided..................|NERD_com-functionality|
2.1 Functionality Summary.............|NERD_com-functionality-summary|
2.2 Functionality Details.............|NERD_com-functionality-details|
@@ -3498,33 +3484,28 @@
2.2.14 Uncomment line map.........|NERD_com-uncomment-line|
2.3 Supported filetypes...............|NERD_com-filetypes|
2.4 Sexy Comments.....................|NERD_com_sexy_comments|
+ 2.5 The NERDComment function..........|NERD_com_NERDComment|
3.Customisation...........................|NERD_com-customisation|
3.1 Customisation summary.............|NERD_com-cust-summary|
3.2 Customisation details.............|NERD_com-cust-details|
3.3 Default delimiter customisation...|NERD_com-cust-delims|
3.4 Key mapping customisation.........|NERD_com-cust-keys|
- 3.5 Sample regular expressions........|NERD_com-reg-exps|
4.Issues with the script..................|NERD_com-issues|
4.1 Delimiter detection heuristics....|NERD_com-heuristics|
4.2 Nesting issues....................|NERD_com-nesting|
- 4.3 Nesting issues....................|NERD_com-nesting|
- 4.3 Mark clobbering...................|NERD_com-mark-clobbering|
5.TODO list...............................|NERD_com-todo|
- 6.Credits.................................|NERD_com-credits|
+ 6.Changelog...............................|NERD_com-changelog|
+ 7.Credits.................................|NERD_com-credits|
==============================================================================
-1. Intro {{{2 *NERD_comments*
-
-NERD_comments provides a set of handy key mappings for commenting code. These
-mappings are consistent across all supported filetypes.
-
-When writing NERD_comments I have tried to give it as many features/options as
-possible while keeping it so that the plugin can still be used with little or
-no knowledge of these. The average user need only know about a few key
-mappings to use NERD_comments while there are plenty of other features for the
-l33t nerd take advantage of.
-
-Enjoy :D
+1. Intro {{{2 *NERD_commenter*
+
+The NERD commenter provides many different commenting operations and styles
+which may be invoked via key mappings and a commenting menu. These operations
+are available for most filetypes.
+
+There are also options available that allow you to tweak the commenting engine
+to you taste.
==============================================================================
2. Functionality provided {{{2 *NERD_com-functionality*
@@ -3546,7 +3527,7 @@
<leader>cn |NERD_com-nested-comment|
-Same as |NERD_com-comment-map| but enforces nesting.
+Same as |NERD_com-comment-map| but forces nesting.
<leader>c<space> |NERD_com-toggle-comment|
@@ -3608,75 +3589,49 @@
2.2 Functionality details {{{3 *NERD_com-functionality-details*
------------------------------------------------------------------------------
-2.2.1 Comment map *NERD_com-comment*
+2.2.1 Comment map *NERD_com-comment*
<leader>cc
Comments out the current line. If multiple lines are selected in visual-line
mode, they are all commented out. If some text is selected in visual or
-visual-block mode then NERD_comments will try to comment out the exact text
-that is selected using multi-part delimiters if they are available.
+visual-block mode then the script will try to comment out the exact text that
+is selected using multi-part delimiters if they are available.
Works in normal, visual, visual-line and visual-block mode.
-Change the mapping with: |NERD_com_line_map|.
-
-Relevant options:
-|NERD_allow_any_visual_delims_regexp|
-|NERD_comment_whole_lines_in_v_mode|
-|NERD_block_com_after_right|
-|NERD_left_align_regexp|
-|NERD_place_holder_regexp|
-|NERD_right_align_regexp|
-|NERD_space_delim_filetype_regexp|
-|NERD_use_nested_comments_default|
+Change the mapping with: |NERDComLineMap|.
------------------------------------------------------------------------------
-2.2.2 Nested comment map *NERD_com-nested-comment*
+2.2.2 Nested comment map *NERD_com-nested-comment*
<leader>cn
Performs nested commenting. Works the same as <leader>cc except that if a
line is already commented then it will be commented again.
-If the filetype is covered by the |NERD_place_holder_regexp| option
-then the previous comment delimiters will be replaced by place-holder
-delimiters if needed. Otherwise the nested comment will only be added if the
-current commenting delimiters have no right delimiter (to avoid compiler
-errors)
+If |NERDUsePlaceHolders| is set then the previous comment delimiters will
+be replaced by place-holder delimiters if needed. Otherwise the nested
+comment will only be added if the current commenting delimiters have no right
+delimiter (to avoid syntax errors)
Works in normal, visual, visual-line, visual-block modes.
-Change the mapping with: |NERD_com_line_nest_map|.
-
-Relevant options:
-|NERD_allow_any_visual_delims_regexp|
-|NERD_comment_whole_lines_in_v_mode|
-|NERD_block_com_after_right|
-|NERD_left_align_regexp|
-|NERD_place_holder_regexp|
-|NERD_right_align_regexp|
-|NERD_space_delim_filetype_regexp|
-|NERD_use_nested_comments_default|
+Change the mapping with: |NERDComLineNestMap|.
+
+Related options:
+|NERDDefaultNesting|
------------------------------------------------------------------------------
-2.2.3 Toggle comment map *NERD_com-toggle-comment*
+2.2.3 Toggle comment map *NERD_com-toggle-comment*
<leader>c<space>
Toggles commenting of the lines selected. The behaviour of this mapping
depends on whether the first line selected is commented or not. If so, all
selected lines are uncommented and vice versa.
-With this mapping, lines are only considered to be commented if a left comment
-delimiter is the first non-space/tab char on the line.
+With this mapping, a line is only considered to be commented if it starts with
+a left delimiter.
Works in normal, visual-line, modes.
-Using this mapping in visual or visual-block modes will cause it to work like
-|NERD_com-comment|
-
-Change the mapping with: |NERD_com_line_toggle_map|.
-
-Relevant options:
-|NERD_left_align_regexp|
-|NERD_right_align_regexp|
-|NERD_space_delim_filetype_regexp|
-|NERD_use_nested_comments_default|
+
+Change the mapping with: |NERDComLineToggleMap|.
------------------------------------------------------------------------------
2.2.4 Minimal comment map *NERD_com-minimal-comment*
@@ -3688,30 +3643,29 @@
will be placed at the end of the last line.
Sets of multipart comment delimiters that are between the top and bottom
-selected lines are replaced with place holders (see |NERD_lPlace|) if
-NERD_place_holder_regexp is set for the current filetype. If it is not, then
+selected lines are replaced with place holders (see |NERDLPlace|) if
+|NERDUsePlaceHolders| is set for the current filetype. If it is not, then
the comment will be aborted if place holders are required to prevent illegal
syntax.
+Change the mapping with: |NERDComLineMinimalMap|
+
------------------------------------------------------------------------------
-2.2.5 Invert comment map *NERD_com-invert-comment*
+2.2.5 Invert comment map *NERD_com-invert-comment*
<leader>ci
Inverts the commented state of each selected line. If the a selected line is
commented then it is uncommented and vice versa. Each line is examined and
commented/uncommented individually.
-With this mapping, lines are only considered to be commented if a left comment
-delimiter is the first non-space/tab char on the line.
+With this mapping, a line is only considered to be commented if it starts with
+a left delimiter.
Works in normal, visual-line, modes.
-Change the mapping with: |NERD_com_line_invert_map|.
-
-Relevant options:
-
+Change the mapping with: |NERDComLineInvertMap|.
------------------------------------------------------------------------------
-2.2.6 Sexy comment map *NERD_com-sexy-comment*
+2.2.6 Sexy comment map *NERD_com-sexy-comment*
<leader>cs
Comments the selected line(s) ``sexily''... see |NERD_com_sexy_commenting| for
a description of what sexy comments are. Can only be done on filetypes for
@@ -3722,92 +3676,75 @@
Works in normal, visual-line.
-Change the mapping with: |NERD_com_line_sexy_map|
-
-Relevant options:
-|NERD_use_compact_sexy_com_regexp|
+Change the mapping with: |NERDComLineSexyMap|
+
+Related options:
+|NERDCompactSexyComs|
------------------------------------------------------------------------------
-2.2.7 Yank comment map *NERD_com-yank-comment*
+2.2.7 Yank comment map *NERD_com-yank-comment*
<leader>cy
Same as <leader>cc except that it yanks the line(s) that are commented first.
Works in normal, visual, visual-line, visual-block modes.
-Change the mapping with: |NERD_com_line_yank_map|
-
-Relevant options:
-
+Change the mapping with: |NERDComLineYankMap|
------------------------------------------------------------------------------
-2.2.8 Comment to EOL map *NERD_com-EOL-comment*
+2.2.8 Comment to EOL map *NERD_com-EOL-comment*
<leader>c$
Comments the current line from the current cursor position up to the end of
the line.
Works in normal mode.
-Change the mapping with: |NERD_com_to_end_of_line_map|
-
-Relevant options:
-
+Change the mapping with: |NERDComToEOLMap|
------------------------------------------------------------------------------
-2.2.9 Append com to line map *NERD_com-append-comment*
+2.2.9 Append com to line map *NERD_com-append-comment*
<leader>cA
Appends comment delimiters to the end of the current line and goes
to insert mode between the new delimiters.
Works in normal mode.
-Change the mapping with: |NERD_append_com_map|.
-
-Relevant options:
-
+Change the mapping with: |NERDAppendComMap|.
------------------------------------------------------------------------------
-2.2.10 Prepend com to line map *NERD_com-prepend-comment*
+2.2.10 Prepend com to line map *NERD_com-prepend-comment*
<leader>cI
Prepends comment delimiters to the start of the current line and goes to
insert mode between the new delimiters.
Works in normal mode.
-Change the mapping with: |NERD_prepend_com_map|.
-
-Relevant options:
-
+Change the mapping with: |NERDPrependComMap|.
------------------------------------------------------------------------------
-2.2.11 Insert comment map *NERD_com-insert-comment*
+2.2.11 Insert comment map *NERD_com-insert-comment*
<C-c>
Adds comment delimiters at the current cursor position and inserts
between them.
Works in insert mode.
-Change the mapping with: |NERD_com_in_insert_map|.
-
-Relevant options:
-
+Change the mapping with: |NERDComInInsertMap|.
------------------------------------------------------------------------------
-2.2.12 Use alternate delims map *NERD_com-alt-delim*
+2.2.12 Use alternate delims map *NERD_com-alt-delim*
<leader>ca
Changes to the alternative commenting style if one is available. For example,
if the user is editing a c++ file using // comments and they hit <leader>ca
then they will be switched over to /**/ comments.
-keys for this mappings can be overridden with the
Works in normal mode.
-Change the mapping with: |NERD_alt_com_map|
-
-Relevant options:
-
+Change the mapping with: |NERDAltComMap|
+
+See also |NERD_com-cust-delims|
------------------------------------------------------------------------------
-2.2.13 Comment aligned maps *NERD_com-aligned-comment*
+2.2.13 Comment aligned maps *NERD_com-aligned-comment*
<leader>cl <leader>cr <leader>cb
Same as <leader>cc except that the comment delimiters are aligned on the left
side, right side or both sides respectively. These comments are always nested
@@ -3815,16 +3752,11 @@
Works in normal, visual-line.
-Change the mappings with: |NERD_com_align_left_map|, |NERD_com_align_right_map|
-and |NERD_com_align_both_map|.
-
-Relevant options:
-|NERD_left_align_regexp|
-|NERD_right_align_regexp|
-
+Change the mappings with: |NERDComAlignLeftMap|, |NERDComAlignRightMap|
+and |NERDComAlignBothMap|.
------------------------------------------------------------------------------
-2.2.14 Uncomment line map *NERD_com-uncomment-line*
+2.2.14 Uncomment line map *NERD_com-uncomment-line*
<leader>cu
Uncomments the current line. If multiple lines are selected in
visual mode then they are all uncommented.
@@ -3837,45 +3769,47 @@
Works in normal, visual, visual-line, visual-block.
-Change the mapping with: |NERD_uncom_line_map|.
-
-Relevant options:
-|NERD_dont_remove_alt_coms|
-|NERD_dont_remove_spaces_regexp|
+Change the mapping with: |NERDUncomLineMap|.
+
+Related options:
+|NERDRemoveAltComs|
+|NERDRemoveExtraSpaces|
------------------------------------------------------------------------------
-2.3 Supported filetypes *NERD_com-filetypes*
-
-Files that can be commented by this plugin:
-abaqus abc acedb ada ahdl amiga aml ampl ant apache apachestyle asm68k asm asm
-asn aspvbs atlas automake ave awk basic b bc bdf bib bindzone btm caos catalog
-c cfg cg ch cl clean clipper conf config cpp crontab cs csc csp css cterm cupl
-cvs dcl def diff dns dosbatch dosini dot dracula dsl dtd dtml dylan ecd eiffel
-elf elmfilt erlang eruby eterm expect exports fgl focexec form fortran foxpro
-fvwm fx gdb gdmo gnuplot gtkrc haskell hb h help hercules hog html htmlos ia64
-icon idlang idl indent inform inittab ishd iss ist jam java javascript jess
-jgraph jproperties jproperties jsp kix kscript lace lex lftp lifelines lilo
-lisp lite lotos lout lprolog lscript lss lua lynx m4 make maple masm master
-matlab mel mf mib mma model moduala. modula2 modula3 monk mush muttrc named
-nasm nastran natural ncf netrw nqc nsis ocaml omnimark openroad opl ora ox
-pascal pcap pccts perl pfmain php phtml pic pike pilrc pine plm plsql po
-postscr pov povini ppd ppwiz procmail progress prolog psf ptcap python python
-radiance ratpoison r rc readline rebol registry remind rexx robots rpl ruby sa
-samba sas sather scheme scilab screen scsh sdl sed sgml sgmldecl sgmllnx sicad
-simula sinda skill slang sl slrnrc sm smil smith sml snnsnet snnspat snnsres
-snobol4 spec specman spice sql sqlforms sqlj sqr squid st stp strace svn tads
-taglist tags tak tasm tcl terminfo tex texinfo texmf tf tidy tli trasys tsalt
-tsscl tssgm uc uil vb verilog vgrindefs vhdl vim virata vrml vsejcl webmacro
-wget winbatch wml sh wvdial xdefaults xf86conf xhtml xkb xmath xml xmodmap
-xpm2 xpm xslt yacc yaml z8a
+2.3 Supported filetypes {{{3 *NERD_com-filetypes*
+
+Filetypes that can be commented by this plugin:
+abaqus abc acedb ada ahdl amiga aml ampl ant apache apachestyle asm68k asm asn
+aspvbs atlas automake ave awk basic b bc bdf bib bindzone bst btm caos catalog
+c cfg cg ch cl clean clipper conf config context cpp crontab cs csc csp css
+cterm cupl cvs dcl debsources def diff dns dosbatch dosini dot dracula dsl dtd
+dtml dylan ecd eiffel elf elmfilt erlang eruby eterm expect exports fetchmail
+fgl focexec form fortran foxpro fvwm fx gdb gdmo geek gentoo-package-keywords
+gentoo-package-mask gentoo-package-use gnuplot gtkrc haskell hb h help
+hercules hog html htmlos ia64 icon idlang idl indent inform inittab ishd iss
+ist jam java javascript jess jgraph jproperties jproperties jsp kconfig kix
+kscript lace lex lftp lifelines lilo lisp lite lotos lout lprolog lscript lss
+lua lynx m4 mail make maple masm master matlab mel mf mib mma model moduala.
+modula2 modula3 monk mush muttrc named nasm nastran natural ncf netdict netrw
+nqc nsis ocaml occam omlet omnimark openroad opl ora ox pascal passwd pcap
+pccts perl pfmain php phtml pic pike pilrc pine plaintex plm plsql po postscr
+pov povini ppd ppwiz procmail progress prolog psf ptcap python python qf
+radiance ratpoison r rc readline rebol registry remind rexx robots rpl rtf
+ruby sa samba sas sather scheme scilab screen scsh sdl sed selectbuf sgml
+sgmldecl sgmllnx sicad simula sinda skill slang sl slrnrc sm smil smith sml
+snnsnet snnspat snnsres snobol4 spec specman spice sql sqlforms sqlj sqr squid
+st stp strace svn tads taglist tags tak tasm tcl terminfo tex plaintex texinfo
+texmf tf tidy tli trasys tsalt tsscl tssgm uc uil vb verilog vgrindefs vhdl
+vim viminfo virata vrml vsejcl webmacro wget winbatch wml [^w]*sh wvdial
+xdefaults xf86conf xhtml xkb xmath xml xmodmap xpm2 xpm xslt yacc yaml z8a
If a language is not in the list of hardcoded supported filetypes then the
&commentstring vim option is used.
------------------------------------------------------------------------------
-2.4 Sexy Comments *NERD_com_sexy_comments*
+2.4 Sexy Comments {{{3 *NERD_com_sexy_comments*
These are comments that use one set of multipart comment delimiters as well as
one other marker symbol. For example: >
/*
@@ -3887,9 +3821,33 @@
* So there!
* But this one is ``compact'' style */
<
-Here the multipart delimiters are /* and */ and the marker is *. NERD_comments
-is capable of adding and removing comments of this type.
-
+Here the multipart delimiters are /* and */ and the marker is *. The NERD
+commenter is capable of adding and removing comments of this type.
+
+
+------------------------------------------------------------------------------
+2.5 The NERDComment function {{{3 *NERD_com_NERDComment*
+
+All of the NERD commenter mappings and menu items invoke a single function
+which delegates the commenting work to other functions. This function is
+public and has the prototype: >
+ function! NERDComment(isVisual, type)
+<
+The arguments to this function are simple:
+ - isVisual: if you wish to do any kind of visual comment then set this to
+ 1 and the function will use the '< and '> marks to find the comment
+ boundries. If set to 0 then the function will operate on the current
+ line.
+ - type: is used to specify what type of commenting operation is to be
+ performed, and it can be one of the following: 'sexy', 'invert',
+ 'minimal', 'toggle', 'alignLeft', 'alignRight', 'alignBoth', 'norm',
+ 'nested', 'toEOL', 'prepend', 'append', 'insert', 'uncomment'
+
+For example, if you typed >
+ :call NERDComment(1, 'sexy')
+<
+then the script would do a sexy comment on the last visual selection.
+
==============================================================================
3. Customisation {{{2 *NERD_com-customisation*
@@ -3898,45 +3856,43 @@
3.1 Customisation summary *NERD_com-cust-summary*
|loaded_nerd_comments| Turns off the script.
-|NERD_allow_any_visual_delims_regexp| Allows multipart alternative delims to
- be used when commenting in
+|NERDAllowAnyVisualDelims| Allows multipart alternative delims to
+ be used when commenting in
visual/visual-block mode.
-|NERD_block_com_after_right| Forces right delims to be placed when
+|NERDBlockComIgnoreEmpty| Forces right delims to be placed when
doing visual-block comments.
-|NERD_comment_whole_lines_in_v_mode| Changes behaviour of visual comments.
-|NERD_menu_mode| Determines if a NERD comment menu will
- be made and whether the menu will have a
- keyboard shortcut.
-|NERD_dont_remove_alt_coms| Causes alternative comments not to be
- removed when uncommenting.
-|NERD_dont_remove_spaces_regexp| Causes spaces not to be removed when
- uncommenting if the filetype doesnt
- match |NERD_space_delim_filetype_regexp|
-|NERD_create_h_filetype| Creates a new filetype for .h files.
-|NERD_lPlace| Specifies what to use as the left
+|NERDCommentWholeLinesInVMode| Changes behaviour of visual comments.
+|NERDDefaultNesting| Tells the script to use nested comments
+ by default.
+|NERDMenuMode| Specifies how the NERD commenter menu
+ will appear (if at all).
+|NERDLPlace| Specifies what to use as the left
delimiter placeholder when nesting
comments.
-|NERD_left_align_regexp| Specifies which filetypes to align left
- delimiters for.
-|NERD_mapleader| Specifies what all the commenting key
+|NERDMapleader| Specifies what all the commenting key
mappings will begin with.
-|NERD_place_holder_regexp| Specifies which filetypes may use
+|NERDUsePlaceHolders| Specifies which filetypes may use
placeholders when nesting comments.
-|NERD_right_align_regexp| Specifies which filetypes to align right
- delimiters for.
-|NERD_rPlace| Specifies what to use as the right
+|NERDRemoveAltComs| Tells the script whether to remove
+ alternative comment delimiters when
+ uncommenting.
+|NERDRemoveExtraSpaces| Tells the script to always remove the
+ extra spaces when uncommenting
+ (regardless of whether NERDSpaceDelims
+ is set)
+|NERDRPlace| Specifies what to use as the right
delimiter placeholder when nesting
comments.
-|NERD_shut_up| Stops all output from the script.
-|NERD_space_delim_filetype_regexp| Specifies which filetypes to add spaces
- around the delimiters for.
-|NERD_use_compact_sexy_com_regexp| Specifies which filetypes to use compact
- sexy comments for.
-|NERD_use_nested_comments_default| Tells the script to use nested comments
- by default.
-
------------------------------------------------------------------------------
-3.3 Customisation details *NERD_com-cust-details*
+|NERDShutUp| Stops all output from the script.
+|NERDSpaceDelims| Specifies whether to add extra spaces
+ around delimiters when commenting, and
+ whether to remove them when
+ uncommenting.
+|NERDCompactSexyComs| Specifies whether to use the compact
+ style sexy comments.
+
+------------------------------------------------------------------------------
+3.3 Customisation details *NERD_com-cust-details*
To enable any of the below options you should put the given line in your
~/.vimrc
@@ -3947,37 +3903,40 @@
let loaded_nerd_comments=1
<
------------------------------------------------------------------------------
- *NERD_allow_any_visual_delims_regexp*
-This option is set to a regular expression that is used to specify which
-filetypes this option should be turned on for. If this covers the current
-filetype then, when NERD_comments is doing a visual or visual-block comment
-(but not a visual-line comment) it will choose the right delimiters to use for
-the comment. This normally means using the current delimiters if they are
-multipart or using the alternative delimiters if THEY are multipart and the
-current delims are not. For example if we are editing the following java
-code: >
+------------------------------------------------------------------------------
+ *NERDAllowAnyVisualDelims*
+Values: 0 or 1.
+Default: 1.
+
+If set to 1 then, when doing a visual or visual-block comment (but not a
+visual-line comment), the script will choose the right delimiters to use for
+the comment. This means either using the current delimiters if they are
+multipart or using the alternative delimiters if THEY are multipart. For
+example if we are editing the following java code: >
float foo = 1221;
float bar = 324;
System.out.println(foo * bar);
<
If we are using // comments and select the "foo" and "bar" in visual-block
-mode, as shown left below (where '|'s are used to represent the visual-block
-boundary), and comment it then it will use the alternative delims as shown on
-the right: >
+mode, as shown left below (where '|'s are used to represent the visual-block
+boundary), and comment it then the script will use the alternative delims as
+shown on the right: >
+
float |foo| = 1221; float /*foo*/ = 1221;
float |bar| = 324; float /*bar*/ = 324;
System.out.println(foo * bar); System.out.println(foo * bar);
<
-By default this option is set to '.*' i.e is turned on for all filetypes.
-
------------------------------------------------------------------------------
- *NERD_block_com_after_right*
-This option affects commenting when it is done in visual-block mode. If this
-option is turned on, lines that begin outside the right boundary of the
-selection block will be commented. Enable this option with: >
- let NERD_block_com_after_right=1
-<
+
+
+------------------------------------------------------------------------------
+ *NERDBlockComIgnoreEmpty*
+Values: 0 or 1.
+Default: 1.
+
+This option affects visual-block mode commenting. If this option is turned
+on, lines that begin outside the right boundary of the selection block will be
+ignored.
+
For example, if you are commenting this chunk of c code in visual-block mode
(where the '|'s are used to represent the visual-block boundary) >
#include <sys/types.h>
@@ -3990,7 +3949,7 @@
| | }
|} |
<
-If NERD_block_com_after_right=1 then this code will become: >
+If NERDBlockComIgnoreEmpty=0 then this code will become: >
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
@@ -4006,18 +3965,22 @@
#include <unistd.h>
#include <stdio.h>
/*int*/ main(){
- printf("SUCK THIS\n");
- while(1){
- fork();
- }
+ printf("SUCK THIS\n");
+ while(1){
+ fork();
+ }
/*} */
<
------------------------------------------------------------------------------
- *NERD_comment_whole_lines_in_v_mode*
-This option can take 2 values. By default NERD_comments tries to comment out
-exactly what is selected in visual mode (v). For example if you select and
-comment the following c code (using | to represent the visual boundary): >
+
+------------------------------------------------------------------------------
+ *NERDCommentWholeLinesInVMode*
+Values: 0, 1 or 2.
+Default: 0.
+
+By default the script tries to comment out exactly what is selected in visual
+mode (v). For example if you select and comment the following c code (using |
+to represent the visual boundary): >
in|t foo = 3;
int bar =| 9;
int baz = foo + bar;
@@ -4032,8 +3995,8 @@
/*int bar = 9;*/
int baz = foo + bar;
<
-If you prefer the second option then stick this line in your .vimrc: >
- let NERD_comment_whole_lines_in_v_mode=1
+If you prefer the second option then stick this line in your vimrc: >
+ let NERDCommentWholeLinesInVMode=1
<
If the filetype you are editing only has no multipart delimiters (for example
@@ -4041,37 +4004,40 @@
in#t foo = 3;
#int bar = 9;
<
-(where # is the comment delimiter) as this is the closest NERD_comments can
+(where # is the comment delimiter) as this is the closest the script can
come to commenting out exactly what was selected. If you prefer for whole
lines to be commented out when there is no multipart delimiters but the EXACT
text that was selected to be commented out if there IS multipart delimiters
-then stick the following line in your .vimrc: >
- let NERD_comment_whole_lines_in_v_mode=2
+then stick the following line in your vimrc: >
+ let NERDCommentWholeLinesInVMode=2
<
-Note that this option does not affect the behaviour of visual-block mode ().
-
------------------------------------------------------------------------------
- *NERD_dont_remove_alt_coms*
-When uncommenting a line when there is an alternative commenting style for the
-current filetype, this option tells the script not to look for, and remove,
-comments delimiters of the alternative style. >
- let NERD_dont_remove_alt_coms=1
-<
+Note that this option does not affect the behaviour of |visual-block| mode.
+
+------------------------------------------------------------------------------
+ *NERDRemoveAltComs*
+Values: 0 or 1.
+Default: 1.
+
+When uncommenting a line (for a filetype with an alternative commenting style)
+this option tells the script whether to look for, and remove, comments
+delimiters of the alternative style.
+
For example, if you are editing a c++ file using // style comments and you go
<leader>cu on this line: >
/* This is a c++ comment baby! */
<
-It will not be uncommented if the NERD_dont_remove_alt_coms is set to 1.
-
------------------------------------------------------------------------------
- *NERD_dont_remove_spaces_regexp*
+It will not be uncommented if the NERDRemoveAltComs is set to 0.
+
+------------------------------------------------------------------------------
+ *NERDRemoveExtraSpaces*
+Values: 0 or 1.
+Default: 1.
+
By default, the NERD commenter will remove spaces around comment delimiters if
either:
-1. The current filetype matches the |NERD_space_delim_filetype_regexp| option
- (which is a regular expression).
-2. The current filtype doesnt match NERD_dont_remove_spaces_regexp option
- (which is also a reg exp)
+1. |NERDSpaceDelims| is set to 1.
+2. NERDRemoveExtraSpaces is set to 1.
This means that if we have the following lines in a c code file: >
/* int foo = 5; */
@@ -4089,35 +4055,23 @@
int bar = 10;
int baz = foo + bar
<
-If you want the spaces to be removed only if the current filetype matches
-|NERD_space_delim_filetype_regexp| then set the
-NERD_dont_remove_spaces_regexp option in your vimrc so that it matches the
-desired filetypes.
-
-See |NERD_com-reg-exps| for example reg exps.
-
-Defaults to "^python$"
-
------------------------------------------------------------------------------
- *NERD_create_h_filetype*
-If this option is set then NERD_comments will create a seperate filetype for h
-files. This could be needed because some versions of vim treat h files as cpp
-files which can be dodgy for commenting because if you are using // to comment
-cpp files then this is invalid when you are commenting h files for a c
-project (unless you arent adhering to the ANSI standard... naughty naughty).
-To enable this option, stick the following line in your .vimrc: >
- let NERD_create_h_filetype = 1
-<
-
------------------------------------------------------------------------------
- *NERD_lPlace*
- *NERD_rPlace*
+If you want the spaces to be removed only if |NERDSpaceDelims| is set then
+set NERDRemoveExtraSpaces to 0.
+
+------------------------------------------------------------------------------
+ *NERDLPlace*
+ *NERDRPlace*
+Values: arbitrary string.
+Default:
+ NERDLPlace: "[>"
+ NERDRPlace: "<]"
+
These options are used to control the strings used as place-holder delimiters.
Place holder delimiters are used when performing nested commenting when the
filetype supports commenting styles with both left and right delimiters.
To set these options use lines like: >
- let NERD_lPlace="FOO"
- let NERD_rPlace="BAR"
+ let NERDLPlace="FOO"
+ let NERDRPlace="BAR"
<
Following the above example, if we have line of c code: >
/* int horse */
@@ -4126,49 +4080,13 @@
/*FOO int horse BAR*/
<
When we uncomment this line it will go back to what it was.
-NERD_lPlace defaults to '[>', NERD_rPlace defaults to '<]'.
-
------------------------------------------------------------------------------
- *NERD_left_align_regexp*
-This option is a regular expression which is used to specify which filetypes
-should have their left delimiters aligned when commenting multiple lines.
-
-For example, consider this chunk of c code: >
- 1 int foo = 3;
- 2 int bar = 5;
- 3 while(foo < 50){
- 4 foo = foo + bar;
- 5 printf("i am just making up this code\n");
- 6 printf("i have no idea what im writing\n");
- 7 }
-<
-If the NERD_left_align_regexp regexp covers c files then if we select lines
-3-7 in visual mode and hit <leader>cc the code will become: >
- 1 int foo = 3;
- 2 int bar = 5;
- 3 /*while(foo < 50){*/
- 4 /* foo = foo + bar;*/
- 5 /* printf("i am just making up this code\n");*/
- 6 /* printf("i have no idea what im writing\n");*/
- 7 /*}*/
-<
-If NERD_left_align_regexp doesnt cover c files then the code will become: >
- 1 int foo = 3;
- 2 int bar = 5;
- 3 /* while(foo < 50){ */
- 4 /* foo = foo + bar; */
- 5 /* printf("i am just making up this code\n"); */
- 6 /* printf("i have no idea what im writing\n"); */
- 7 /* } */
-<
-NERD_left_align_regexp defaults to '^$' meaning no filetypes have their left
-delims aligned.
-
-See |NERD_com-reg-exps| for example reg exps.
-
------------------------------------------------------------------------------
- *NERD_mapleader*
-NERD_mapleader is used to specify what all the NERD commenter key mappings
+
+------------------------------------------------------------------------------
+ *NERDMapleader*
+Values: arbitrary string.
+Default: <leader>c
+
+NERDMapleader is used to specify what all the NERD commenter key mappings
begin with.
Assuming that <leader> == '\', the default key mappings will look like this: >
@@ -4180,7 +4098,7 @@
...
<
However, if this line: >
- let NERD_mapleader = ',x'
+ let NERDMapleader = ',x'
<
were present in your vimrc then the default mappings would look like this: >
,xc
@@ -4193,71 +4111,40 @@
This option only affects the mappings that have not been explicitly set
manually (see |NERD_com-cust-keys|).
-Default is <leader>c.
-
------------------------------------------------------------------------------
- *NERD_menu_mode*
-This option can take 3 values:
- "0": Turns the NERD commenter menu off completely.
- "1": Turns the NERD commenter menu on with no menu shortcut.
- "2": Turns the NERD commenter menu on with <alt>-c as the menu shortcut.
+------------------------------------------------------------------------------
+ *NERDMenuMode*
+Values: 0, 1, 2, 3.
+Default: 3
+
+This option can take 4 values:
+ "0": Turns the menu off.
+ "1": Turns the 'comment' menu on with no menu shortcut.
+ "2": Turns the 'comment 'menu on with <alt>-c as the shortcut.
+ "3": Turns the 'Plugin -> comment' menu on with <alt>-c as the shortcut.
-Default is "2".
-
------------------------------------------------------------------------------
- *NERD_place_holder_regexp*
-This option is a regular expression which is used to specify which filetypes
-place-holder delimiters should be used for when adding nested comments.
-
-See |NERD_com-reg-exps| for example reg exps.
-
------------------------------------------------------------------------------
- *NERD_right_align_regexp*
-This option is a regular expression which is used to specify which filetypes
-should have their right delimiters aligned when commenting multiple lines.
-
-For example, consider this chunk of c code: >
- 1 int foo = 3;
- 2 int bar = 5;
- 3 while(foo < 50){
- 4 foo = foo + bar;
- 5 printf("i am just making up this code\n");
- 6 printf("i have no idea what im writing\n");
- 7 }
+------------------------------------------------------------------------------
+ *NERDUsePlaceHolders*
+Values: 0 or 1.
+Default 1.
+
+This option is used to specify whether place-holder delimiters should be used
+when adding nested comments.
+
+------------------------------------------------------------------------------
+ *NERDShutUp*
+Values: 0 or 1.
+Default 1.
+
+This option is used to prevent the script from echoing anything. Stick this
+line in your vimrc: >
+ let NERDShutUp=1
<
-If the NERD_right_align_regexp regexp covers c files then if we select lines
-3-7 in visual mode and hit <leader>cc the code will become: >
- 1 int foo = 3;
- 2 int bar = 5;
- 3 /*while(foo < 50){ */
- 4 /*foo = foo + bar; */
- 5 /*printf("i am just making up this code\n"); */
- 6 /*printf("i have no idea what im writing\n");*/
- 7 /*} */
-<
-If NERD_right_align_regexp doesnt cover c files then the code will become: >
- 1 int foo = 3;
- 2 int bar = 5;
- 3 /* while(foo < 50){ */
- 4 /* foo = foo + bar; */
- 5 /* printf("i am just making up this code\n"); */
- 6 /* printf("i have no idea what im writing\n"); */
- 7 /* } */
-<
-NERD_right_align_regexp defaults to '^$' meaning no filetypes have their right
-delims aligned.
-
-See |NERD_com-reg-exps| for example reg exps.
-
------------------------------------------------------------------------------
- *NERD_shut_up*
-This option is used to prevent NERD_comments from echoing anything.
-Stick this line in your .vimrc: >
- let NERD_shut_up=1
-<
-
------------------------------------------------------------------------------
- *NERD_space_delim_filetype_regexp*
+
+------------------------------------------------------------------------------
+ *NERDSpaceDelims*
+Values: 0 or 1.
+Default 0.
+
Some people prefer a space after the left delimiter and before the right
delimiter like this: >
/* int foo=2; */
@@ -4265,15 +4152,15 @@
as opposed to this: >
/*int foo=2;*/
<
-This option is a regular expression that is used to specify which filetypes
-NERD_comments should use spaces for (as in the first eg above).
-NERD_space_delim_filetype_regexp defaults to '^$'.
-
-See also |NERD_dont_remove_spaces_regexp|.
-See |NERD_com-reg-exps| for example reg exps.
-
------------------------------------------------------------------------------
- *NERD_use_compact_sexy_com_regexp*
+If you want spaces to be added then set NERDSpaceDelims to 1 in your vimrc.
+
+See also |NERDRemoveExtraSpaces|.
+
+------------------------------------------------------------------------------
+ *NERDCompactSexyComs*
+Values: 0 or 1.
+Default 0.
+
Some people may want their sexy comments to be like this: >
/* Hi There!
* This is a sexy comment
@@ -4286,183 +4173,61 @@
* in c
*/
<
-The option NERD_use_compact_sexy_com_regexp is a regular expression. If the
-filetype that the user is commenting matches this regular expression then when
-they do sexy comments they will look like the first comment above.
-
------------------------------------------------------------------------------
- *NERD_use_nested_comments_default*
-When this option is turned on comments are nested automatically. That is, if
-you hit <leader>cc on a line that is already commented, or contains comments,
-it will be commented again. >
- let NERD_use_nested_comments_default=1
+If this option is set to 1 then the top style will be used.
+
+------------------------------------------------------------------------------
+ *NERDDefaultNesting*
+Values: 0 or 1.
+Default 0.
+
+When this option is set to 1, comments are nested automatically. That is, if
+you hit <leader>cc on a line that is already commented it will be commented
+again
+
+------------------------------------------------------------------------------
+3.3 Default delimiter customisation *NERD_com-cust-delims*
+
+If you want the NERD commenter to use the alternative delimiters for a
+specific filetype by default then put a line of this form into your vimrc: >
+ let NERD_<&filetype>_alt_style=1
<
-
------------------------------------------------------------------------------
-3.3 Default delimiter customisation *NERD_com-cust-delims*
-These options are used to tell NERD_comments which delimiters to use for a
-given filetype when it first loads up. To set one of these options just stick
-the corresponding line in your .vimrc. For example: if i want to use /* */ to
-delimit comments in java files instead of // (which is the default) then I
-would stick this line in my .vimrc: >
- let NERD_use_c_style_java_comments=1
+Example: java uses // style comments by default, but you want it to default to
+/* */ style comments instead. You would put this line in your vimrc: >
+ let NERD_java_alt_style=1
<
-Note that if filetype has two commenting styles, which are both supported, you
-can switch between them with <leader>ca. See |NERD_com-alt-delim|. These
-options only change which style is used when the script is initialsed.
-
-NERD_use_ada_with_spaces: use --<space> instead of -- for ada files.
-NERD_use_c_style_acedb_comments: use /**/ instead of // for acedb files.
-NERD_use_c_style_ch_comments: use /**/ instead of // for ch files.
-NERD_use_c_style_clean_comments: use /**/ instead of // for clean files.
-NERD_use_c_style_clipper_comments: use /**/ instead of // for clipper files.
-NERD_use_c_style_cpp_comments: use /**/ instead of // for c++ files.
-NERD_use_c_style_cs_comments: use /**/ instead of // for c# files.
-NERD_use_c_style_dot_comments: use /**/ instead of // for dot files.
-NERD_use_c_style_dylan_comments: use /**/ instead of // for dylan files.
-NERD_use_c_style_h_comments: use /**/ instead of // for h files.
-NERD_use_c_style_hercules_comments: use /**/ instead of // for hercules files.
-NERD_use_c_style_idl_comments: use /**/ instead of // for idl files.
-NERD_use_c_style_ishd_comments: use /**/ instead of // for ishd files.
-NERD_use_c_style_java_comments: use /**/ instead of // for java files.
-NERD_use_c_style_javascript_comments: use /**/ instead of // for javascript files.
-NERD_use_c_style_kscript_comments: use /**/ instead of // for kscript files.
-NERD_use_c_style_mel_comments: use /**/ instead of // for mel files.
-NERD_use_c_style_named_comments: use /**/ instead of // for named files.
-NERD_use_c_style_pccts_comments: use /**/ instead of // for pccts files.
-NERD_use_c_style_php_comments: use /* */ instead of // for php files.
-NERD_use_c_style_pike_comments: use /**/ instead of // for pike files.
-NERD_use_c_style_pilrc_comments: use /**/ instead of // for pilrc files.
-NERD_use_c_style_plm_comments: use /**/ instead of // for plm files.
-NERD_use_c_style_pov_comments: use /**/ instead of // for pov files.
-NERD_use_c_style_prolog_comments: use /**/ instead of % for prolog files.
-NERD_use_c_style_rc_comments: use /**/ instead of // for rc files.
-NERD_use_c_style_tads_comments: use /**/ instead of // for tads files.
-NERD_use_c_style_tsalt_comments: use /**/ instead of // for tsalt files.
-NERD_use_c_style_uc_comments: use /**/ instead of // for uc files.
-NERD_use_c_style_verilog_comments: use /**/ instead of // for verilog files.
-NERD_use_dash_dash_simula_comments: use -- instead of % for simula files.
-NERD_use_dnl_style_automake_comments: use dnl instead of # for automake files.
-NERD_use_hash_samba_comments: use # instead of ; for samba files.
-NERD_use_long_haskell_comments: use {--} instead of -- for haskell files.
-NERD_use_long_lisp_comments: use #||# instead of ; for lisp files.
-NERD_use_long_lua_comments: use --[[]] instead of -- for lua files.
-NERD_use_paren_star_pascal_comments: use (**) instead of {} for pascal files.
-NERD_use_REM_basic_comments: use REM instead of ' for basic files.
-NERD_use_single_part_c_comments: use // instead of /* */ for c files.
-
-
------------------------------------------------------------------------------
-3.4 Key mapping customisation *NERD_com-cust-keys*
+See |NERD_com-alt-delim| for switching commenting styles at runtime.
+
+------------------------------------------------------------------------------
+3.4 Key mapping customisation *NERD_com-cust-keys*
These options are used to override the default keys that are used for the
commenting mappings. Their values must be set to strings. As an example: if
you wanted to use the mapping <leader>foo to uncomment lines of code then
you would place this line in your vimrc >
- let NERD_uncom_line_map="<leader>foo"
+ let NERDUncomLineMap="<leader>foo"
<
-
Check out |NERD_com-functionality| for details about what the following
mappings do.
- *NERD_alt_com_map*
-To override the <leader>ca mapping, set this option >
- let NERD_alt_com_map="<new mapping>"
-<
- *NERD_append_com_map*
-To override the <leader>ce mapping, set this option >
- let NERD_append_com_map="<new mapping>"
-<
- *NERD_com_align_left_map*
-To override the <leader>cl mapping, set this option >
- let NERD_com_align_left_map="<new mapping>"
-<
- *NERD_com_align_both_map*
-To override the <leader>cb mapping, set this option >
- let NERD_com_align_both_map="<new mapping>"
-<
- *NERD_com_align_right_map*
-To override the <leader>cr mapping, set this option >
- let NERD_com_align_right_map="<new mapping>"
-<
- *NERD_com_in_insert_map*
-To override the <C-c> mapping, set this option >
- let NERD_com_in_insert_map="<new mapping>"
-<
- *NERD_com_line_invert_map*
-To override the <leader>ci mapping, set this option >
- let NERD_com_line_invert_map="<new mapping>"
-<
- *NERD_com_line_map*
-To override the <leader>cc mapping, set this option >
- let NERD_com_line_map="<new mapping>"
-<
- *NERD_com_line_nest_map*
-To override the <leader>cn mapping, set this option >
- let NERD_com_line_nest_map="<new mapping>"
-<
- *NERD_com_line_sexy_map*
-To override the <leader>cs mapping, set this option >
- let NERD_com_line_sexy_map="<new mapping>"
-<
- *NERD_com_line_toggle_map*
-To override the <leader>c<space> mapping, set this option >
- let NERD_com_line_toggle_map="<new mapping>"
-<
- *NERD_com_line_minimal_map*
-To override the <leader>cm mapping, set this option >
- let NERD_com_line_minimal_map="<new mapping>"
-<
- *NERD_com_to_end_of_line_map*
-To override the <leader>c$ mapping, set this option >
- let NERD_com_to_end_of_line_map="<new mapping>"
-<
- *NERD_com_line_yank_map*
-To override the <leader>cy mapping, set this option >
- let NERD_com_line_yank_map="<new mapping>"
-<
- *NERD_uncom_line_map*
-To override the <leader>cu mapping, set this option >
- let NERD_uncom_line_map="<new mapping>"
-<
-
-------------------------------------------------------------------------------
-3.5 Sample regular expressions *NERD_com-reg-exps*
-
-Many of the options in the NERD commenter must be set to regular
-expressions... regular expressions can be a bit confusing so i have provided
-some template ones here that you can start from:
-
-Regexp1: '.*'
-Matches any filetype. This is useful for turning an option on for all files.
-
-Regexp2: '^$'
-Matches no filetypes. This is useful for turning an option off for all files.
-
-Regexp3: '^\(java\)$'
-Matches only the java filetype.
-
-Regexp4: '^\(c\|vim\)$'
-Matches only c and vim filetypes.
-
-Regexp5: '^\(c.*\|vim\)$'
-Matches filetypes beginning with c (eg c, cpp, cs, etc) as well
-as vim files.
-
-Regexp6: '^\(c.*\|java\|tex\)$'
-Matches filetypes beginning with c (eg c, cpp, cs, etc) as well as java and
-tex filetypes.
-
-Regexp7: '^\(python\)\@!'
-Matches anything other than 'python'.
-
-Regexp8: '^c\(s\)\@!'
-Matches 'c' followed by anything accept an 's'.
-
-Regexp9: '^\(foo$\|bar$\|baz$\)\@!'
-Matches any strings except 'foo', 'bar' and 'baz'.
-
+Default Mapping Option to override~
+
+<leader>ca NERDAltComMap
+<leader>ce NERDAppendComMap
+<leader>cl NERDComAlignLeftMap
+<leader>cb NERDComAlignBothMap
+<leader>cr NERDComAlignRightMap
+<C-c> NERDComInInsertMap
+<leader>ci NERDComLineInvertMap
+<leader>cc NERDComLineMap
+<leader>cn NERDComLineNestMap
+<leader>cs NERDComLineSexyMap
+<leader>c<space> NERDComLineToggleMap
+<leader>cm NERDComLineMinimalMap
+<leader>c$ NERDComToEOLMap
+<leader>cy NERDComLineYankMap
+<leader>cu NERDUncomLineMap
+
==============================================================================
4. Issues with the script{{{2 *NERD_com-issues*
@@ -4507,14 +4272,6 @@
(Note that in the above examples I have deliberately not used place holders
for simplicity)
-------------------------------------------------------------------------------
-4.3 Mark clobbering *NERD_com-mark-clobbering*
-
-The script clobbers the s and t marks when doing most comments. Im not sure
-how to save and restore the marks yet.
-
-
-
==============================================================================
5. TODO list {{{2 *NERD_com-todo*
@@ -4524,7 +4281,83 @@
==============================================================================
-6. Credits {{{2 *NERD_com-credits*
+6. Changelog {{{2 *NERD_com-changelog*
+
+2.0.5
+ - Added support for autoit, autohotkey and docbk filetypes (thanks to
+ Michael Böhler)
+ - Added support for cmake (thanks to Aaron Small)
+ - Added support for htmldjango and django filetypes (thanks to Ramiro
+ Morales)
+ - Improved the delimiters for eruby again
+ - Applied a patch from Seth Mason to fix some pathing issues with the help
+ file installation.
+
+2.0.4
+ - Added support for verilog_systemverilog and systemverilog filetypes
+ (Thanks to Alexey for the email)
+ - Added support for fstab, thanks to Lizendir for the email.
+ - Added support for the smarty filetype.
+ - Improved the delimiters for eruby.
+ - Added dummy support for changelog filetype.
+
+2.0.3
+ - Added dummy support for the csv filetype (thx to Mark Woodward for the
+ email)
+ - Added dummy support for vo_base and otl filetypes (thanks to fREW for
+ the email)
+
+2.0.2:
+ - Minor bug fix that was stopping nested comments from working
+
+2.0.1:
+ - Fixed the visual bell for the |NERDComToEOLMap| map.
+ - Added another possible value to the NERDMenuMode option which causes the
+ menu to be displayed under 'Plugin -> Comment'. See :h NERDMenuMode.
+ This new menu mode is now the default.
+ - Added support for the occam filetype (thanks to Anders for emailing me)
+ - Made the main commenting function (NERDComment) available outside the
+ script.
+ - bug fixes and refactoring
+
+2.0.0:
+ - NOTE: renamed the script to NERD_commenter.vim. When you install this
+ version you must delete the old files: NERD_comments.vim and
+ NERD_comments.txt.
+ - Reworked the mappings and main entry point function for the script to
+ avoid causing visual-bells and screen scrolling.
+ - Changes to the script options (see |NERD_com-Customisation| for
+ details):
+ - They are all camel case now instead of underscored.
+ - Converted all of the regular expression options into simple boolean
+ options for simplicity.
+ - All the options are now stated positively, eg.
+ NERD_dont_remove_spaces_regexp has become NERDRemoveExtraSpaces.
+ - Some of the option names have been changed (other than in the above
+ ways)
+ - Some have been removed altogether, namely: NERD_create_h_filetype
+ (why was a commenting script creating a filetype?!),
+ NERD_left_align_regexp, NERD_right_align_regexp,
+
+ - Removed all the NERD_use_alt_style_XXX_coms options and replaced them
+ with a better system. Now if a filetype has alternative delims, the
+ script will check whether an option of the form
+ "NERD_<&filetype>_alt_style" exists, and if it does then alt delims will
+ be used. See |NERD_com-cust-delims| for details.
+ - The script no longer removes extra spaces for sexy comments for the
+ NERDRemoveExtraSpaces option (it will still remove spaces if
+ NERDSpaceDelims is set).
+ - Added dummy support for viminfo and rtf.
+ - Added support for the "gentoo-package-\(keywords\|mask\|use\)"
+ filetypes.
+ - Added '#' comments as an alternative for the asm filetype
+
+Thanks to Markus Klinik and Anders for bug reports, and again to Anders
+for his patch. Thanks to John O'Shea and fREW for the filetype
+information.
+
+==============================================================================
+7. Credits {{{2 *NERD_com-credits*
Thanks and respect to the following people:
@@ -4616,9 +4449,49 @@
Thanks to Gary Church and Tim Carey-Smith for complaining about the
keymappings and causing me to introduce the NERD_mapleader option :)
+Thanks to Vigil for pointing out that the "fetchmail" filetype was not
+supported and emailing me the delimiters
+
+Thanks to Michael Brunner for telling me about the kconfig filetype.
+
+Thanks to Antono Vasiljev for telling me about the netdict filetype.
+
+Thanks to Melissa Reid for telling me about the omlet filetype.
+
+Thanks to Ilia N Ternovich for alerting me to the 'qf' (quickfix) filetype.
+
+Thanks to Markus Klinik for emailing me about a bug for sexy comments where
+spaces were being eaten.
+
+Thanks to John O'Shea for emailing me about the RTF filetype.
+
+Thanks to Anders for emailing me a patch to help get rid of all the visual
+bells and screen scrolling, and for sending me the delimiters for the occam
+filetype.
+
+Thanks to Anders and Markus Klinik for emailing me about the screen scrolling
+issues and finally getting me off my ass about them :P
+
+Thanks to Mark Woodward for emailing me about the csv filetype.
+
+Thanks to fREW for emailing me with the /gentoo-package-(mask|keywords|use)/
+filetypes the vo_base filetype.
+
+Thanks to Alexey for emailing me about the verilog_systemverilog/systemverilog
+filetypes.
+
+Cheers to Lizendir for the email about the fstab filetype
+
+Thanks to Michael Böhler for emailing me with the autoit, autohotkey and docbk
+filetypes.
+
+Thanks to Aaron Small for emailing me about the cmake filetype.
+
+Thanks to Ramiro for emailing me about the htmldjango and django filetypes.
+
+Thanks to Seth Mason for sending me a patch to fix some pathing issues for the
+help doc installation.
Cheers to myself for being the best looking man on Earth!
-
=== END_DOC
-
" vim: set foldmethod=marker :
Modified: trunk/packages/vim-scripts/plugin/a.vim
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/plugin/a.vim?rev=958&op=diff
==============================================================================
--- trunk/packages/vim-scripts/plugin/a.vim (original)
+++ trunk/packages/vim-scripts/plugin/a.vim Thu Jun 21 10:27:19 2007
@@ -11,6 +11,9 @@
" Directory & regex enhancements added by Bindu Wavell who is well known on
" vim.sf.net
+"
+" Patch for spaces in files/directories from Nathan Stien (also reported by
+" Soeren Sonnenburg)
" Do not load a.vim if is has already been loaded.
if exists("loaded_alternateFile")
@@ -21,6 +24,8 @@
endif
let loaded_alternateFile = 1
+let alternateExtensionsDict = {}
+
" setup the default set of alternate extensions. The user can override in thier
" .vimrc if the defaults are not suitable. To override in a .vimrc simply set a
" g:alternateExtensions_<EXT> variable to a comma separated list of alternates,
@@ -31,7 +36,7 @@
" This variable will be increased when an extension with greater number of dots
" is added by the AddAlternateExtensionMapping call.
-let s:maxDotsInExtension = 0
+let s:maxDotsInExtension = 1
" Function : AddAlternateExtensionMapping (PRIVATE)
" Purpose : simple helper function to add the default alternate extension
@@ -49,13 +54,14 @@
" This code handles extensions which contains a dot. exists() fails with
" such names.
- let v:errmsg = ""
+ "let v:errmsg = ""
" FIXME this line causes ex to return 1 instead of 0 for some reason??
- silent! echo g:alternateExtensions_{a:extension}
- if (v:errmsg != "")
- let g:alternateExtensions_{a:extension} = a:alternates
- endif
-
+ "silent! echo g:alternateExtensions_{a:extension}
+ "if (v:errmsg != "")
+ "let g:alternateExtensions_{a:extension} = a:alternates
+ "endif
+
+ let g:alternateExtensionsDict[a:extension] = a:alternates
let dotsNumber = strlen(substitute(a:extension, "[^.]", "", "g"))
if s:maxDotsInExtension < dotsNumber
let s:maxDotsInExtension = dotsNumber
@@ -93,9 +99,10 @@
" Mappings for OCaml
call <SID>AddAlternateExtensionMapping('ml',"mli")
call <SID>AddAlternateExtensionMapping('mli',"ml")
-
-"let g:alternateExtensions_{'aspx.cs'} = "aspx"
-"let g:alternateExtensions_{'aspx'} = "aspx.cs"
+" ASP stuff
+call <SID>AddAlternateExtensionMapping('aspx.cs', 'aspx')
+call <SID>AddAlternateExtensionMapping('aspx.vb', 'aspx')
+call <SID>AddAlternateExtensionMapping('aspx', 'aspx.cs,aspx.vb')
" Setup default search path, unless the user has specified
" a path in their [._]vimrc.
@@ -110,6 +117,16 @@
" by default a.vim will alternate to a file which does not exist
let g:alternateNoDefaultAlternate = 0
endif
+
+" If this variable is true then a.vim will convert the alternate filename to a
+" filename relative to the current working directory.
+" Feature by Nathan Huizinga
+if (!exists('g:alternateRelativeFiles'))
+ " by default a.vim will not convert the filename to one relative to the
+ " current working directory
+ let g:alternateRelativeFiles = 0
+endif
+
" Function : GetNthItemFromList (PRIVATE)
" Purpose : Support reading items from a comma seperated list
@@ -289,7 +306,16 @@
function! EnumerateFilesByExtension(path, baseName, extension)
let enumeration = ""
let extSpec = ""
- silent! let extSpec = g:alternateExtensions_{a:extension}
+ let v:errmsg = ""
+ silent! echo g:alternateExtensions_{a:extension}
+ if (v:errmsg == "")
+ let extSpec = g:alternateExtensions_{a:extension}
+ endif
+ if (extSpec == "")
+ if (has_key(g:alternateExtensionsDict, a:extension))
+ let extSpec = g:alternateExtensionsDict[a:extension]
+ endif
+ endif
if (extSpec != "")
let n = 1
let done = 0
@@ -380,6 +406,9 @@
while i <= s:maxDotsInExtension
let mods = mods . ":e"
let extension = fnamemodify(a:path, mods)
+ if (has_key(g:alternateExtensionsDict, extension))
+ return extension
+ endif
let v:errmsg = ""
silent! echo g:alternateExtensions_{extension}
if (v:errmsg == "")
@@ -669,7 +698,7 @@
" + implemented fix from Matt Perry
function! <SID>FindOrCreateBuffer(fileName, doSplit, findSimilar)
" Check to see if the buffer is already open before re-opening it.
- let FILENAME = a:fileName
+ let FILENAME = escape(a:fileName, ' ')
let bufNr = -1
let lastBuffer = bufnr("$")
let i = 1
@@ -701,6 +730,10 @@
let FILENAME = bufName
endif
endif
+ endif
+
+ if (g:alternateRelativeFiles == 1)
+ let FILENAME = fnamemodify(FILENAME, ":p:.")
endif
let splitType = a:doSplit[0]
Modified: trunk/packages/vim-scripts/plugin/bufexplorer.vim
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/plugin/bufexplorer.vim?rev=958&op=diff
==============================================================================
--- trunk/packages/vim-scripts/plugin/bufexplorer.vim (original)
+++ trunk/packages/vim-scripts/plugin/bufexplorer.vim Thu Jun 21 10:27:19 2007
@@ -1,5 +1,5 @@
"=============================================================================
-" Copyright: Copyright (C) 2001-2006 Jeff Lanzarotta
+" Copyright: Copyright (C) 2001-2007 Jeff Lanzarotta
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
@@ -10,7 +10,7 @@
" Name Of File: bufexplorer.vim
" Description: Buffer Explorer Vim Plugin
" Maintainer: Jeff Lanzarotta (delux256-vim at yahoo dot com)
-" Last Changed: Thursday, 30 November 2006
+" Last Changed: Friday, 27 April 2007
" Version: See g:loaded_bufexplorer for version number.
" Usage: Normally, this file should reside in the plugins
" directory and be automatically sourced. If not, you must
@@ -39,170 +39,97 @@
endif
" Version number.
-let g:loaded_bufexplorer = "7.0.12"
-
-" Show default help? If you set this to 0, you're on your own remembering that
-" '<F1>' brings up the help and what the sort order is.
-" 0 = Don't show, 1 = Do show.
-if !exists("g:bufExplorerDefaultHelp")
- let g:bufExplorerDefaultHelp = 1
-endif
-
-" Show detailed help by default?
-" 0 = Don't show, 1 = Do show.
-if !exists("g:bufExplorerDetailedHelp")
- let g:bufExplorerDetailedHelp = 0
-endif
-
-" Sort method.
-" Can be either 'number', 'name', 'mru', 'fullpath', or 'extension'.
-if !exists("g:bufExplorerSortBy")
- let g:bufExplorerSortBy = "mru"
-endif
-
-" When opening a new window, split the new windows below or above the
-" current window? 1 = below, 0 = above.
-if !exists("g:bufExplorerSplitBelow")
- let g:bufExplorerSplitBelow = &splitbelow
-endif
-
-" When opening a new window, split the new windows to the right or to the left
-" of the current window? 1 = right, 0 = left.
-if !exists("g:bufExplorerSplitRight")
- let g:bufExplorerSplitRight = &splitright
-endif
-
-" When opening a new window, split the new window horizontally or vertically?
-" '' = Horizontal, 'v' = Vertical.
-if !exists("g:bufExplorerSplitType")
- let g:bufExplorerSplitType = ""
-endif
-
-" When selected buffer is opened, open in current window or open a separate
-" one. 1 = use current, 0 = use new.
-if !exists("g:bufExplorerOpenMode")
- let g:bufExplorerOpenMode = 0
-endif
-
-" When opening a new window vertically, set the width to be this value.
-if !exists("g:bufExplorerSplitVertSize")
- let g:bufExplorerSplitVertSize = 0
-endif
-
-" When opening a new window horizontally, set the height to be this value.
-if !exists("g:bufExplorerSplitHorzSize")
- let g:bufExplorerSplitHorzSize = 0
-endif
-
-" Whether to sort in forward or reverse order.
-" 1 = forward, -1 = reverse.
-if !exists("g:bufExplorerSortDirection")
- let g:bufExplorerSortDirection = 1
-endif
-
-if g:bufExplorerSortDirection == 1
- let s:sortDirLabel = ""
-elseif g:bufExplorerSortDirection = -1
- let s:sortDirLabel = "reverse "
-endif
-
-" Whether to split out the path and file name or not.
-" 0 = Don't split, 1 = Do split.
-if !exists("g:bufExplorerSplitOutPathName")
- let g:bufExplorerSplitOutPathName = 1
-endif
-
-" Whether to show directories in the buffer list or not. Directories
-" usually show up in the list from using a command like ":e .".
-" 0 = Don't show, 1 = Do show.
-if !exists("g:bufExplorerShowDirectories")
- let g:bufExplorerShowDirectories = 1
-endif
-
-" Whether to show absolute paths or relative to the current directory.
-" 0 = Show absolute paths, 1 = Show relative paths
-if !exists("g:bufExplorerShowRelativePath")
- let g:bufExplorerShowRelativePath = 0
-endif
-
-" Used to make sure that only one BufExplorer is open at a time.
-if !exists("g:bufExplorerRunning")
- let g:bufExplorerRunning = 0
-endif
+let g:loaded_bufexplorer = "7.0.15"
" Check to make sure the Vim version 700 or greater.
if v:version < 700
- echo "Sorry, bufexplorer ".g:loaded_bufexplorer." ONLY runs with Vim 7.0 and greater"
+ echo "Sorry, bufexplorer ".g:loaded_bufexplorer."\nONLY runs with Vim 7.0 and greater"
finish
endif
-let s:MRUList = []
+" Set {{{1
+function s:Set(var, default)
+ if !exists(a:var)
+ if type(a:default)
+ exec "let" a:var "=" string(a:default)
+ else
+ exec "let" a:var "=" a:default
+ endif
+
+ return 1
+ endif
+
+ return 0
+endfunction
+"1}}}
+
+" Set Defaults.
+call s:Set("g:bufExplorerDefaultHelp", 1) " Show default help?
+call s:Set("g:bufExplorerDetailedHelp", 0) " Show detailed help?
+call s:Set("g:bufExplorerReverseSort", 0) " Sort reverse?
+call s:Set("g:bufExplorerShowDirectories", 1) " Show directories? (Dir's are added by commands like ':e .')
+call s:Set("g:bufExplorerShowRelativePath", 0) " Show listings with relative or absolute paths?
+call s:Set("g:bufExplorerSortBy", "mru") " Sorting methods are in s:sort_by:
+call s:Set("g:bufExplorerSplitBelow", &splitbelow) " Show horizontal splits below or above?
+call s:Set("g:bufExplorerSplitHorzSize", 0) " Height for a horizontal split.
+call s:Set("g:bufExplorerSplitOutPathName", 1) " Split out path and file name?
+call s:Set("g:bufExplorerSplitRight", &splitright) " Show vertical splits right or left?
+call s:Set("g:bufExplorerSplitVertical", 0) " Show splits horizontal or vertical?
+call s:Set("g:bufExplorerSplitVertSize", 0) " Height for a vertical split.
+call s:Set("g:bufExplorerUseCurrentWindow", 0) " Open selected buffer in current or new window.
let s:sort_by = ["number", "name", "fullpath", "mru", "extension"]
-" Setup the autocommands that handle the MRUList and other stuff.
+" Setup the autocommands that handle the MRUList and other stuff. {{{1
augroup bufexplorer
autocmd!
+ autocmd BufNew * call <SID>MRUPush()
autocmd BufEnter * call <SID>MRUPush()
autocmd BufEnter * call <SID>SetAltBufName()
autocmd BufDelete * call <SID>MRUPop()
autocmd BufWinEnter \[BufExplorer\] call <SID>Initialize()
autocmd BufWinLeave \[BufExplorer\] call <SID>Cleanup()
- autocmd VimEnter * call <SID>BuildInitialMRU()
+ autocmd VimEnter * call <SID>BuildMRU()
augroup End
-" Create commands
-if !exists(":BufExplorer")
- command BufExplorer :call <SID>StartBufExplorer("drop")
-endif
-
-if !exists(":SBufExplorer")
- command SBufExplorer :call <SID>StartBufExplorer("sp")
-endif
-
-if !exists(":VSBufExplorer")
- command VSBufExplorer :call <SID>StartBufExplorer("vsp")
-endif
-
-" Public Interfaces
+" Create commands {{{1
+command BufExplorer :call <SID>StartBufExplorer("drop")
+command SBufExplorer :call <SID>StartBufExplorer("sp")
+command VSBufExplorer :call <SID>StartBufExplorer("vsp")
+
+" Public Interfaces {{1
map <silent> <unique> <Leader>be :BufExplorer<CR>
map <silent> <unique> <Leader>bs :SBufExplorer<CR>
map <silent> <unique> <Leader>bv :VSBufExplorer<CR>
-" Winmanager Integration {{{
+let s:MRUList = []
+let s:running = 0
+
+" Winmanager Integration {{{1
let g:BufExplorer_title = "\[Buf\ List\]"
-
-if !exists("g:bufExplorerResize")
- let g:bufExplorerResize = 1
-endif
-
-" Function to start display.
-" set the mode to 'winmanager' for this buffer. this is to figure out how this
-" plugin was called. in a standalone fashion or by winmanager.
-function! BufExplorer_Start()
+call s:Set("g:bufExplorerResize", 1)
+call s:Set("g:bufExplorerMaxHeight", 25) " Handles dynamic resizing of the window.
+
+" Function to start display. Set the mode to 'winmanager' for this buffer.
+" This is to figure out how this plugin was called. In a standalone fashion
+" or by winmanager.
+function BufExplorer_Start()
let b:displayMode = "winmanager"
-
call s:StartBufExplorer("e")
endfunction
" Returns whether the display is okay or not.
-function! BufExplorer_IsValid()
+function BufExplorer_IsValid()
return 0
endfunction
" Handles dynamic refreshing of the window.
-function! BufExplorer_Refresh()
+function BufExplorer_Refresh()
let b:displayMode = "winmanager"
-
call s:StartBufExplorer("e")
endfunction
-" Handles dynamic resizing of the window.
-if !exists("g:bufExplorerMaxHeight")
- let g:bufExplorerMaxHeight = 25
-endif
-
" BufExplorer_ReSize.
-function! BufExplorer_ReSize()
+function BufExplorer_ReSize()
if !g:bufExplorerResize
return
end
@@ -215,8 +142,7 @@
" the last window line. Sometimes, when a line is deleted, although the
" window size is exactly equal to the number of lines in the file, some of
" the lines are pushed up and we see some lagging '~'s.
- let presRow = line(".")
- let presCol = virtcol(".")
+ let pres = getpos(".")
exe $
@@ -227,13 +153,11 @@
let &scrolloff = _scr
- exe presRow
- exe "keepjumps normal! ".presCol."|"
-endfunction
-" --- End Winmanager Integration
+ call setpos(".", pres)
+endfunction
" Initialize {{{1
-function! s:Initialize()
+function s:Initialize()
let s:_insertmode = &insertmode
set noinsertmode
@@ -255,21 +179,25 @@
setlocal cursorline
setlocal nospell
- let g:bufExplorerRunning = 1
+ set nobuflisted
+
+ let s:running = 1
endfunction
" Cleanup {{{1
-function! s:Cleanup()
+function s:Cleanup()
let &insertmode = s:_insertmode
let &showcmd = s:_showcmd
let &cpo = s:_cpo
let &report = s:_report
let &list = s:_list
- let g:bufExplorerRunning = 0
+ let s:running = 0
+
+ delmarks!
endfunction
" StartBufExplorer {{{1
-function! s:StartBufExplorer(split)
+function s:StartBufExplorer(open)
let name = '[BufExplorer]'
if !has("win32")
@@ -278,18 +206,20 @@
endif
" Make sure there is only one explorer open at a time.
- if g:bufExplorerRunning == 1
+ if s:running == 1
" Go to the open buffer.
- exec "drop" name
+ if has("gui")
+ exec "drop" name
+ end
+
return
endif
silent let s:raw_buffer_listing = s:GetBufferList()
- if s:DoAnyMoreBuffersExist() == 0
+ if len(s:raw_buffer_listing) < 2
echo "\r"
- echohl WarningMsg | echo "Sorry, there are no more buffers to explore"
- echohl none
+ call s:Warn("Sorry, there are no more buffers to explore")
return
endif
@@ -306,39 +236,36 @@
if !exists("b:displayMode") || b:displayMode != "winmanager"
" Do not use keepalt when opening bufexplorer to allow the buffer that we
" are leaving to become the new alternate buffer
- let [_splitbelow, _splitright] = [&splitbelow, &splitright]
- let [&splitbelow, &splitright] = [g:bufExplorerSplitBelow, g:bufExplorerSplitRight]
- exe "silent!" a:split name
- let [&splitbelow, &splitright] = [_splitbelow, _splitright]
+ call s:SplitOpen("silent ".a:open." ".name)
let s:splitWindow = winnr("$") > s:numberOfOpenWindows
if s:splitWindow
" Resize
- let [s, c] = (a:split =~ "v") ? [g:bufExplorerSplitVertSize, "|"] : [g:bufExplorerSplitHorzSize, "_"]
+ let [s, c] = (a:open =~ "v") ? [g:bufExplorerSplitVertSize, "|"] : [g:bufExplorerSplitHorzSize, "_"]
+
if (s > 0)
exe s "wincmd" c
endif
endif
+ else
+ let s:splitWindow = winnr("$") > s:numberOfOpenWindows
endif
call s:DisplayBufferList()
endfunction
" DisplayBufferList {{{1
-function! s:DisplayBufferList()
+function s:DisplayBufferList()
setlocal bufhidden=delete
setlocal buftype=nofile
setlocal modifiable
setlocal noswapfile
setlocal nowrap
- if has("syntax")
- call s:SetupSyntax()
- endif
-
+ call s:SetupSyntax()
call s:MapKeys()
- call s:AddHeader()
+ call setline(1, s:CreateHelp())
call s:BuildBufferList()
call cursor(s:firstBufferLine, 1)
@@ -350,7 +277,7 @@
endfunction
" MapKeys {{{1
-function! s:MapKeys()
+function s:MapKeys()
if exists("b:displayMode") && b:displayMode == "winmanager"
nnoremap <buffer> <silent> <tab> :call <SID>SelectBuffer(1)<cr>
endif
@@ -379,68 +306,72 @@
endfunction
" SetupSyntax {{{1
-if has("syntax")
- function! s:SetupSyntax()
- syn match bufExplorerHelp "^\"[ -].*"
- syn match bufExplorerHelpEnd "^\"=.*$"
- syn match bufExplorerSortBy "^\" Sorted by .*$"
- syn match bufExplorerOpenIn "^\" Open in .*$"
+function s:SetupSyntax()
+ if has("syntax")
+ syn match bufExplorerHelp "^\".*" contains=bufExplorerSortBy,bufExplorerMapping,bufExplorerTitle,bufExplorerSortType,bufExplorerToggleSplit,bufExplorerToggleOpen
+ syn match bufExplorerOpenIn "Open in \w\+ window" contained
+ syn match bufExplorerSplit "\w\+ split" contained
+ syn match bufExplorerSortBy "Sorted by .*" contained contains=bufExplorerOpenIn,bufExplorerSplit
+ syn match bufExplorerMapping "\" \zs.\+\ze :" contained
+ syn match bufExplorerTitle "Buffer Explorer.*" contained
+ syn match bufExplorerSortType "'\w\{-}'" contained
syn match bufExplorerBufNbr /^\s*\d\+/
-
- syn match bufExplorerModBuf /^\s*\d\+.\{4}+.*$/
- syn match bufExplorerLockedBuf /^\s*\d\+.\{3}[\-=].*$/
- syn match bufExplorerHidBuf /^\s*\d\+.\{2}h.*$/
- syn match bufExplorerActBuf /^\s*\d\+.\{2}a.*$/
- syn match bufExplorerCurBuf /^\s*\d\+.%.*$/
- syn match bufExplorerAltBuf /^\s*\d\+.#.*$/
-
- if !exists("g:did_bufexplorer_syntax_inits")
- let g:did_bufexplorer_syntax_inits = 1
-
- hi def link bufExplorerBufNbr Number
- hi def link bufExplorerHelp Special
- hi def link bufExplorerHelpEnd Special
- hi def link bufExplorerOpenIn String
- hi def link bufExplorerSortBy String
-
- hi def link bufExpFlagTagged Statement
- hi def link bufExplorerUnlisted Comment
- hi def link bufExplorerHidBuf Constant
- hi def link bufExplorerActBuf Identifier
- hi def link bufExplorerCurBuf Type
- hi def link bufExplorerAltBuf String
- hi def link bufExplorerModBuf Exception
- hi def link bufExplorerLockedBuf Special
- endif
- endfunction
-endif
+ syn match bufExplorerToggleSplit "toggle split type" contained
+ syn match bufExplorerToggleOpen "toggle open mode" contained
+
+ syn match bufExplorerModBuf /^\s*\d\+.\{4}+.*/
+ syn match bufExplorerLockedBuf /^\s*\d\+.\{3}[\-=].*/
+ syn match bufExplorerHidBuf /^\s*\d\+.\{2}h.*/
+ syn match bufExplorerActBuf /^\s*\d\+.\{2}a.*/
+ syn match bufExplorerCurBuf /^\s*\d\+.%.*/
+ syn match bufExplorerAltBuf /^\s*\d\+.#.*/
+
+ hi def link bufExplorerBufNbr Number
+ hi def link bufExplorerMapping NonText
+ hi def link bufExplorerHelp Special
+ hi def link bufExplorerOpenIn Identifier
+ hi def link bufExplorerSortBy String
+ hi def link bufExplorerSplit NonText
+ hi def link bufExplorerTitle NonText
+ hi def link bufExplorerSortType bufExplorerSortBy
+ hi def link bufExplorerToggleSplit bufExplorerSplit
+ hi def link bufExplorerToggleOpen bufExplorerOpenIn
+
+ hi def link bufExplorerActBuf Identifier
+ hi def link bufExplorerAltBuf String
+ hi def link bufExplorerCurBuf Type
+ hi def link bufExplorerHidBuf Constant
+ hi def link bufExplorerLockedBuf Special
+ hi def link bufExplorerModBuf Exception
+ endif
+endfunction
" GetHelpStatus {{{1
-function! s:GetHelpStatus()
- let h = '" Sorted by '.s:sortDirLabel.g:bufExplorerSortBy
+function s:GetHelpStatus()
+ let h = '" Sorted by '.((g:bufExplorerReverseSort == 1) ? "reverse " : "").g:bufExplorerSortBy
if s:splitWindow == 1
- if g:bufExplorerOpenMode == 1
+ if g:bufExplorerUseCurrentWindow == 1
let h .= ' | Open in Same window'
else
let h .= ' | Open in New window'
endif
endif
- if empty(g:bufExplorerSplitType)
+ if g:bufExplorerSplitVertical
+ let h .= ' | Vertical split'
+ else
let h .= ' | Horizontal split'
- else
- let h .= ' | Vertical split'
endif
return h
endfunction
-" AddHeader {{{1
-function! s:AddHeader()
+" CreateHelp {{{1
+function s:CreateHelp()
if g:bufExplorerDefaultHelp == 0 && g:bufExplorerDetailedHelp == 0
let s:firstBufferLine = 1
- return
+ return []
endif
let header = []
@@ -458,48 +389,47 @@
endif
call add(header, '" p : toggle spliting of file and path name')
- call add(header, '" R : toggle showing relative or short paths')
- call add(header, '" q : quit the Buffer Explorer')
+ call add(header, '" q : quit')
+ call add(header, '" r : reverse sort')
+ call add(header, '" R : toggle showing relative or full paths')
call add(header, '" s : select sort field '.string(s:sort_by).'')
-
- if s:splitWindow == 1
- call add(header, '" t : toggle split type')
- endif
-
- call add(header, '" r : reverse sort')
+ call add(header, '" t : toggle split type')
else
call add(header, '" Press <F1> for Help')
endif
- let h = s:GetHelpStatus()
-
- call add(header, h)
+ call add(header, s:GetHelpStatus())
+
call add(header, '"=')
let s:firstBufferLine = len(header) + 1
- call setline(1, header)
+
+ return header
endfunction
" GetBufferList {{{1
-function! s:GetBufferList()
+function s:GetBufferList()
redir => bufoutput
buffers
redir END
let bufs = split(bufoutput, '\n')
- let all = []
- let bufferNameWidths = []
+ let [all, widths, s:maxWidths] = [[], {}, {}]
+ let s:types = ["fullname", "relativename", "relativepath", "path", "shortname"]
+ for n in s:types
+ let widths[n] = []
+ endfor
for buf in bufs
let b = {}
let bufName = matchstr(buf, '"\zs.\+\ze"')
- let nameOnly = fnamemodify(bufName, ":t")
-
- if (nameOnly =~ '^\[.\+\]')
- let b["fullname"] = nameOnly
- let b["shortname"] = nameOnly
- let b["relativename"] = nameOnly
+ let nameonly = fnamemodify(bufName, ":t")
+
+ if (nameonly =~ '^\[.\+\]')
+ let b["relativename"] = nameonly
+ let b["fullname"] = nameonly
+ let b["shortname"] = nameonly
+ let b["relativepath"] = ""
let b["path"] = ""
- let b["relativepath"] = ""
else
let b["relativename"] = fnamemodify(bufName, ':~:.')
let b["fullname"] = fnamemodify(bufName, ":p")
@@ -515,34 +445,52 @@
endif
let b["attributes"] = matchstr(buf, '^\zs.\{-1,}\ze"')
+ let b["line"] = matchstr(buf, 'line \d\+')
+
call add(all, b)
- call add(bufferNameWidths, strlen(b["shortname"]))
+ for n in s:types
+ call add(widths[n], len(b[n]))
+ endfor
endfor
- let s:maxBufferNameWidth = max(bufferNameWidths)
+ for n in s:types
+ let s:maxWidths[n] = max(widths[n])
+ endfor
return all
endfunction
" BuildBufferList {{{1
-function! s:BuildBufferList()
+function s:BuildBufferList()
let lines = []
-
- let pathPad = repeat(' ', s:maxBufferNameWidth)
+ let pads = {}
+
+ for n in s:types
+ let pads[n] = repeat(' ', s:maxWidths[n])
+ endfor
" Loop through every buffer.
for buf in s:raw_buffer_listing
- let line = buf["attributes"]." "
-
- if g:bufExplorerSplitOutPathName
- let path = (g:bufExplorerShowRelativePath) ? buf["relativepath"] : buf["path"]
- let line .= buf["shortname"].strpart(pathPad.path, strlen(buf["shortname"]) - 1)
- else
- let line .= (g:bufExplorerShowRelativePath) ? buf["relativename"] : buf["fullname"]
- endif
-
- call add(lines, line)
+ let line = buf["attributes"]." "
+
+ if g:bufExplorerSplitOutPathName
+ let type = (g:bufExplorerShowRelativePath) ? "relativepath" : "path"
+ let path = buf[type]
+ let line .= buf["shortname"]." ".strpart(pads["shortname"].path, len(buf["shortname"]))
+ else
+ let type = (g:bufExplorerShowRelativePath) ? "relativename" : "fullname"
+ let path = buf[type]
+ let line .= path
+ endif
+
+ if !empty(pads[type])
+ let line .= strpart(pads[type], len(path))." "
+ endif
+
+ let line .= buf["line"]
+
+ call add(lines, line)
endfor
call setline(s:firstBufferLine, lines)
@@ -551,17 +499,18 @@
endfunction
" SelectBuffer {{{1
-function! s:SelectBuffer(split)
+function s:SelectBuffer(split)
" Sometimes messages are not cleared when we get here so it looks like an
" error has occurred when it really has not.
echo ""
" Are we on a line with a file name?
- if getline('.') =~ '^"'
+ if line('.') < s:firstBufferLine
+ exec "normal! \<cr>"
return
endif
- let _bufNbr = s:ExtractBufferNbr(getline('.'))
+ let _bufNbr = str2nr(getline('.'))
if exists("b:displayMode") && b:displayMode == "winmanager"
let bufname = expand("#"._bufNbr.":p")
@@ -574,8 +523,7 @@
if bufexists(_bufNbr)
let ka = "keepalt"
- " bufExplorerOpenMode: 1 == use current, 0 == use new
- if (g:bufExplorerOpenMode && s:splitWindow) || (!s:splitWindow && a:split)
+ if (g:bufExplorerUseCurrentWindow && s:splitWindow) || (!s:splitWindow && a:split)
" we will return to the previous buffer before opening the new one, so
" be sure to not use the keepalt modifier
silent bd!
@@ -587,39 +535,61 @@
" original alt buffer first to restore it. This only happens when
" selecting the current (%) buffer.
try
- exe "keepjumps silent! b!" s:altBufNbr
+ exe "keepjumps silent b!" s:altBufNbr
catch
endtry
let ka = ""
endif
- let cmd = (a:split) ? (g:bufExplorerSplitType == "v") ? "vert sb" : "sb" : "b!"
- let [_splitbelow, _splitright] = [&splitbelow, &splitright]
- let [&splitbelow, &splitright] = [g:bufExplorerSplitBelow, g:bufExplorerSplitRight]
- exe ka "keepjumps silent" cmd _bufNbr
- let [&splitbelow, &splitright] = [_splitbelow, _splitright]
+ let cmd = (a:split) ? (g:bufExplorerSplitVertical == 1) ? "vert sb" : "sb" : "b!"
+ call s:SplitOpen(ka." keepjumps silent ".cmd." "._bufNbr)
else
+ call s:Error("Sorry, that buffer no longer exists, please select another")
+ call s:RemoveBuffer(_bufNbr)
+ endif
+endfunction
+
+" RemoveBuffer {{{1
+function s:RemoveBuffer(buf)
+ " This routine assumes that the buffer to be removed is on the current line
+ try
+ exe "silent bw ".a:buf
+
setlocal modifiable
- keepjumps d _
+ " "_dd does not move the cursor (d _ does)
+ normal! "_dd
setlocal nomodifiable
- echoerr "Sorry, that buffer no longer exists, please select another"
- endif
+ call s:MRUPop(a:buf)
+
+ " Delete the buffer from the raw buffer list
+ call filter(s:raw_buffer_listing, 'v:val["attributes"] !~ " '.a:buf.' "')
+ catch
+ call s:Error(v:exception)
+ endtry
+endfunction
+
+" SplitOpen {{{1
+function s:SplitOpen(cmd)
+ let [_splitbelow, _splitright] = [&splitbelow, &splitright]
+ let [&splitbelow, &splitright] = [g:bufExplorerSplitBelow, g:bufExplorerSplitRight]
+
+ exe a:cmd
+
+ let [&splitbelow, &splitright] = [_splitbelow, _splitright]
endfunction
" DeleteBuffer {{{1
-function! s:DeleteBuffer()
- if getline('.') =~ '^"'
+function s:DeleteBuffer()
+ " Are we on a line with a file name?
+ if line('.') < s:firstBufferLine
return
endif
-
- let _bufNbr = s:ExtractBufferNbr(getline('.'))
" Do not allow this buffer to be deleted if it is the last one.
if len(s:MRUList) == 1
- echohl ErrorMsg | echo "Sorry, you are not allowed to delete the last buffer"
- echohl none
+ call s:Error("Sorry, you are not allowed to delete the last buffer")
return
endif
@@ -629,21 +599,12 @@
call WinManagerSuspendAUs()
end
+ let _bufNbr = str2nr(getline('.'))
+
if getbufvar(_bufNbr, '&modified') == 1
- echohl ErrorMsg | echo "Sorry, no write since last change for buffer "._bufNbr.", unable to delete"
- echohl none
+ call s:Error("Sorry, no write since last change for buffer "._bufNbr.", unable to delete")
else
- exe "silent! bw "._bufNbr
-
- setlocal modifiable
- " Does not move cursor (d _ does)
- keepjumps normal! "_dd
- setlocal nomodifiable
-
- call s:MRUPop(_bufNbr)
-
- " Delete the buffer from the raw buffer list
- call filter(s:raw_buffer_listing, 'v:val["attributes"] !~ " '._bufNbr.' "')
+ call s:RemoveBuffer(_bufNbr)
endif
" Reactivate winmanager autocommand activity.
@@ -654,7 +615,7 @@
endfunction
" Close {{{1
-function! s:Close()
+function s:Close()
let alt = bufnr("#")
if (s:numberOfOpenWindows > 1 && !s:splitWindow)
@@ -689,32 +650,25 @@
endfunction
" ToggleHelp {{{1
-function! s:ToggleHelp()
+function s:ToggleHelp()
let g:bufExplorerDetailedHelp = !g:bufExplorerDetailedHelp
+ setlocal modifiable
+
" Save position
- let orig_size = line("$")
- let [line, col] = [line("."), col('.')]
-
- " get list of buffers
- let buffs = getline(1, "$")
- call filter(buffs, 'v:val !~ "^\""')
-
- setlocal modifiable
-
- " Remove old info
- keepjumps silent! % d _
-
- call <SID>AddHeader()
-
- call setline(s:firstBufferLine, buffs)
+ normal! ma
+
+ " Remove old header
+ if (s:firstBufferLine > 1)
+ exec "1,".(s:firstBufferLine-1) "d _"
+ endif
+
+ call append(0, s:CreateHelp())
+
+ silent! normal! g`a
+ delmarks a
setlocal nomodifiable
-
- let new_size = line("$")
- let line = line + new_size - orig_size
-
- call cursor(line, col)
if exists("b:displayMode") && b:displayMode == "winmanager"
call WinManagerForceReSize("BufExplorer")
@@ -722,34 +676,43 @@
endfunction
" ToggleSplitOutPathName {{{1
-function! s:ToggleSplitOutPathName()
+function s:ToggleSplitOutPathName()
let g:bufExplorerSplitOutPathName = !g:bufExplorerSplitOutPathName
+ call s:RebuildBufferList()
+endfunction
+
+" ToggleShowRelativePath {{{1
+function s:ToggleShowRelativePath()
+ let g:bufExplorerShowRelativePath = !g:bufExplorerShowRelativePath
+ call s:RebuildBufferList()
+endfunction
+
+" RebuildBufferList {{{1
+function s:RebuildBufferList()
setlocal modifiable
let curPos = getpos('.')
- call <SID>BuildBufferList()
+ call s:BuildBufferList()
call setpos('.', curPos)
setlocal nomodifiable
endfunction
-" ToggleShowRelativePath {{{1
-function! s:ToggleShowRelativePath()
- let g:bufExplorerShowRelativePath = !g:bufExplorerShowRelativePath
- setlocal modifiable
-
- let curPos = getpos('.')
-
- call <SID>BuildBufferList()
- call setpos('.', curPos)
-
- setlocal nomodifiable
-endfunction
-
" ToggleOpenMode {{{1
-function! s:ToggleOpenMode()
- let g:bufExplorerOpenMode = !g:bufExplorerOpenMode
+function s:ToggleOpenMode()
+ let g:bufExplorerUseCurrentWindow = !g:bufExplorerUseCurrentWindow
+ call s:UpdateHelpStatus()
+endfunction
+
+" ToggleSplitType {{{1
+function s:ToggleSplitType()
+ let g:bufExplorerSplitVertical = !g:bufExplorerSplitVertical
+ call s:UpdateHelpStatus()
+endfunction
+
+" UpdateHelpStatus {{{1
+function s:UpdateHelpStatus()
if s:firstBufferLine > 1
setlocal modifiable
@@ -760,76 +723,34 @@
endif
endfunction
-" ToggleSplitType {{{1
-function! s:ToggleSplitType()
- if empty(g:bufExplorerSplitType)
- let g:bufExplorerSplitType = "v"
- else
- let g:bufExplorerSplitType = ""
- endif
-
- if s:firstBufferLine > 1
- setlocal modifiable
-
- let text = s:GetHelpStatus()
- call setline(s:firstBufferLine - 2, text)
-
- setlocal nomodifiable
- endif
-endfunction
-
-" ExtractBufferNbr {{{1
-function! s:ExtractBufferNbr(line)
- return matchstr(a:line, '\d\+') + 0
-endfunction
-
" MRUCmp {{{1
-function! s:MRUCmp(line1, line2)
- return index(s:MRUList, s:ExtractBufferNbr(a:line1)) - index(s:MRUList, s:ExtractBufferNbr(a:line2))
+function s:MRUCmp(line1, line2)
+ return index(s:MRUList, str2nr(a:line1)) - index(s:MRUList, str2nr(a:line2))
endfunction
" SortReverse {{{1
-function! s:SortReverse()
- if g:bufExplorerSortDirection == -1
- let g:bufExplorerSortDirection = 1
- let s:sortDirLabel = ""
- else
- let g:bufExplorerSortDirection = -1
- let s:sortDirLabel = "reverse "
- endif
-
- setlocal modifiable
-
- let curPos = getpos('.')
-
- call <SID>SortListing()
-
- if s:firstBufferLine > 1
- let text = s:GetHelpStatus()
- call setline(s:firstBufferLine - 2, text)
- endif
-
- call setpos('.', curPos)
-
- setlocal nomodifiable
+function s:SortReverse()
+ let g:bufExplorerReverseSort = !g:bufExplorerReverseSort
+ call s:ReSortListing()
endfunction
" SortSelect {{{1
-function! s:SortSelect()
+function s:SortSelect()
let i = index(s:sort_by, g:bufExplorerSortBy)
let i += 1
let g:bufExplorerSortBy = get(s:sort_by, i, s:sort_by[0])
+ call s:ReSortListing()
+endfunction
+
+" ReSortListing {{{1
+function s:ReSortListing()
setlocal modifiable
let curPos = getpos('.')
- call <SID>SortListing()
-
- if s:firstBufferLine > 1
- let text = s:GetHelpStatus()
- call setline(s:firstBufferLine - 2, text)
- endif
+ call s:SortListing()
+ call s:UpdateHelpStatus()
call setpos('.', curPos)
@@ -837,105 +758,94 @@
endfunction
" SortListing {{{1
-function! s:SortListing()
- let start = s:firstBufferLine
-
- let reverse = (g:bufExplorerSortDirection == 1) ? "": "!"
+function s:SortListing()
+ let sort = s:firstBufferLine.",$sort".((g:bufExplorerReverseSort == 1) ? "!": "")
if g:bufExplorerSortBy == "number"
" Easiest case.
- exec start.",$sort".reverse 'n'
+ exec sort 'n'
elseif g:bufExplorerSortBy == "name"
if g:bufExplorerSplitOutPathName
- exec start.",$sort".reverse 'i /^\s*\d\+.\{7}/'
+ exec sort 'ir /\d.\{7}\zs\f\+\ze/'
else
- " Ignore everything in the line until the last path separator.
- exec start.",$sort".reverse 'i /.*[\/\\]/'
+ exec sort 'ir /\zs[^\/\\]\+\ze\s*line/'
endif
elseif g:bufExplorerSortBy == "fullpath"
if g:bufExplorerSplitOutPathName
- " Sort twice ~ first on the file name then on the path.
- exec start.",$sort".reverse 'i /^\s*\d\+.\{7}/'
- exec start.",$sort".reverse 'i /^\s*\d\+.\{8}\S\+\s\+/'
- else
- " No-brainer, just like sort by name.
- exec start.",$sort".reverse 'i /^\s*\d\+.\{7}/'
- endif
+ " Sort twice - first on the file name then on the path.
+ exec sort 'ir /\d.\{7}\zs\f\+\ze/'
+ endif
+
+ exec sort 'ir /\zs\f\+\ze\s\+line/'
elseif g:bufExplorerSortBy == "extension"
- exec start.",$sort".reverse 'i /^\s*\d\+.\{7}\S*\./'
+ exec sort 'ir /\.\zs\w\+\ze\s/'
elseif g:bufExplorerSortBy == "mru"
- let l = getline(start, "$")
+ let l = getline(s:firstBufferLine, "$")
call sort(l, "<SID>MRUCmp")
- if (!empty(reverse))
+ if g:bufExplorerReverseSort
call reverse(l)
endif
- call setline(start, l)
+ call setline(s:firstBufferLine, l)
endif
endfunction
" SetAltBufName {{{1
-function! s:SetAltBufName()
+function s:SetAltBufName()
let b:altFileName = '# '.expand("#:t")
endfunction
" MRUPush {{{1
-function! s:MRUPush()
- let bufNbr = bufnr("%")
+function s:MRUPush()
+ let bufNbr = str2nr(expand('<abuf>'))
" Skip temporary buffer with buftype set.
- if !empty(getbufvar(bufNbr, "&buftype"))
- return
- endif
-
- if !buflisted(bufNbr)
+ " Don't add the BufExplorer window to the list.
+ if !empty(getbufvar(bufNbr, "&buftype")) ||
+ \ !buflisted(bufNbr) ||
+ \ fnamemodify(bufname(bufNbr), ":t") == "[BufExplorer]"
return
end
- " Don't add the BufExplorer window to the list.
- if fnamemodify(bufname(bufNbr), ":t") == "[BufExplorer]"
- return
- end
-
call s:MRUPop(bufNbr)
- call insert(s:MRUList,bufNbr)
+ call insert(s:MRUList, bufNbr)
endfunction
" MRUPop {{{1
-function! s:MRUPop(...)
- let _bufNbr = (a:0) ? a:1 : bufnr("%")
-
- let idx = index(s:MRUList, _bufNbr)
+function s:MRUPop(...)
+ let idx = index(s:MRUList, (a:0) ? a:1 : bufnr("%"))
if (idx != -1)
call remove(s:MRUList, idx)
endif
endfunction
-" BuildInitialMRU {{{1
-function! s:BuildInitialMRU()
+" BuildMRU {{{1
+function s:BuildMRU()
let s:MRUList = range(1, bufnr('$'))
call filter(s:MRUList, 'buflisted(v:val)')
endfunction
" MRUListShow {{{1
-function! s:MRUListShow()
+function s:MRUListShow()
echomsg "MRUList=".string(s:MRUList)
endfunction
-" DoAnyMoreBuffersExist {{{1
-function! s:DoAnyMoreBuffersExist()
- return len(s:raw_buffer_listing) > 1
-endfunction
-
" BufExplorerGetAltBuf {{{1
-function! BufExplorerGetAltBuf()
- if exists("b:altFileName")
- return b:altFileName
- else
- return ""
+function BufExplorerGetAltBuf()
+ return (exists("b:altFileName") ? b:altFileName : "")
+endfunction
+
+" Error {{{1
+function s:Error(msg)
+ echohl ErrorMsg | echo a:msg | echohl none
+endfunction
+
+" Warn {{{1
+function s:Warn(msg)
+ echohl WarningMsg | echo a:msg | echohl none
endfunction
" vim:ft=vim foldmethod=marker sw=2
Modified: trunk/packages/vim-scripts/plugin/calendar.vim
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/plugin/calendar.vim?rev=958&op=diff
==============================================================================
--- trunk/packages/vim-scripts/plugin/calendar.vim (original)
+++ trunk/packages/vim-scripts/plugin/calendar.vim Thu Jun 21 10:27:19 2007
@@ -1,39 +1,42 @@
"=============================================================================
" What Is This: Calendar
" File: calendar.vim
-" Author: Yasuhiro Matsumoto <mattn_jp at hotmail.com>
-" Last Change: Tue, 17 Jan 2006
-" Version: 1.4a
+" Author: Yasuhiro Matsumoto <mattn.jp at gmail.com>
+" Last Change: Wed, 02 May 2007
+" Version: 1.5
" Thanks:
-" Noel Henson : today action
-" Per Winkvist : bug report
-" Peter Findeisen : bug fix
-" Chip Campbell : gave a hint for 1.3z
-" PAN Shizhu : gave a hint for 1.3y
-" Eric Wald : bug fix
-" Sascha Wuestemann : advise
-" Linas Vasiliauskas : bug report
-" Per Winkvist : bug report
-" Ronald Hoelwarth : gave a hint for 1.3s
-" Vikas Agnihotri : bug report
-" Steve Hall : gave a hint for 1.3q
-" James Devenish : bug fix
-" Carl Mueller : gave a hint for 1.3o
-" Klaus Fabritius : bug fix
-" Stucki : gave a hint for 1.3m
-" Rosta : bug report
-" Richard Bair : bug report
-" Yin Hao Liew : bug report
-" Bill McCarthy : bug fix and gave a hint
-" Srinath Avadhanula : bug fix
-" Ronald Hoellwarth : few advices
-" Juan Orlandini : added higlighting of days with data
-" Ray : bug fix
-" Ralf.Schandl : gave a hint for 1.3
-" Bhaskar Karambelkar : bug fix
-" Suresh Govindachar : gave a hint for 1.2, bug fix
-" Michael Geddes : bug fix
-" Leif Wickland : bug fix
+" Serge (gentoosiast) Koksharov : bug fix
+" Vitor Antunes : bug fix
+" Olivier Mengue : bug fix
+" Noel Henson : today action
+" Per Winkvist : bug report
+" Peter Findeisen : bug fix
+" Chip Campbell : gave a hint for 1.3z
+" PAN Shizhu : gave a hint for 1.3y
+" Eric Wald : bug fix
+" Sascha Wuestemann : advise
+" Linas Vasiliauskas : bug report
+" Per Winkvist : bug report
+" Ronald Hoelwarth : gave a hint for 1.3s
+" Vikas Agnihotri : bug report
+" Steve Hall : gave a hint for 1.3q
+" James Devenish : bug fix
+" Carl Mueller : gave a hint for 1.3o
+" Klaus Fabritius : bug fix
+" Stucki : gave a hint for 1.3m
+" Rosta : bug report
+" Richard Bair : bug report
+" Yin Hao Liew : bug report
+" Bill McCarthy : bug fix and gave a hint
+" Srinath Avadhanula : bug fix
+" Ronald Hoellwarth : few advices
+" Juan Orlandini : added higlighting of days with data
+" Ray : bug fix
+" Ralf.Schandl : gave a hint for 1.3
+" Bhaskar Karambelkar : bug fix
+" Suresh Govindachar : gave a hint for 1.2, bug fix
+" Michael Geddes : bug fix
+" Leif Wickland : bug fix
" Usage:
" :Calendar
" show calendar at this year and this month
@@ -49,6 +52,8 @@
" <Leader>ch
" show horizontal calendar ...
" ChangeLog:
+" 1.5 : bug fix, fixed ruler formating with strpart.
+" bug fix, using winfixheight.
" 1.4a : bug fix, week numbenr was broken on 2005.
" added calendar_today action.
" bug fix, about wrapscan.
@@ -283,7 +288,7 @@
" :echo calendar_version
" GetLatestVimScripts: 52 1 :AutoInstall: calendar.vim
-let g:calendar_version = "1.4a"
+let g:calendar_version = "1.5"
if &compatible
finish
endif
@@ -686,7 +691,7 @@
let vwruler = g:calendar_wruler
endif
if exists('g:calendar_monday')
- let vwruler = strpart(vwruler,3).' '.strpart(vwruler,0,2)
+ let vwruler = strpart(vwruler,stridx(vwruler, ' ') + 1).' '.strpart(vwruler,0,stridx(vwruler, ' '))
endif
let vdisplay2 = vdisplay2.' '.vwruler."\n"
if g:calendar_mark == 'right'
@@ -936,6 +941,7 @@
" or not
if dir
execute 'bo '.vheight.'split __Calendar'
+ setlocal winfixheight
else
execute 'to '.vcolumn.'vsplit __Calendar'
endif
@@ -947,6 +953,7 @@
setlocal norightleft
setlocal foldcolumn=0
setlocal modifiable
+ setlocal nolist
set nowrapscan
let b:Calendar='Calendar'
" is this a vertical (0) or a horizontal (1) split?
Modified: trunk/packages/vim-scripts/plugin/cvsmenu.vim
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/plugin/cvsmenu.vim?rev=958&op=diff
==============================================================================
--- trunk/packages/vim-scripts/plugin/cvsmenu.vim (original)
+++ trunk/packages/vim-scripts/plugin/cvsmenu.vim Thu Jun 21 10:27:19 2007
@@ -1,8 +1,8 @@
" CVSmenu.vim : Vim menu for using CVS vim:tw=0:sw=2:ts=8
" Author : Thorsten Maerz <info at netztorte.de> vim600:fdm=marker
" Maintainer : Wu Yongwei <wuyongwei at gmail.com>
-" $Revision: 1.140 $
-" $Date: 2006/10/22 09:39:38 $
+" $Revision: 1.142 $
+" $Date: 2007/05/09 14:28:53 $
" License : LGPL
"
" Tested with Vim 6.0
@@ -83,8 +83,11 @@
if !exists("g:CVSspacesinannotate")
let g:CVSspacesinannotate = 1 " spaces to add in annotated source
endif
-if !exists("g:CVScvsoutputencoding")
- let g:CVScvsoutputencoding = '' " the encoding of CVS(NT) output
+if !exists("g:CVScmdencoding")
+ let g:CVScmdencoding = '' " the encoding of CVS(NT) commands
+endif
+if !exists("g:CVSfileencoding")
+ let g:CVSfileencoding = '' " the encoding of files in CVS
endif
if !exists("g:CVSdontconvertfor")
let g:CVSdontconvertfor = '' " commands that need no conversion
@@ -338,7 +341,7 @@
new
let zbak=@z
let @z = ''
- \."\n\"CVSmenu $Revision: 1.140 $"
+ \."\n\"CVSmenu $Revision: 1.142 $"
\."\n\"Current directory : ".expand('%:p:h')
\."\n\"Current Root : ".root
\."\n\"Current Repository : ".repository
@@ -365,7 +368,8 @@
\."\nlet g:CVSfullstatus\t= " .g:CVSfullstatus ."\t\" Display all fields for fullstatus"
\."\nlet g:CVSreloadaftercommit = " .g:CVSreloadaftercommit ."\t\" Reload file to update CVS keywords"
\."\nlet g:CVSspacesinannotate = " .g:CVSspacesinannotate ."\t\" Spaces to add in annotated source"
- \."\nlet g:CVScvsoutputencoding = \'" .g:CVScvsoutputencoding."\'" ."\t\" The encoding of CVS(NT) output"
+ \."\nlet g:CVScmdencoding = \'" .g:CVScmdencoding."\'" ."\t\" The encoding of CVS(NT) commands"
+ \."\nlet g:CVSfileencoding = \'" .g:CVSfileencoding."\'" ."\t\" The encoding of files in CVS"
\."\nlet g:CVSdontconvertfor = \'" .g:CVSdontconvertfor."\'" ."\t\" Commands that need no conversion"
\."\n\"----------------------------------------"
\."\n\" Change above values to your needs."
@@ -771,8 +775,10 @@
unlet tmp dummy
else
let regbak=@z
- if has('iconv') && g:CVScvsoutputencoding != ''
- let filename=iconv(filename, &encoding, g:CVScvsoutputencoding)
+ let cntenc=''
+ if has('iconv') && g:CVScmdencoding != ''
+ let filename=iconv(filename, &encoding, g:CVScmdencoding)
+ let cntenc=g:CVScmdencoding
endif
if &shell =~? 'cmd\.exe'
let shellxquotebak=&shellxquote
@@ -784,15 +790,21 @@
unlet shellxquotebak
endif
let cvscmd=matchstr(a:cmd,'\(^\| \)\zs\w\+\>')
- if has('iconv')
- \&& g:CVScvsoutputencoding != ''
+ if (cvscmd == 'annotate' || cvscmd == 'update')
+ \&& g:CVSfileencoding != ''
+ let cntenc=g:CVSfileencoding
+ endif
+ if has('iconv') && cntenc != ''
\&& ','.g:CVSdontconvertfor.',' !~ ','.cvscmd.','
- let @z=iconv(@z, g:CVScvsoutputencoding, &encoding)
+ let @z=iconv(@z, cntenc, &encoding)
endif
new
+ if cntenc != ''
+ let &fileencoding=cntenc
+ endif
silent normal "zP
let @z=regbak
- unlet regbak cvscmd
+ unlet regbak cntenc cvscmd
endif
call CVSProcessOutput(isfile, filename, a:cmd)
call CVSRestoreDir()
Modified: trunk/packages/vim-scripts/plugin/gnupg.vim
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/plugin/gnupg.vim?rev=958&op=diff
==============================================================================
--- trunk/packages/vim-scripts/plugin/gnupg.vim (original)
+++ trunk/packages/vim-scripts/plugin/gnupg.vim Thu Jun 21 10:27:19 2007
@@ -1,14 +1,15 @@
" Name: gnupg.vim
-" Version: $Id: gnupg.vim,v 1.27 2003/06/24 07:57:16 mb Exp $
+" Version: $Id: gnupg.vim 1605 2007-03-01 09:58:04Z mbr $
" Author: Markus Braun <markus.braun at krawel.de>
" Summary: Vim plugin for transparent editing of gpg encrypted files.
-" TODO enable signing
-" TODO GPGOptions for encrypting, signing, auto fetch ..
+" Licence: This program is free software; you can redistribute it and/or
+" modify it under the terms of the GNU General Public License.
+" See http://www.gnu.org/copyleft/gpl.txt
" Section: Documentation {{{1
" Description:
"
-" This script implements transparent editing of gpg public/private-key
-" encrypted files. The filename must have a ".gpg" suffix. When opening such
+" This script implements transparent editing of gpg encrypted files. The
+" filename must have a ".gpg", ".pgp" or ".asc" suffix. When opening such
" a file the content is decrypted, when opening a new file the script will
" ask for the recipients of the encrypted file. The file content will be
" encrypted to all recipients before it is written. The script turns off
@@ -24,115 +25,239 @@
"
" :GPGEditRecipients
" Opens a scratch buffer to change the list of recipients. Recipients that
-" are unknown (not in your public key) are highlighted and have a
-" prepended "!". Closing the buffer with :x or :bd makes the changes permanent.
+" are unknown (not in your public key) are highlighted and have
+" a prepended "!". Closing the buffer makes the changes permanent.
"
" :GPGViewRecipients
" Prints the list of recipients.
"
+" :GPGEditOptions
+" Opens a scratch buffer to change the options for encryption (symmetric,
+" asymmetric, signing). Closing the buffer makes the changes permanent.
+" WARNING: There is no check of the entered options, so you need to know
+" what you are doing.
+"
+" :GPGViewOptions
+" Prints the list of options.
+"
+" Variables:
+"
+" g:GPGUseAgent
+" If set to 0 a possible available gpg-agent won't be used. Defaults to 1.
+"
+" g:GPGPreferSymmetric
+" If set to 1 symmetric encryption is preferred for new files. Defaults to 0.
+"
+" g:GPGPreferArmor
+" If set to 1 armored data is preferred for new files. Defaults to 0.
+"
" Credits:
" Mathieu Clabaut for inspirations through his vimspell.vim script.
+" Richard Bronosky for patch to enable ".pgp" suffix.
+" Erik Remmelzwaal for patch to enable windows support and patient beta
+" testing.
+"
" Section: Plugin header {{{1
-if (exists("loaded_gnupg") || &cp || exists("#BufReadPre#*.gpg"))
- finish
+if (exists("loaded_gnupg") || &cp || exists("#BufReadPre#*.\(gpg\|asc\|pgp\)"))
+ finish
endi
let loaded_gnupg = 1
-" dettermine if gnupg can use the gpg-agent
-if (exists("$GPG_AGENT_INFO"))
- let s:gpgcommand = "gpg --use-agent"
-else
- let s:gpgcommand = "gpg"
-endif
-
" Section: Autocmd setup {{{1
augroup GnuPG
- au!
-
- " First make sure nothing is written to ~/.viminfo while editing
- " an encrypted file.
- autocmd BufNewFile,BufReadPre,FileReadPre *.gpg set viminfo=
- " We don't want a swap file, as it writes unencrypted data to disk
- autocmd BufNewFile,BufReadPre,FileReadPre *.gpg set noswapfile
- " Force the user to edit the recipient list if he opens a new file
- autocmd BufNewFile *.gpg call s:GPGEditRecipients()
- " Switch to binary mode to read the encrypted file
- autocmd BufReadPre,FileReadPre *.gpg set bin
- autocmd BufReadPost,FileReadPost *.gpg call s:GPGDecrypt()
- " Switch to normal mode for editing
- autocmd BufReadPost,FileReadPost *.gpg set nobin
- " Call the autocommand for the file minus .gpg$
- autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r")
- autocmd BufReadPost,FileReadPost *.gpg execute ":redraw!"
-
- " Switch to binary mode before encrypt the file
- autocmd BufWritePre,FileWritePre *.gpg set bin
- " Convert all text to encrypted text before writing
- autocmd BufWritePre,FileWritePre *.gpg call s:GPGEncrypt()
- " Undo the encryption so we are back in the normal text, directly
- " after the file has been written.
- autocmd BufWritePost,FileWritePost *.gpg silent u
- " Switch back to normal mode for editing
- autocmd BufWritePost,FileWritePost *.gpg set nobin
+au!
+
+" First make sure nothing is written to ~/.viminfo while editing
+" an encrypted file.
+autocmd BufNewFile,BufReadPre,FileReadPre *.\(gpg\|asc\|pgp\) set viminfo=
+" We don't want a swap file, as it writes unencrypted data to disk
+autocmd BufNewFile,BufReadPre,FileReadPre *.\(gpg\|asc\|pgp\) set noswapfile
+" Initialize the internal variables
+autocmd BufNewFile,BufReadPre,FileReadPre *.\(gpg\|asc\|pgp\) call s:GPGInit()
+" Force the user to edit the recipient list if he opens a new file and public
+" keys are preferred
+autocmd BufNewFile *.\(gpg\|asc\|pgp\) if (exists("g:GPGPreferSymmetric") && g:GPGPreferSymmetric == 0) | call s:GPGEditRecipients() | endi
+" Switch to binary mode to read the encrypted file
+autocmd BufReadPre,FileReadPre *.\(gpg\|asc\|pgp\) set bin
+autocmd BufReadPost,FileReadPost *.\(gpg\|asc\|pgp\) call s:GPGDecrypt()
+" Switch to normal mode for editing
+autocmd BufReadPost,FileReadPost *.\(gpg\|asc\|pgp\) set nobin
+" Call the autocommand for the file minus .gpg$
+autocmd BufReadPost,FileReadPost *.\(gpg\|asc\|pgp\) execute ":doautocmd BufReadPost " . escape(expand("%:r"), ' *?\"'."'")
+autocmd BufReadPost,FileReadPost *.\(gpg\|asc\|pgp\) execute ":redraw!"
+
+" Switch to binary mode before encrypt the file
+autocmd BufWritePre,FileWritePre *.\(gpg\|asc\|pgp\) set bin
+" Convert all text to encrypted text before writing
+autocmd BufWritePre,FileWritePre *.\(gpg\|asc\|pgp\) call s:GPGEncrypt()
+" Undo the encryption so we are back in the normal text, directly
+" after the file has been written.
+autocmd BufWritePost,FileWritePost *.\(gpg\|asc\|pgp\) if (exists("b:GPGEncrypted") && b:GPGEncrypted == 1) | silent u | endi
+" Switch back to normal mode for editing
+autocmd BufWritePost,FileWritePost *.\(gpg\|asc\|pgp\) set nobin
augroup END
" Section: Highlight setup {{{1
-highlight default GPGWarning term=reverse ctermfg=Yellow guifg=Yellow
-highlight default GPGError term=reverse ctermfg=Red guifg=Red
-highlight default GPGHighlightUnknownRecipient term=reverse ctermfg=Red cterm=underline guifg=Red gui=underline
+highlight default link GPGWarning WarningMsg
+highlight default link GPGError ErrorMsg
+highlight default link GPGHighlightUnknownRecipient ErrorMsg
" Section: Functions {{{1
+" Function: s:GPGInit() {{{2
+"
+" initialize the plugin
+"
+fun s:GPGInit()
+ " check if gpg-agent is allowed
+ if (!exists("g:GPGUseAgent"))
+ let g:GPGUseAgent = 1
+ endif
+
+ " check if symmetric encryption is preferred
+ if (!exists("g:GPGPreferSymmetric"))
+ let g:GPGPreferSymmetric = 0
+ endif
+
+ " check if armored files are preferred
+ if (!exists("g:GPGPreferArmor"))
+ let g:GPGPreferArmor = 0
+ endif
+
+ " determine if gnupg can use the gpg-agent
+ if (exists("$GPG_AGENT_INFO") && g:GPGUseAgent == 1)
+ if (!exists("$GPG_TTY"))
+ echohl GPGError
+ echo "The GPG_TTY is not set!"
+ echo "gpg-agent might not work."
+ echohl None
+ endif
+ let s:GPGCommand="gpg --use-agent"
+ else
+ let s:GPGCommand="gpg --no-use-agent"
+ endif
+
+ " don't use tty in gvim
+ " FIXME find a better way to avoid an error.
+ " with this solution only --use-agent will work
+ if has("gui_running")
+ let s:GPGCommand=s:GPGCommand . " --no-tty"
+ endif
+
+ " setup shell environment for unix and windows
+ let s:shellredirsave=&shellredir
+ let s:shellsave=&shell
+ if (match(&shell,"\\(cmd\\|command\\).exe") >= 0)
+ " windows specific settings
+ let s:shellredir = '>%s'
+ let s:shell = &shell
+ let s:stderrredirnull = '2>nul'
+ else
+ " unix specific settings
+ let s:shellredir = &shellredir
+ let s:shell = 'sh'
+ let s:stderrredirnull ='2>/dev/null'
+ let s:GPGCommand="LANG=C LC_ALL=C " . s:GPGCommand
+ endi
+
+ " find the supported algorithms
+ let &shellredir=s:shellredir
+ let &shell=s:shell
+ let output=system(s:GPGCommand . " --version")
+ let &shellredir=s:shellredirsave
+ let &shell=s:shellsave
+
+ let s:GPGPubkey=substitute(output, ".*Pubkey: \\(.\\{-}\\)\n.*", "\\1", "")
+ let s:GPGCipher=substitute(output, ".*Cipher: \\(.\\{-}\\)\n.*", "\\1", "")
+ let s:GPGHash=substitute(output, ".*Hash: \\(.\\{-}\\)\n.*", "\\1", "")
+ let s:GPGCompress=substitute(output, ".*Compress: \\(.\\{-}\\)\n.*", "\\1", "")
+endf
+
" Function: s:GPGDecrypt() {{{2
"
" decrypt the buffer and find all recipients of the encrypted file
"
fun s:GPGDecrypt()
- " get the filename of the current buffer
- let filename=escape(expand("%:p"), ' *?\"'."'")
-
- " clear GPGRecipients, GPGUnknownRecipients and GPGOptions
- let b:GPGRecipients=""
- let b:GPGUnknownRecipients=""
- let b:GPGOptions=""
-
- " find the recipients of the file
- let output=system(s:gpgcommand . " --decrypt --dry-run --batch " . filename)
- let start=match(output, "ID [[:xdigit:]]\\{8}", 0)
- while (start >= 0)
- let start=start+3
- let recipient=strpart(output, start, 8)
- let name=s:GPGNameToID(recipient)
- if (strlen(name) > 0)
- let b:GPGRecipients=b:GPGRecipients . name . ":"
- else
- let b:GPGUnknownRecipients=b:GPGUnknownRecipients . recipient . ":"
- echohl GPGWarning
- echo "The recipient " . recipient . " is not in your public keyring!"
- echohl None
- end
- let start=match(output, "ID [[:xdigit:]]\\{8}", start)
- endw
-
- "echo "GPGRecipients=\"" . b:GPGRecipients . "\""
-
- " Find out if the message is armored
- if (stridx(getline(1), "-----BEGIN PGP MESSAGE-----") >= 0)
- let b:GPGOptions=b:GPGOptions . "armor:"
- endi
-
- " finally decrypt the buffer content
- " since even with the --quiet option passphrase typos will be reported,
- " we must redirect stderr (using sh temporarily)
- let shsave=&sh
- let &sh='sh'
- exec "'[,']!" . s:gpgcommand . " --quiet --decrypt 2>/dev/null"
- let &sh=shsave
- if (v:shell_error) " message could not be decrypted
- silent u
- echohl GPGError
- let asd=input("Message could not be decrypted! (Press ENTER)")
- echohl None
- bwipeout
- return
- endi
+ " get the filename of the current buffer
+ let filename=escape(expand("%:p"), '\"')
+
+ " clear GPGEncrypted, GPGRecipients, GPGUnknownRecipients and GPGOptions
+ let b:GPGEncrypted=0
+ let b:GPGRecipients=""
+ let b:GPGUnknownRecipients=""
+ let b:GPGOptions=""
+
+ " find the recipients of the file
+ let &shellredir=s:shellredir
+ let &shell=s:shell
+ let output=system(s:GPGCommand . " --decrypt --dry-run --batch --no-use-agent --logger-fd 1 \"" . filename . "\"")
+ let &shellredir=s:shellredirsave
+ let &shell=s:shellsave
+
+ " check if the file is symmetric/asymmetric encrypted
+ if (match(output, "gpg: [^ ]\\+ encrypted data") >= 0)
+ " file is symmetric encrypted
+ let b:GPGEncrypted=1
+
+ let b:GPGOptions=b:GPGOptions . "symmetric:"
+
+ let cipher=substitute(output, ".*gpg: \\([^ ]\\+\\) encrypted data.*", "\\1", "")
+ if (match(s:GPGCipher, "\\<" . cipher . "\\>") >= 0)
+ let b:GPGOptions=b:GPGOptions . "cipher-algo " . cipher . ":"
+ else
+ echohl GPGWarning
+ echo "The cipher " . cipher . " is not known by the local gpg command. Using default!"
+ echo
+ echohl None
+ endi
+ elseif (match(output, "gpg: public key decryption") >= 0)
+ " file is asymmetric encrypted
+ let b:GPGEncrypted=1
+
+ let b:GPGOptions=b:GPGOptions . "encrypt:"
+
+ let start=match(output, "ID [[:xdigit:]]\\{8}")
+ while (start >= 0)
+ let start=start+3
+ let recipient=strpart(output, start, 8)
+ let name=s:GPGNameToID(recipient)
+ if (strlen(name) > 0)
+ let b:GPGRecipients=b:GPGRecipients . name . ":"
+ else
+ let b:GPGUnknownRecipients=b:GPGUnknownRecipients . recipient . ":"
+ echohl GPGWarning
+ echo "The recipient " . recipient . " is not in your public keyring!"
+ echohl None
+ end
+ let start=match(output, "ID [[:xdigit:]]\\{8}", start)
+ endw
+ elseif (match(output, "gpg: no valid OpenPGP data found") >= 0)
+ " file is not encrypted
+ let b:GPGEncrypted=0
+ echohl GPGWarning
+ echo "File is not encrypted, all GPG functions disabled!"
+ echohl None
+ return
+ endi
+
+ " check if the message is armored
+ if (stridx(getline(1), "-----BEGIN PGP MESSAGE-----") >= 0)
+ let b:GPGOptions=b:GPGOptions . "armor:"
+ endi
+
+ " finally decrypt the buffer content
+ " since even with the --quiet option passphrase typos will be reported,
+ " we must redirect stderr (using shell temporarily)
+ let &shellredir=s:shellredir
+ let &shell=s:shell
+ exec "'[,']!" . s:GPGCommand . " --quiet --decrypt " . s:stderrredirnull
+ let &shellredir=s:shellredirsave
+ let &shell=s:shellsave
+ if (v:shell_error) " message could not be decrypted
+ silent u
+ echohl GPGError
+ let asd=input("Message could not be decrypted! (Press ENTER)")
+ echohl None
+ bwipeout
+ return
+ endi
endf
" Function: s:GPGEncrypt() {{{2
@@ -140,54 +265,81 @@
" encrypts the buffer to all previous recipients
"
fun s:GPGEncrypt()
- let options=""
- let recipients=""
- let field=0
-
- " built list of options
- if (exists("b:GPGOptions"))
- let field=0
- let option=s:GetField(b:GPGOptions, ":", field)
- while (strlen(option))
- let options=options . " --" . option . " "
- let field=field+1
- let option=s:GetField(b:GPGOptions, ":", field)
- endw
- endi
-
- " check if there are unknown recipients and warn
- if (exists("b:GPGUnknownRecipients"))
- if (strlen(b:GPGUnknownRecipients) > 0)
- echohl GPGWarning
- echo "There are unknown recipients!!"
- echo "Please use GPGEditRecipients to correct!!"
- echohl None
- endi
- endi
-
- " built list of recipients
- if (exists("b:GPGRecipients"))
- let field=0
- let gpgid=s:GetField(b:GPGRecipients, ":", field)
- while (strlen(gpgid))
- let recipients=recipients . " -r " . gpgid
- let field=field+1
- let gpgid=s:GetField(b:GPGRecipients, ":", field)
- endw
- else
- echohl GPGWarning
- echo "There are no recipients!!"
- echo "Please use GPGEditRecipients to correct!!"
- echohl None
- endi
-
- " encrypt the buffer
- let shsave=&sh
- let &sh='sh'
- exec "'[,']!" . s:gpgcommand . " --quiet --no-encrypt-to --encrypt " . options . recipients . " 2>/dev/null"
- let &sh=shsave
-
- redraw!
+ " guard for unencrypted files
+ if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+ echohl GPGWarning
+ echo "File is not encrypted, all GPG functions disabled!"
+ echohl None
+ return
+ endi
+
+ let options=""
+ let recipients=""
+ let field=0
+
+ " built list of options
+ if (!exists("b:GPGOptions") || strlen(b:GPGOptions) == 0)
+ if (exists("g:GPGPreferSymmetric") && g:GPGPreferSymmetric == 1)
+ let b:GPGOptions="symmetric:"
+ else
+ let b:GPGOptions="encrypt:"
+ endi
+ if (exists("g:GPGPreferArmor") && g:GPGPreferArmor == 1)
+ let b:GPGOptions=b:GPGOptions . "armor:"
+ endi
+ endi
+ let field=0
+ let option=s:GetField(b:GPGOptions, ":", field)
+ while (strlen(option))
+ let options=options . " --" . option . " "
+ let field=field+1
+ let option=s:GetField(b:GPGOptions, ":", field)
+ endw
+
+ " check if there are unknown recipients and warn
+ if (exists("b:GPGUnknownRecipients") && strlen(b:GPGUnknownRecipients) > 0)
+ echohl GPGWarning
+ echo "There are unknown recipients!!"
+ echo "Please use GPGEditRecipients to correct!!"
+ echo
+ echohl None
+ endi
+
+ " built list of recipients
+ if (exists("b:GPGRecipients") && strlen(b:GPGRecipients) > 0)
+ let field=0
+ let gpgid=s:GetField(b:GPGRecipients, ":", field)
+ while (strlen(gpgid))
+ let recipients=recipients . " -r " . gpgid
+ let field=field+1
+ let gpgid=s:GetField(b:GPGRecipients, ":", field)
+ endw
+ else
+ if (match(b:GPGOptions, "encrypt:") >= 0)
+ echohl GPGError
+ echo "There are no recipients!!"
+ echo "Please use GPGEditRecipients to correct!!"
+ echo
+ echohl None
+ endi
+ endi
+
+ " encrypt the buffer
+ let &shellredir=s:shellredir
+ let &shell=s:shell
+ silent exec "'[,']!" . s:GPGCommand . " --quiet --no-encrypt-to " . options . recipients . " " . s:stderrredirnull
+ let &shellredir=s:shellredirsave
+ let &shell=s:shellsave
+ if (v:shell_error) " message could not be encrypted
+ silent u
+ echohl GPGError
+ let asd=input("Message could not be encrypted! File might be empty! (Press ENTER)")
+ echohl None
+ bwipeout
+ return
+ endi
+
+ "redraw!
endf
" Function: s:GPGViewRecipients() {{{2
@@ -195,39 +347,47 @@
" echo the recipients
"
fun s:GPGViewRecipients()
- if (exists("b:GPGRecipients"))
- echo 'This file has following recipients (Unknown recipients have a prepended "!"):'
- " echo the recipients
- let field=0
- let name=s:GetField(b:GPGRecipients, ":", field)
- while (strlen(name) > 0)
- let name=s:GPGIDToName(name)
- echo name
-
- let field=field+1
- let name=s:GetField(b:GPGRecipients, ":", field)
- endw
-
- " put the unknown recipients in the scratch buffer
- let field=0
- echohl GPGWarning
- let name=s:GetField(b:GPGUnknownRecipients, ":", field)
- while (strlen(name) > 0)
- let name="!" . name
- echo name
-
- let field=field+1
- let name=s:GetField(b:GPGUnknownRecipients, ":", field)
- endw
- echohl None
-
- " check if there is any known recipient
- if (strlen(s:GetField(b:GPGRecipients, ":", 0)) == 0)
- echohl GPGError
- echo 'There are no known recipients!'
- echohl None
- endi
- endi
+ " guard for unencrypted files
+ if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+ echohl GPGWarning
+ echo "File is not encrypted, all GPG functions disabled!"
+ echohl None
+ return
+ endi
+
+ if (exists("b:GPGRecipients"))
+ echo 'This file has following recipients (Unknown recipients have a prepended "!"):'
+ " echo the recipients
+ let field=0
+ let name=s:GetField(b:GPGRecipients, ":", field)
+ while (strlen(name) > 0)
+ let name=s:GPGIDToName(name)
+ echo name
+
+ let field=field+1
+ let name=s:GetField(b:GPGRecipients, ":", field)
+ endw
+
+ " put the unknown recipients in the scratch buffer
+ let field=0
+ echohl GPGWarning
+ let name=s:GetField(b:GPGUnknownRecipients, ":", field)
+ while (strlen(name) > 0)
+ let name="!" . name
+ echo name
+
+ let field=field+1
+ let name=s:GetField(b:GPGUnknownRecipients, ":", field)
+ endw
+ echohl None
+
+ " check if there is any known recipient
+ if (strlen(s:GetField(b:GPGRecipients, ":", 0)) == 0)
+ echohl GPGError
+ echo 'There are no known recipients!'
+ echohl None
+ endi
+ endi
endf
" Function: s:GPGEditRecipients() {{{2
@@ -235,149 +395,347 @@
" create a scratch buffer with all recipients to add/remove recipients
"
fun s:GPGEditRecipients()
- " only do this if it isn't already a GPGRecipients_* buffer
- if (match(bufname("%"), "GPGRecipients_") != 0 && match(bufname("%"), "\.gpg$") >= 0)
-
- " save buffer name
- let buffername=bufname("%")
- let editbuffername="GPGRecipients_" . buffername
-
- " create scratch buffer
- exe 'silent! split ' . editbuffername
-
- " check if this buffer exists
- if (bufexists(editbuffername))
- " empty the buffer
- silent normal! 1GdG
- endi
-
- " Mark the buffer as a scratch buffer
- setlocal buftype=nofile
- setlocal noswapfile
- setlocal nowrap
- setlocal nobuflisted
- setlocal nonumber
-
- " so we know for which other buffer this edit buffer is
- let b:corresponding_to=buffername
-
- " put some comments to the scratch buffer
- silent put ='GPG: ----------------------------------------------------------------------'
- silent put ='GPG: Please edit the list of recipients, one recipient per line'
- silent put ='GPG: Unknown recipients have a prepended \"!\"'
- silent put ='GPG: Lines beginning with \"GPG:\" are removed automatically'
- silent put ='GPG: Use :x or :bd to close this buffer'
- silent put ='GPG: ----------------------------------------------------------------------'
-
- " put the recipients in the scratch buffer
- let recipients=getbufvar(b:corresponding_to, "GPGRecipients")
- let field=0
-
- let name=s:GetField(recipients, ":", field)
- while (strlen(name) > 0)
- let name=s:GPGIDToName(name)
- silent put =name
-
- let field=field+1
- let name=s:GetField(recipients, ":", field)
- endw
-
- " put the unknown recipients in the scratch buffer
- let unknownRecipients=getbufvar(b:corresponding_to, "GPGUnknownRecipients")
- let field=0
- let syntaxPattern="\\(nonexistingwordinthisbuffer"
-
- let name=s:GetField(unknownRecipients, ":", field)
- while (strlen(name) > 0)
- let name="!" . name
- let syntaxPattern=syntaxPattern . "\\|" . name
- silent put =name
-
- let field=field+1
- let name=s:GetField(unknownRecipients, ":", field)
- endw
-
- let syntaxPattern=syntaxPattern . "\\)"
-
- " define highlight
- if (has("syntax") && exists("g:syntax_on"))
- exec('syntax match GPGUnknownRecipient "' . syntaxPattern . '"')
- highlight clear GPGUnknownRecipient
- highlight link GPGUnknownRecipient GPGHighlightUnknownRecipient
-
- syntax match GPGComment "^GPG:.*$"
- highlight clear GPGComment
- highlight link GPGComment Comment
- endi
-
- " delete the empty first line
- silent normal! 1Gdd
-
- " jump to the first recipient
- silent normal! 6G
-
- " add a autocommand to regenerate the recipients after a write
- augroup GPGEditRecipients
- augroup END
- execute 'au GPGEditRecipients BufHidden ' . editbuffername . ' call s:GPGFinishRecipientsBuffer()'
-
- endi
-
+ " guard for unencrypted files
+ if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+ echohl GPGWarning
+ echo "File is not encrypted, all GPG functions disabled!"
+ echohl None
+ return
+ endi
+
+ " only do this if it isn't already a GPGRecipients_* buffer
+ if (match(bufname("%"), "^\\(GPGRecipients_\\|GPGOptions_\\)") != 0 && match(bufname("%"), "\.\\(gpg\\|asc\\|pgp\\)$") >= 0)
+
+ " save buffer name
+ let buffername=bufname("%")
+ let editbuffername="GPGRecipients_" . buffername
+
+ " check if this buffer exists
+ if (!bufexists(editbuffername))
+ " create scratch buffer
+ exe 'silent! split ' . escape(editbuffername, ' *?\"'."'")
+
+ " add a autocommand to regenerate the recipients after a write
+ autocmd BufHidden,BufUnload <buffer> call s:GPGFinishRecipientsBuffer()
+ else
+ if (bufwinnr(editbuffername) >= 0)
+ " switch to scratch buffer window
+ exe 'silent! ' . bufwinnr(editbuffername) . "wincmd w"
+ else
+ " split scratch buffer window
+ exe 'silent! sbuffer ' . escape(editbuffername, ' *?\"'."'")
+
+ " add a autocommand to regenerate the recipients after a write
+ autocmd BufHidden,BufUnload <buffer> call s:GPGFinishRecipientsBuffer()
+ endi
+
+ " empty the buffer
+ silent normal! 1GdG
+ endi
+
+ " Mark the buffer as a scratch buffer
+ setlocal buftype=nofile
+ setlocal noswapfile
+ setlocal nowrap
+ setlocal nobuflisted
+ setlocal nonumber
+
+ " so we know for which other buffer this edit buffer is
+ let b:corresponding_to=buffername
+
+ " put some comments to the scratch buffer
+ silent put ='GPG: ----------------------------------------------------------------------'
+ silent put ='GPG: Please edit the list of recipients, one recipient per line'
+ silent put ='GPG: Unknown recipients have a prepended \"!\"'
+ silent put ='GPG: Lines beginning with \"GPG:\" are removed automatically'
+ silent put ='GPG: Closing this buffer commits changes'
+ silent put ='GPG: ----------------------------------------------------------------------'
+
+ " put the recipients in the scratch buffer
+ let recipients=getbufvar(b:corresponding_to, "GPGRecipients")
+ let field=0
+
+ let name=s:GetField(recipients, ":", field)
+ while (strlen(name) > 0)
+ let name=s:GPGIDToName(name)
+ silent put =name
+
+ let field=field+1
+ let name=s:GetField(recipients, ":", field)
+ endw
+
+ " put the unknown recipients in the scratch buffer
+ let unknownRecipients=getbufvar(b:corresponding_to, "GPGUnknownRecipients")
+ let field=0
+ let syntaxPattern="\\(nonexistingwordinthisbuffer"
+
+ let name=s:GetField(unknownRecipients, ":", field)
+ while (strlen(name) > 0)
+ let name="!" . name
+ let syntaxPattern=syntaxPattern . "\\|" . name
+ silent put =name
+
+ let field=field+1
+ let name=s:GetField(unknownRecipients, ":", field)
+ endw
+
+ let syntaxPattern=syntaxPattern . "\\)"
+
+ " define highlight
+ if (has("syntax") && exists("g:syntax_on"))
+ exec('syntax match GPGUnknownRecipient "' . syntaxPattern . '"')
+ highlight clear GPGUnknownRecipient
+ highlight link GPGUnknownRecipient GPGHighlightUnknownRecipient
+
+ syntax match GPGComment "^GPG:.*$"
+ highlight clear GPGComment
+ highlight link GPGComment Comment
+ endi
+
+ " delete the empty first line
+ silent normal! 1Gdd
+
+ " jump to the first recipient
+ silent normal! G
+
+ endi
endf
" Function: s:GPGFinishRecipientsBuffer() {{{2
"
" create a new recipient list from RecipientsBuffer
fun s:GPGFinishRecipientsBuffer()
- " clear GPGRecipients and GPGUnknownRecipients
- let GPGRecipients=""
- let GPGUnknownRecipients=""
-
- " delete the autocommand
- exe "au! GPGEditRecipients * " . bufname("%")
-
- let currentline=1
- let recipient=getline(currentline)
-
- " get the recipients from the scratch buffer
- while (currentline <= line("$"))
- " delete all spaces at beginning and end of the line
- " also delete a '!' at the beginning of the line
- let recipient=substitute(recipient, "^[[:space:]!]*\\(.\\{-}\\)[[:space:]]*$", "\\1", "")
- " delete comment lines
- let recipient=substitute(recipient, "^GPG:.*$", "", "")
-
- " only do this if the line is not empty
- if (strlen(recipient) > 0)
- let gpgid=s:GPGNameToID(recipient)
- if (strlen(gpgid) > 0)
- let GPGRecipients=GPGRecipients . gpgid . ":"
- else
- let GPGUnknownRecipients=GPGUnknownRecipients . recipient . ":"
- echohl GPGWarning
- echo "The recipient " . recipient . " is not in your public keyring!"
- echohl None
- end
- endi
-
- let currentline=currentline+1
- let recipient=getline(currentline)
- endw
-
- " write back the new recipient list to the corresponding buffer and mark it
- " as modified
- call setbufvar(b:corresponding_to, "GPGRecipients", GPGRecipients)
- call setbufvar(b:corresponding_to, "GPGUnknownRecipients", GPGUnknownRecipients)
- call setbufvar(b:corresponding_to, "&mod", 1)
- "echo "GPGRecipients=\"" . getbufvar(b:corresponding_to, "GPGRecipients") . "\""
-
- " check if there is any known recipient
- if (strlen(s:GetField(GPGRecipients, ":", 0)) == 0)
- echohl GPGError
- echo 'There are no known recipients!'
- echohl None
- endi
-
+ " guard for unencrypted files
+ if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+ echohl GPGWarning
+ echo "File is not encrypted, all GPG functions disabled!"
+ echohl None
+ return
+ endi
+
+ " go to buffer before doing work
+ if (bufnr("%") != expand("<abuf>"))
+ " switch to scratch buffer window
+ exe 'silent! ' . bufwinnr(expand("<afile>")) . "wincmd w"
+ endi
+
+ " clear GPGRecipients and GPGUnknownRecipients
+ let GPGRecipients=""
+ let GPGUnknownRecipients=""
+
+ " delete the autocommand
+ autocmd! * <buffer>
+
+ let currentline=1
+ let recipient=getline(currentline)
+
+ " get the recipients from the scratch buffer
+ while (currentline <= line("$"))
+ " delete all spaces at beginning and end of the line
+ " also delete a '!' at the beginning of the line
+ let recipient=substitute(recipient, "^[[:space:]!]*\\(.\\{-}\\)[[:space:]]*$", "\\1", "")
+ " delete comment lines
+ let recipient=substitute(recipient, "^GPG:.*$", "", "")
+
+ " only do this if the line is not empty
+ if (strlen(recipient) > 0)
+ let gpgid=s:GPGNameToID(recipient)
+ if (strlen(gpgid) > 0)
+ let GPGRecipients=GPGRecipients . gpgid . ":"
+ else
+ let GPGUnknownRecipients=GPGUnknownRecipients . recipient . ":"
+ echohl GPGWarning
+ echo "The recipient " . recipient . " is not in your public keyring!"
+ echohl None
+ end
+ endi
+
+ let currentline=currentline+1
+ let recipient=getline(currentline)
+ endw
+
+ " write back the new recipient list to the corresponding buffer and mark it
+ " as modified. Buffer is now for sure a encrypted buffer.
+ call setbufvar(b:corresponding_to, "GPGRecipients", GPGRecipients)
+ call setbufvar(b:corresponding_to, "GPGUnknownRecipients", GPGUnknownRecipients)
+ call setbufvar(b:corresponding_to, "&mod", 1)
+ call setbufvar(b:corresponding_to, "GPGEncrypted", 1)
+
+ " check if there is any known recipient
+ if (strlen(s:GetField(GPGRecipients, ":", 0)) == 0)
+ echohl GPGError
+ echo 'There are no known recipients!'
+ echohl None
+ endi
+endf
+
+" Function: s:GPGViewOptions() {{{2
+"
+" echo the recipients
+"
+fun s:GPGViewOptions()
+ " guard for unencrypted files
+ if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+ echohl GPGWarning
+ echo "File is not encrypted, all GPG functions disabled!"
+ echohl None
+ return
+ endi
+
+ if (exists("b:GPGOptions"))
+ echo 'This file has following options:'
+ " echo the options
+ let field=0
+ let option=s:GetField(b:GPGOptions, ":", field)
+ while (strlen(option) > 0)
+ echo option
+
+ let field=field+1
+ let option=s:GetField(b:GPGOptions, ":", field)
+ endw
+ endi
+endf
+
+" Function: s:GPGEditOptions() {{{2
+"
+" create a scratch buffer with all recipients to add/remove recipients
+"
+fun s:GPGEditOptions()
+ " guard for unencrypted files
+ if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+ echohl GPGWarning
+ echo "File is not encrypted, all GPG functions disabled!"
+ echohl None
+ return
+ endi
+
+ " only do this if it isn't already a GPGOptions_* buffer
+ if (match(bufname("%"), "^\\(GPGRecipients_\\|GPGOptions_\\)") != 0 && match(bufname("%"), "\.\\(gpg\\|asc\\|pgp\\)$") >= 0)
+
+ " save buffer name
+ let buffername=bufname("%")
+ let editbuffername="GPGOptions_" . buffername
+
+ " check if this buffer exists
+ if (!bufexists(editbuffername))
+ " create scratch buffer
+ exe 'silent! split ' . escape(editbuffername, ' *?\"'."'")
+
+ " add a autocommand to regenerate the options after a write
+ autocmd BufHidden,BufUnload <buffer> call s:GPGFinishOptionsBuffer()
+ else
+ if (bufwinnr(editbuffername) >= 0)
+ " switch to scratch buffer window
+ exe 'silent! ' . bufwinnr(editbuffername) . "wincmd w"
+ else
+ " split scratch buffer window
+ exe 'silent! sbuffer ' . escape(editbuffername, ' *?\"'."'")
+
+ " add a autocommand to regenerate the options after a write
+ autocmd BufHidden,BufUnload <buffer> call s:GPGFinishOptionsBuffer()
+ endi
+
+ " empty the buffer
+ silent normal! 1GdG
+ endi
+
+ " Mark the buffer as a scratch buffer
+ setlocal buftype=nofile
+ setlocal noswapfile
+ setlocal nowrap
+ setlocal nobuflisted
+ setlocal nonumber
+
+ " so we know for which other buffer this edit buffer is
+ let b:corresponding_to=buffername
+
+ " put some comments to the scratch buffer
+ silent put ='GPG: ----------------------------------------------------------------------'
+ silent put ='GPG: THERE IS NO CHECK OF THE ENTERED OPTIONS!'
+ silent put ='GPG: YOU NEED TO KNOW WHAT YOU ARE DOING!'
+ silent put ='GPG: IF IN DOUBT, QUICKLY EXIT USING :x OR :bd'
+ silent put ='GPG: Please edit the list of options, one option per line'
+ silent put ='GPG: Please refer to the gpg documentation for valid options'
+ silent put ='GPG: Lines beginning with \"GPG:\" are removed automatically'
+ silent put ='GPG: Closing this buffer commits changes'
+ silent put ='GPG: ----------------------------------------------------------------------'
+
+ " put the options in the scratch buffer
+ let options=getbufvar(b:corresponding_to, "GPGOptions")
+ let field=0
+
+ let option=s:GetField(options, ":", field)
+ while (strlen(option) > 0)
+ silent put =option
+
+ let field=field+1
+ let option=s:GetField(options, ":", field)
+ endw
+
+ " delete the empty first line
+ silent normal! 1Gdd
+
+ " jump to the first option
+ silent normal! G
+
+ " define highlight
+ if (has("syntax") && exists("g:syntax_on"))
+ syntax match GPGComment "^GPG:.*$"
+ highlight clear GPGComment
+ highlight link GPGComment Comment
+ endi
+ endi
+endf
+
+" Function: s:GPGFinishOptionsBuffer() {{{2
+"
+" create a new option list from OptionsBuffer
+fun s:GPGFinishOptionsBuffer()
+ " guard for unencrypted files
+ if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
+ echohl GPGWarning
+ echo "File is not encrypted, all GPG functions disabled!"
+ echohl None
+ return
+ endi
+
+ " go to buffer before doing work
+ if (bufnr("%") != expand("<abuf>"))
+ " switch to scratch buffer window
+ exe 'silent! ' . bufwinnr(expand("<afile>")) . "wincmd w"
+ endi
+
+ " clear GPGOptions and GPGUnknownOptions
+ let GPGOptions=""
+ let GPGUnknownOptions=""
+
+ " delete the autocommand
+ autocmd! * <buffer>
+
+ let currentline=1
+ let option=getline(currentline)
+
+ " get the options from the scratch buffer
+ while (currentline <= line("$"))
+ " delete all spaces at beginning and end of the line
+ " also delete a '!' at the beginning of the line
+ let option=substitute(option, "^[[:space:]!]*\\(.\\{-}\\)[[:space:]]*$", "\\1", "")
+ " delete comment lines
+ let option=substitute(option, "^GPG:.*$", "", "")
+
+ " only do this if the line is not empty
+ if (strlen(option) > 0)
+ let GPGOptions=GPGOptions . option . ":"
+ endi
+
+ let currentline=currentline+1
+ let option=getline(currentline)
+ endw
+
+ " write back the new option list to the corresponding buffer and mark it
+ " as modified
+ call setbufvar(b:corresponding_to, "GPGOptions", GPGOptions)
+ call setbufvar(b:corresponding_to, "&mod", 1)
endf
@@ -386,57 +744,61 @@
" find GPG key ID corresponding to a name
" Returns: ID for the given name
fun s:GPGNameToID(name)
- " ask gpg for the id for a name
- let output=system(s:gpgcommand . " --quiet --with-colons --fixed-list-mode --list-keys \"" . a:name . "\"")
-
- " parse the output of gpg
+ " ask gpg for the id for a name
+ let &shellredir=s:shellredir
+ let &shell=s:shell
+ let output=system(s:GPGCommand . " --quiet --with-colons --fixed-list-mode --list-keys \"" . a:name . "\"")
+ let &shellredir=s:shellredirsave
+ let &shell=s:shellsave
+
+ " parse the output of gpg
+ let pub_seen=0
+ let uid_seen=0
+ let line=0
+ let counter=0
+ let gpgids=""
+ let choices="The name \"" . a:name . "\" is ambiguous. Please select the correct key:\n"
+ let linecontent=s:GetField(output, "\n", line)
+ while (strlen(linecontent))
+ " search for the next uid
+ if (pub_seen == 1)
+ if (s:GetField(linecontent, ":", 0) == "uid")
+ if (uid_seen == 0)
+ let choices=choices . counter . ": " . s:GetField(linecontent, ":", 9) . "\n"
+ let counter=counter+1
+ let uid_seen=1
+ else
+ let choices=choices . " " . s:GetField(linecontent, ":", 9) . "\n"
+ endi
+ else
+ let uid_seen=0
let pub_seen=0
- let uid_seen=0
- let line=0
- let counter=0
- let gpgids=""
- let choices="The name \"" . a:name . "\" is ambiguous. Please select the correct key:\n"
- let linecontent=s:GetField(output, "\n", line)
- while (strlen(linecontent))
- " search for the next uid
- if (pub_seen == 1)
- if (s:GetField(linecontent, ":", 0) == "uid")
- if (uid_seen == 0)
- let choices=choices . counter . ": " . s:GetField(linecontent, ":", 9) . "\n"
- let counter=counter+1
- let uid_seen=1
- else
- let choices=choices . " " . s:GetField(linecontent, ":", 9) . "\n"
- endi
- else
- let uid_seen=0
- let pub_seen=0
- endi
- endi
-
- " search for the next pub
- if (pub_seen == 0)
- if (s:GetField(linecontent, ":", 0) == "pub")
- let gpgids=gpgids . s:GetField(linecontent, ":", 4) . ":"
- let pub_seen=1
- endi
- endi
-
- let line=line+1
- let linecontent=s:GetField(output, "\n", line)
- endw
-
- " counter > 1 means we have more than one results
- let answer=0
- if (counter > 1)
- let choices=choices . "Enter number: "
- let answer=input(choices, "0")
- while (answer == "")
- let answer=input("Enter number: ", "0")
- endw
- endi
-
- return s:GetField(gpgids, ":", answer)
+ endi
+ endi
+
+ " search for the next pub
+ if (pub_seen == 0)
+ if (s:GetField(linecontent, ":", 0) == "pub")
+ let gpgids=gpgids . s:GetField(linecontent, ":", 4) . ":"
+ let pub_seen=1
+ endi
+ endi
+
+ let line=line+1
+ let linecontent=s:GetField(output, "\n", line)
+ endw
+
+ " counter > 1 means we have more than one results
+ let answer=0
+ if (counter > 1)
+ let choices=choices . "Enter number: "
+ let answer=input(choices, "0")
+ while (answer == "")
+ let answer=input("Enter number: ", "0")
+ endw
+ endi
+
+ return s:GetField(gpgids, ":", answer)
endf
" Function: s:GPGIDToName(identity) {{{2
@@ -444,32 +806,36 @@
" find name corresponding to a GPG key ID
" Returns: Name for the given ID
fun s:GPGIDToName(identity)
- " TODO is the encryption subkey really unique?
-
- " ask gpg for the id for a name
- let output=system(s:gpgcommand . " --quiet --with-colons --fixed-list-mode --list-keys " . a:identity )
-
- " parse the output of gpg
+ " TODO is the encryption subkey really unique?
+
+ " ask gpg for the id for a name
+ let &shellredir=s:shellredir
+ let &shell=s:shell
+ let output=system(s:GPGCommand . " --quiet --with-colons --fixed-list-mode --list-keys " . a:identity )
+ let &shellredir=s:shellredirsave
+ let &shell=s:shellsave
+
+ " parse the output of gpg
+ let pub_seen=0
+ let finish=0
+ let line=0
+ let linecontent=s:GetField(output, "\n", line)
+ while (strlen(linecontent) && !finish)
+ if (pub_seen == 0) " search for the next pub
+ if (s:GetField(linecontent, ":", 0) == "pub")
+ let pub_seen=1
+ endi
+ else " search for the next uid
+ if (s:GetField(linecontent, ":", 0) == "uid")
let pub_seen=0
- let finish=0
- let line=0
- let linecontent=s:GetField(output, "\n", line)
- while (strlen(linecontent) && !finish)
- if (pub_seen == 0) " search for the next pub
- if (s:GetField(linecontent, ":", 0) == "pub")
- let pub_seen=1
- endi
- else " search for the next uid
- if (s:GetField(linecontent, ":", 0) == "uid")
- let pub_seen=0
- let finish=1
- let uid=s:GetField(linecontent, ":", 9)
- endi
- endi
-
- let line=line+1
- let linecontent=s:GetField(output, "\n", line)
- endw
+ let finish=1
+ let uid=s:GetField(linecontent, ":", 9)
+ endi
+ endi
+
+ let line=line+1
+ let linecontent=s:GetField(output, "\n", line)
+ endw
return uid
endf
@@ -480,32 +846,34 @@
" Returns: content of the field, if field doesn't exist it returns an empty
" string
fun s:GetField(line, separator, field)
- let counter=a:field
- let separatorLength=strlen(a:separator)
- let start=0
- let end=match(a:line, a:separator)
- if (end < 0)
- let end=strlen(a:line)
- endi
-
- " search for requested field
- while (start < strlen(a:line) && counter > 0)
- let counter=counter-separatorLength
- let start=end+separatorLength
- let end=match(a:line, a:separator, start)
- if (end < 0)
- let end=strlen(a:line)
- endi
- endw
-
- if (start < strlen(a:line))
- return strpart(a:line, start, end-start)
- else
- return ""
- endi
+ let counter=a:field
+ let separatorLength=strlen(a:separator)
+ let start=0
+ let end=match(a:line, a:separator)
+ if (end < 0)
+ let end=strlen(a:line)
+ endi
+
+ " search for requested field
+ while (start < strlen(a:line) && counter > 0)
+ let counter=counter-separatorLength
+ let start=end+separatorLength
+ let end=match(a:line, a:separator, start)
+ if (end < 0)
+ let end=strlen(a:line)
+ endi
+ endw
+
+ if (start < strlen(a:line))
+ return strpart(a:line, start, end-start)
+ else
+ return ""
+ endi
endf
" Section: Command definitions {{{1
com! GPGViewRecipients call s:GPGViewRecipients()
com! GPGEditRecipients call s:GPGEditRecipients()
+com! GPGViewOptions call s:GPGViewOptions()
+com! GPGEditOptions call s:GPGEditOptions()
" vim600: set foldmethod=marker:
Modified: trunk/packages/vim-scripts/plugin/taglist.vim
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/plugin/taglist.vim?rev=958&op=diff
==============================================================================
--- trunk/packages/vim-scripts/plugin/taglist.vim (original)
+++ trunk/packages/vim-scripts/plugin/taglist.vim Thu Jun 21 10:27:19 2007
@@ -1,7 +1,15 @@
" File: taglist.vim
" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
-" Version: 4.0 Beta 4
-" Last Modified: April 12, 2006
+" Version: 4.4
+" Last Modified: May 24, 2007
+" Copyright: Copyright (C) 2002-2007 Yegappan Lakshmanan
+" Permission is hereby granted to use and distribute this code,
+" 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.
"
" The "Tag List" plugin is a source code browser plugin for Vim and provides
" an overview of the structure of the programming language files and allows
@@ -9,7 +17,7 @@
" programming languages. You can visit the taglist plugin home page for more
" information:
"
-" http://www.geocities.com/yegappan/taglist
+" http://vim-taglist.sourceforge.net
"
" You can subscribe to the taglist mailing list to post your questions
" or suggestions for improvement or to report bugs. Visit the following
@@ -33,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
@@ -73,7 +81,12 @@
" Location of the exuberant ctags tool
if !exists('Tlist_Ctags_Cmd')
if executable('exuberant-ctags')
+ " On Debian Linux, exuberant ctags is installed
+ " as exuberant-ctags
let Tlist_Ctags_Cmd = 'exuberant-ctags'
+ elseif executable(' exctags')
+ " On Free-BSD, exuberant ctags is installed as exctags
+ let Tlist_Ctags_ Cmd = 'exctags'
elseif executable('ctags')
let Tlist_Ctags_Cmd = 'ctags'
elseif executable('ctags.exe')
@@ -252,20 +265,20 @@
autocmd BufFilePost __Tag_List__ call s:Tlist_Vim_Session_Load()
" Define the user commands to manage the taglist window
- command! -nargs=0 TlistToggle call s:Tlist_Window_Toggle()
- command! -nargs=0 TlistOpen call s:Tlist_Window_Open()
+ command! -nargs=0 -bar TlistToggle call s:Tlist_Window_Toggle()
+ command! -nargs=0 -bar TlistOpen call s:Tlist_Window_Open()
" For backwards compatiblity define the Tlist command
- command! -nargs=0 Tlist TlistToggle
+ command! -nargs=0 -bar Tlist TlistToggle
command! -nargs=+ -complete=file TlistAddFiles
\ call s:Tlist_Add_Files(<f-args>)
command! -nargs=+ -complete=dir TlistAddFilesRecursive
\ call s:Tlist_Add_Files_Recursive(<f-args>)
- command! -nargs=0 TlistClose call s:Tlist_Window_Close()
- command! -nargs=0 TlistUpdate call s:Tlist_Update_Current_File()
- command! -nargs=0 TlistHighlightTag call s:Tlist_Window_Highlight_Tag(
+ command! -nargs=0 -bar TlistClose call s:Tlist_Window_Close()
+ command! -nargs=0 -bar TlistUpdate call s:Tlist_Update_Current_File()
+ command! -nargs=0 -bar TlistHighlightTag call s:Tlist_Window_Highlight_Tag(
\ fnamemodify(bufname('%'), ':p'), line('.'), 2, 1)
" For backwards compatiblity define the TlistSync command
- command! -nargs=0 TlistSync TlistHighlightTag
+ command! -nargs=0 -bar TlistSync TlistHighlightTag
command! -nargs=* -complete=buffer TlistShowPrototype
\ echo Tlist_Get_Tag_Prototype_By_Line(<f-args>)
command! -nargs=* -complete=buffer TlistShowTag
@@ -274,41 +287,52 @@
\ call s:Tlist_Session_Load(<q-args>)
command! -nargs=* -complete=file TlistSessionSave
\ call s:Tlist_Session_Save(<q-args>)
- command! TlistLock let Tlist_Auto_Update=0
- command! TlistUnlock let Tlist_Auto_Update=1
+ command! -bar TlistLock let Tlist_Auto_Update=0
+ command! -bar TlistUnlock let Tlist_Auto_Update=1
" Commands for enabling/disabling debug and to display debug messages
- command! -nargs=? -complete=file TlistDebug
+ command! -nargs=? -complete=file -bar TlistDebug
\ call s:Tlist_Debug_Enable(<q-args>)
- command! -nargs=0 TlistUndebug call s:Tlist_Debug_Disable()
- command! -nargs=0 TlistMessages echo s:tlist_msg
+ command! -nargs=0 -bar TlistUndebug call s:Tlist_Debug_Disable()
+ command! -nargs=0 -bar TlistMessages call s:Tlist_Debug_Show()
" Define autocommands to autoload the taglist plugin when needed.
" Trick to get the current script ID
map <SID>xx <SID>xx
- let s:sid = substitute(maparg('<SID>xx'), '<SNR>\(\d\+_\)xx$', '\1', '')
+ let s:tlist_sid = substitute(maparg('<SID>xx'), '<SNR>\(\d\+_\)xx$',
+ \ '\1', '')
unmap <SID>xx
- exe 'autocmd FuncUndefined *' . s:sid . 'Tlist_* source ' .
+ exe 'autocmd FuncUndefined *' . s:tlist_sid . 'Tlist_* source ' .
\ escape(expand('<sfile>'), ' ')
- exe 'autocmd FuncUndefined *' . s:sid . 'Tlist_Window_* source ' .
+ exe 'autocmd FuncUndefined *' . s:tlist_sid . 'Tlist_Window_* source ' .
\ escape(expand('<sfile>'), ' ')
- exe 'autocmd FuncUndefined *' . s:sid . 'Tlist_Menu_* source ' .
+ exe 'autocmd FuncUndefined *' . s:tlist_sid . 'Tlist_Menu_* source ' .
\ escape(expand('<sfile>'), ' ')
exe 'autocmd FuncUndefined Tlist_* source ' .
\ escape(expand('<sfile>'), ' ')
exe 'autocmd FuncUndefined TagList_* source ' .
\ escape(expand('<sfile>'), ' ')
- unlet! s:sid
-
let loaded_taglist = 'fast_load_done'
+
+ if g:Tlist_Show_Menu && has('gui_running')
+ call s:Tlist_Menu_Init()
+ endif
" restore 'cpo'
let &cpo = s:cpo_save
finish
endif
+
+if !exists('s:tlist_sid')
+ " Two or more versions of taglist plugin are installed. Don't
+ " load this version of the plugin.
+ finish
+endif
+
+unlet! s:tlist_sid
if loaded_taglist != 'fast_load_done'
" restore 'cpo'
@@ -468,7 +492,7 @@
"------------------- end of language specific options --------------------
" Vim window size is changed by the taglist plugin or not
-let s:tlist_winsize_chgd = 0
+let s:tlist_winsize_chgd = -1
" Taglist window is maximized or not
let s:tlist_win_maximized = 0
" Name of files in the taglist
@@ -613,6 +637,24 @@
let s:tlist_debug_file = ''
endfunction
+" Tlist_Debug_Show
+" Display the taglist debug messages in a new window
+function! s:Tlist_Debug_Show()
+ if s:tlist_msg == ''
+ call s:Tlist_Warning_Msg('Taglist: No debug messages')
+ return
+ endif
+
+ " Open a new window to display the taglist debug messages
+ new taglist_debug.txt
+ " Delete all the lines (if the buffer already exists)
+ silent! %delete _
+ " Add the messages
+ silent! put =s:tlist_msg
+ " Move the cursor to the first line
+ normal! gg
+endfunction
+
" Tlist_Log_Msg
" Log the supplied debug message along with the time
function! s:Tlist_Log_Msg(msg)
@@ -649,7 +691,7 @@
" Tlist_Get_File_Index()
" Return the index of the specified filename
function! s:Tlist_Get_File_Index(fname)
- if s:tlist_file_count == 0
+ if s:tlist_file_count == 0 || a:fname == ''
return -1
endif
@@ -1244,20 +1286,22 @@
" Horizontal window height
let win_size = g:Tlist_WinHeight
else
- " Open a vertically split window. Increase the window size, if
- " needed, to accomodate the new window
- if g:Tlist_Inc_Winwidth &&
- \ &columns < (80 + g:Tlist_WinWidth)
- " Save the original window position
- let s:tlist_pre_winx = getwinposx()
- let s:tlist_pre_winy = getwinposy()
-
- " one extra column is needed to include the vertical split
- let &columns= &columns + g:Tlist_WinWidth + 1
-
- let s:tlist_winsize_chgd = 1
- else
- let s:tlist_winsize_chgd = 0
+ if s:tlist_winsize_chgd == -1
+ " Open a vertically split window. Increase the window size, if
+ " needed, to accomodate the new window
+ if g:Tlist_Inc_Winwidth &&
+ \ &columns < (80 + g:Tlist_WinWidth)
+ " Save the original window position
+ let s:tlist_pre_winx = getwinposx()
+ let s:tlist_pre_winy = getwinposy()
+
+ " one extra column is needed to include the vertical split
+ let &columns= &columns + g:Tlist_WinWidth + 1
+
+ let s:tlist_winsize_chgd = 1
+ else
+ let s:tlist_winsize_chgd = 0
+ endif
endif
if g:Tlist_Use_Right_Window
@@ -1315,6 +1359,26 @@
endif
endfunction
+" Tlist_Ballon_Expr
+" When the mouse cursor is over a tag in the taglist window, display the
+" tag prototype (balloon)
+function! Tlist_Ballon_Expr()
+ " Get the file index
+ let fidx = s:Tlist_Window_Get_File_Index_By_Linenum(v:beval_lnum)
+ if fidx == -1
+ return ''
+ endif
+
+ " Get the tag output line for the current tag
+ let tidx = s:Tlist_Window_Get_Tag_Index(fidx, v:beval_lnum)
+ if tidx == 0
+ return ''
+ endif
+
+ " Get the tag search pattern and display it
+ return s:Tlist_Get_Tag_Prototype(fidx, tidx)
+endfunction
+
" Tlist_Window_Check_Width
" Check the width of the taglist window. For horizontally split windows, the
" 'winfixheight' option is used to fix the height of the window. For
@@ -1341,10 +1405,42 @@
endif
endfunction
+" Tlist_Window_Exit_Only_Window
+" If the 'Tlist_Exit_OnlyWindow' option is set, then exit Vim if only the
+" taglist window is present.
+function! s:Tlist_Window_Exit_Only_Window()
+ " Before quitting Vim, delete the taglist buffer so that
+ " the '0 mark is correctly set to the previous buffer.
+ if v:version < 700
+ if winbufnr(2) == -1
+ bdelete
+ quit
+ endif
+ else
+ if winbufnr(2) == -1
+ if tabpagenr('$') == 1
+ " Only one tag page is present
+ bdelete
+ quit
+ else
+ " More than one tab page is present. Close only the current
+ " tab page
+ close
+ endif
+ endif
+ endif
+endfunction
+
" Tlist_Window_Init
" Set the default options for the taglist window
function! s:Tlist_Window_Init()
call s:Tlist_Log_Msg('Tlist_Window_Init()')
+
+ " The 'readonly' option should not be set for the taglist buffer.
+ " If Vim is started as "view/gview" or if the ":view" command is
+ " used, then the 'readonly' option is set for all the buffers.
+ " Unset it for the taglist buffer
+ setlocal noreadonly
" Set the taglist buffer filetype to taglist
setlocal filetype=taglist
@@ -1439,16 +1535,35 @@
set winfixwidth
endif
+ " Setup balloon evaluation to display tag prototype
+ if v:version >= 700 && has('balloon_eval')
+ setlocal balloonexpr=Tlist_Ballon_Expr()
+ set ballooneval
+ endif
+
" Setup the cpoptions properly for the maps to work
let old_cpoptions = &cpoptions
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> s :call <SID>Tlist_Change_Sort(1, 1, '')<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>
nnoremap <buffer> <silent> - :silent! foldclose<CR>
nnoremap <buffer> <silent> * :silent! %foldopen!<CR>
@@ -1468,15 +1583,27 @@
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(1, 1, '')<CR>
+ \ <C-o>:call <SID>Tlist_Change_Sort('cmd', 'toggle', '')<CR>
inoremap <buffer> <silent> + <C-o>:silent! foldopen<CR>
inoremap <buffer> <silent> - <C-o>:silent! foldclose<CR>
inoremap <buffer> <silent> * <C-o>:silent! %foldopen!<CR>
@@ -1505,7 +1632,8 @@
" 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
@@ -1531,17 +1659,15 @@
" Adjust the Vim window width when taglist window is closed
autocmd BufUnload __Tag_List__ call s:Tlist_Post_Close_Cleanup()
- " Close the fold for this buffer when it's not visible in any window
+ " Close the fold for this buffer when leaving the buffer
if g:Tlist_File_Fold_Auto_Close
- autocmd BufWinLeave * silent
- \ call s:Tlist_Window_Close_File_Fold(expand('<afile>:p'))
+ autocmd BufEnter * silent
+ \ call s:Tlist_Window_Open_File_Fold(expand('<abuf>'))
endif
" Exit Vim itself if only the taglist window is present (optional)
if g:Tlist_Exit_OnlyWindow
- " Before quitting Vim, delete the taglist buffer so that
- " the '0 mark is correctly set to the previous buffer.
- autocmd BufEnter __Tag_List__ nested if winbufnr(2) == -1 |
- \ bdelete | quit | endif
+ autocmd BufEnter __Tag_List__ nested
+ \ call s:Tlist_Window_Exit_Only_Window()
endif
if s:tlist_app_name != "winmanager" &&
\ !g:Tlist_Process_File_Always &&
@@ -1670,7 +1796,7 @@
if s:tlist_app_name != "winmanager"
if g:Tlist_Use_Horiz_Window || g:Tlist_Inc_Winwidth == 0 ||
- \ s:tlist_winsize_chgd == 0 ||
+ \ s:tlist_winsize_chgd != 1 ||
\ &columns < (80 + g:Tlist_WinWidth)
" No need to adjust window width if using horizontally split taglist
" window or if columns is less than 101 or if the user chose not to
@@ -1688,6 +1814,8 @@
let &columns= &columns - (g:Tlist_WinWidth + 1)
endif
endif
+
+ let s:tlist_winsize_chgd = -1
" Reset taglist state variables
if s:tlist_app_name == "winmanager"
@@ -1836,17 +1964,17 @@
endwhile
if s:tlist_{fidx}_tag_count == 0
- put =''
+ if g:Tlist_Compact_Format == 0
+ silent! put =''
+ endif
endif
let s:tlist_{fidx}_end = line('.') - 1
" Create a fold for the entire file
exe s:tlist_{fidx}_start . ',' . s:tlist_{fidx}_end . 'fold'
- if !g:Tlist_File_Fold_Auto_Close
- exe 'silent! ' . s:tlist_{fidx}_start . ',' .
- \ s:tlist_{fidx}_end . 'foldopen!'
- endif
+ exe 'silent! ' . s:tlist_{fidx}_start . ',' .
+ \ s:tlist_{fidx}_end . 'foldopen!'
" Goto the starting line for this file,
exe s:tlist_{fidx}_start
@@ -2116,6 +2244,13 @@
let ctags_cmd = g:Tlist_Ctags_Cmd . ctags_args
let ctags_cmd = ctags_cmd . ' "' . a:filename . '"'
+ if &shellxquote == '"'
+ " Double-quotes within double-quotes will not work in the
+ " command-line.If the 'shellxquote' option is set to double-quotes,
+ " then escape the double-quotes in the ctags command-line.
+ let ctags_cmd = escape(ctags_cmd, '"')
+ endif
+
" In Windows 95, if not using cygwin, disable the 'shellslash'
" option. Otherwise, this will cause problems when running the
" ctags command.
@@ -2124,6 +2259,25 @@
set noshellslash
endif
+ if has('win32') && !has('win32unix') && !has('win95')
+ \ && (&shell =~ 'cmd.exe')
+ " Windows does not correctly deal with commands that have more than 1
+ " set of double quotes. It will strip them all resulting in:
+ " 'C:\Program' is not recognized as an internal or external command
+ " operable program or batch file. To work around this, place the
+ " command inside a batch file and call the batch file.
+ " Do this only on Win2K, WinXP and above.
+ " Contributed by: David Fishburn.
+ let s:taglist_tempfile = fnamemodify(tempname(), ':h') .
+ \ '\taglist.cmd'
+ exe 'redir! > ' . s:taglist_tempfile
+ silent echo ctags_cmd
+ redir END
+
+ call s:Tlist_Log_Msg('Cmd inside batch file: ' . ctags_cmd)
+ let ctags_cmd = '"' . s:taglist_tempfile . '"'
+ endif
+
call s:Tlist_Log_Msg('Cmd: ' . ctags_cmd)
" Run ctags and get the tag list
@@ -2132,6 +2286,11 @@
" Restore the value of the 'shellslash' option.
if has('win95') && !has('win32unix')
let &shellslash = old_shellslash
+ endif
+
+ if exists('s:taglist_tempfile')
+ " Delete the temporary cmd file created on MS-Windows
+ call delete(s:taglist_tempfile)
endif
" Handle errors
@@ -2144,6 +2303,9 @@
return fidx
endif
+ " Store the modification time for the file
+ let s:tlist_{fidx}_mtime = getftime(a:filename)
+
" No tags for current file
if cmd_output == ''
call s:Tlist_Log_Msg('No tags defined in ' . a:filename)
@@ -2151,9 +2313,6 @@
endif
call s:Tlist_Log_Msg('Generated tags information for ' . a:filename)
-
- " Store the modification time for the file
- let s:tlist_{fidx}_mtime = getftime(a:filename)
if v:version > 601
" The following script local variables are used by the
@@ -2198,7 +2357,7 @@
let ttype = s:Tlist_Extract_Tagtype(one_line)
" Make sure the tag type is a valid and supported one
- if ttype == '' || stridx(s:ctags_flags, ttype) == -1
+ if ttype == '' || stridx(ctags_flags, ttype) == -1
" Line is not in proper tags format or Tag type is not
" supported
continue
@@ -2374,6 +2533,16 @@
endif
endfunction
+" Tlist_Window_Mark_File_Window
+" Mark the current window as the file window to use when jumping to a tag.
+" Only if the current window is a non-plugin, non-preview and non-taglist
+" window
+function! s:Tlist_Window_Mark_File_Window()
+ if getbufvar('%', '&buftype') == '' && !&previewwindow
+ let w:tlist_file_window = "yes"
+ endif
+endfunction
+
" Tlist_Window_Open
" Open and refresh the taglist window
function! s:Tlist_Window_Open()
@@ -2398,9 +2567,9 @@
let curbuf_ftype = getbufvar('%', '&filetype')
let cur_lnum = line('.')
- " Mark the current window as the desired window to open a file
- " when a tag is selected
- let w:tlist_file_window = "yes"
+ " Mark the current window as the desired window to open a file when a tag
+ " is selected.
+ call s:Tlist_Window_Mark_File_Window()
" Open the taglist window
call s:Tlist_Window_Create()
@@ -2754,14 +2923,14 @@
" Tlist_Change_Sort()
" Change the sort order of the tag listing
-" caller == 1, taglist window
-" caller == 2, taglist menu
-" action == 1, toggle sort from name to order and vice versa
-" action == 2, set the sort order to sort_type
+" caller == 'cmd', command used in the taglist window
+" caller == 'menu', taglist menu
+" action == 'toggle', toggle sort from name to order and vice versa
+" action == 'set', set the sort order to sort_type
function! s:Tlist_Change_Sort(caller, action, sort_type)
call s:Tlist_Log_Msg('Tlist_Change_Sort (caller = ' . a:caller .
\ ', action = ' . a:action . ', sort_type = ' . a:sort_type . ')')
- if a:caller == 1
+ if a:caller == 'cmd'
let fidx = s:Tlist_Window_Get_File_Index_By_Linenum(line('.'))
if fidx == -1
return
@@ -2769,14 +2938,14 @@
" Remove the previous highlighting
match none
- elseif a:caller == 2
+ elseif a:caller == 'menu'
let fidx = s:Tlist_Get_File_Index(fnamemodify(bufname('%'), ':p'))
if fidx == -1
return
endif
endif
- if a:action == 1
+ if a:action == 'toggle'
let sort_type = s:tlist_{fidx}_sort_type
" Toggle the sort order from 'name' to 'order' and vice versa
@@ -2792,12 +2961,14 @@
" Invalidate the tags listed for this file
let s:tlist_{fidx}_valid = 0
- if a:caller == 1
+ if a:caller == 'cmd'
" Save the current line for later restoration
let curline = '\V\^' . getline('.') . '\$'
call s:Tlist_Window_Refresh_File(s:tlist_{fidx}_filename,
\ s:tlist_{fidx}_filetype)
+
+ exe s:tlist_{fidx}_start . ',' . s:tlist_{fidx}_end . 'foldopen!'
" Go back to the cursor line before the tag list is sorted
call search(curline, 'w')
@@ -2850,6 +3021,8 @@
call s:Tlist_Window_Refresh_File(s:tlist_{fidx}_filename,
\ s:tlist_{fidx}_filetype)
+ exe s:tlist_{fidx}_start . ',' . s:tlist_{fidx}_end . 'foldopen!'
+
" Go back to the tag line before the list is updated
call search(curline, 'w')
endfunction
@@ -2922,18 +3095,75 @@
" 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
@@ -2946,9 +3176,10 @@
let fwin_num = i
break
endif
- if first_usable_win == 0 && bufname(bnum) != g:TagList_title &&
- \ getbufvar(bnum, '&buftype') == ''
- " First non-taglist and a non-plugin window
+ if first_usable_win == 0 &&
+ \ getbufvar(bnum, '&buftype') == '' &&
+ \ !getwinvar(i, '&previewwindow')
+ " First non-taglist, non-plugin and non-preview window
let first_usable_win = i
endif
let i = i + 1
@@ -2967,7 +3198,7 @@
" 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, ' ')
@@ -3004,13 +3235,22 @@
endif
endif
" Mark the window, so that it can be reused.
- let w:tlist_file_window = "yes"
+ call s:Tlist_Window_Mark_File_Window()
else
+ if v:version >= 700
+ " If the file is opened in more than one window, then check
+ " whether the last accessed window has the selected file.
+ " If it does, then use that window.
+ let lastwin_bufnum = winbufnr(winnr('#'))
+ if bufnr(a:filename) == lastwin_bufnum
+ let winnum = winnr('#')
+ endif
+ endif
exe winnum . 'wincmd w'
" 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
@@ -3034,7 +3274,7 @@
" 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'
@@ -3058,11 +3298,13 @@
" 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] == '"'
@@ -3178,11 +3420,9 @@
let right = s:tlist_{a:fidx}_tag_count
if sort_type == 'order'
- " Tag list sorted by order, do a binary search comparing the line
- " numbers and pick a tag entry that contains the current line and
- " highlight it. The idea behind this function is taken from the
- " ctags.vim script (by Alexey Marinichev) available at the Vim online
- " website.
+ " Tags sorted by order, use a binary search.
+ " The idea behind this function is taken from the ctags.vim script (by
+ " Alexey Marinichev) available at the Vim online website.
" If the current line is the less than the first tag, then no need to
" search
@@ -3208,7 +3448,12 @@
endif
endwhile
else
- " sorted by name, brute force method (Dave Eggum)
+ " Tags sorted by name, use a linear search. (contributed by Dave
+ " Eggum).
+ " Look for a tag with a line number less than or equal to the supplied
+ " line number. If multiple tags are found, then use the tag with the
+ " line number closest to the supplied line number. IOW, use the tag
+ " with the highest line number.
let closest_lnum = 0
let final_left = 0
while left <= right
@@ -3538,9 +3783,7 @@
endif
" Mark the current window as the file window
- if bufname('%') !~ g:TagList_title
- let w:tlist_file_window = "yes"
- endif
+ call s:Tlist_Window_Mark_File_Window()
" Source the session file
exe 'source ' . sessionfile
@@ -3766,26 +4009,16 @@
" When a buffer is deleted, remove the file from the taglist
autocmd BufDelete * silent call s:Tlist_Buffer_Removed(expand('<afile>:p'))
-" Tlist_Window_Close_File_Fold
-" Close the fold for the specified file
-function! s:Tlist_Window_Close_File_Fold(filename)
- call s:Tlist_Log_Msg('Tlist_Window_Close_File_Fold (' . a:filename . ')')
- " Make sure a valid filename is supplied
- if a:filename == ''
- return
- endif
+" 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(acmd_bufnr)
+ call s:Tlist_Log_Msg('Tlist_Window_Open_File_Fold (' . a:acmd_bufnr . ')')
" Make sure the taglist window is present
let winnum = bufwinnr(g:TagList_title)
if winnum == -1
call s:Tlist_Warning_Msg('Taglist: Error - Taglist window is not open')
- return
- endif
-
- " Get tag list index of the specified file
- let fidx = s:Tlist_Get_File_Index(a:filename)
- if fidx == -1
- " File not present in the taglist window
return
endif
@@ -3797,21 +4030,29 @@
let in_taglist_window = 0
endif
+ if in_taglist_window
+ " When entering the taglist window, no need to update the folds
+ return
+ endif
+
" Go to the taglist window
if !in_taglist_window
call s:Tlist_Exe_Cmd_No_Acmds(winnum . 'wincmd w')
endif
- " Save the cursor position
- let save_lnum = line('.')
-
- " Perform the requested action on the file
- " Close the fold for the file
- exe "silent! " . s:tlist_{fidx}_start . "," .
- \ s:tlist_{fidx}_end . "foldclose"
-
- " Move the cursor to the original location
- exe save_lnum
+ " Close all the folds
+ silent! %foldclose
+
+ " Get tag list index of the specified file
+ let fname = fnamemodify(bufname(a:acmd_bufnr + 0), ':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
if !in_taglist_window
@@ -3824,21 +4065,21 @@
" Open the window only when files present in any of the Vim windows support
" tags.
function! s:Tlist_Window_Check_Auto_Open()
- let open = 0
+ let open_window = 0
let i = 1
let buf_num = winbufnr(i)
while buf_num != -1
let filename = fnamemodify(bufname(buf_num), ':p')
if !s:Tlist_Skip_File(filename, getbufvar(buf_num, '&filetype'))
- let open = 1
+ let open_window = 1
break
endif
let i = i + 1
let buf_num = winbufnr(i)
endwhile
- if open
+ if open_window
call s:Tlist_Window_Toggle()
endif
endfunction
@@ -3849,18 +4090,18 @@
" Add the menu
anoremenu <silent> T&ags.Refresh\ menu :call <SID>Tlist_Menu_Refresh()<CR>
anoremenu <silent> T&ags.Sort\ menu\ by.Name
- \ :call <SID>Tlist_Change_Sort(2, 2, 'name')<CR>
+ \ :call <SID>Tlist_Change_Sort('menu', 'set', 'name')<CR>
anoremenu <silent> T&ags.Sort\ menu\ by.Order
- \ :call <SID>Tlist_Change_Sort(2, 2, 'order')<CR>
+ \ :call <SID>Tlist_Change_Sort('menu', 'set', 'order')<CR>
anoremenu T&ags.-SEP1- :
if &mousemodel =~ 'popup'
anoremenu <silent> PopUp.T&ags.Refresh\ menu
\ :call <SID>Tlist_Menu_Refresh()<CR>
anoremenu <silent> PopUp.T&ags.Sort\ menu\ by.Name
- \ :call <SID>Tlist_Change_Sort(2, 2, 'name')<CR>
+ \ :call <SID>Tlist_Change_Sort('menu', 'set', 'name')<CR>
anoremenu <silent> PopUp.T&ags.Sort\ menu\ by.Order
- \ :call <SID>Tlist_Change_Sort(2, 2, 'order')<CR>
+ \ :call <SID>Tlist_Change_Sort('menu', 'set', 'order')<CR>
anoremenu PopUp.T&ags.-SEP1- :
endif
endfunction
@@ -4007,6 +4248,7 @@
" Remove the tags menu
if a:clear_menu
call s:Tlist_Menu_Remove_File()
+
endif
" Skip buffers with 'buftype' set to nofile, nowrite, quickfix or help
@@ -4035,6 +4277,12 @@
if fidx == -1
return
endif
+ endif
+
+ let fname = escape(fnamemodify(bufname('%'), ':t'), '.')
+ if fname != ''
+ exe 'anoremenu T&ags.' . fname . ' <Nop>'
+ anoremenu T&ags.-SEP2- :
endif
if !s:tlist_{fidx}_tag_count
Modified: trunk/packages/vim-scripts/plugin/vcscommand.vim
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/plugin/vcscommand.vim?rev=958&op=diff
==============================================================================
--- trunk/packages/vim-scripts/plugin/vcscommand.vim (original)
+++ trunk/packages/vim-scripts/plugin/vcscommand.vim Thu Jun 21 10:27:19 2007
@@ -2,10 +2,28 @@
"
" Vim plugin to assist in working with files under control of CVS or SVN.
"
-" Last Change:
-" Version: Beta 10
+" Version: Beta 18
" Maintainer: Bob Hiestand <bob.hiestand at gmail.com>
-" License: This file is placed in the public domain.
+" License:
+" Copyright (c) 2007 Bob Hiestand
+"
+" Permission is hereby granted, free of charge, to any person obtaining a copy
+" of this software and associated documentation files (the "Software"), to
+" deal in the Software without restriction, including without limitation the
+" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+" sell copies of the Software, and to permit persons to whom the Software is
+" furnished to do so, subject to the following conditions:
+"
+" The above copyright notice and this permission notice shall be included in
+" all copies or substantial portions of the Software.
+"
+" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+" IN THE SOFTWARE.
"
" Section: Documentation {{{1
"
@@ -46,6 +64,8 @@
" message. The commit can be abandoned if the log message
" buffer is deleted or wiped before being written.
"
+" VCSDelete Deletes the current file and removes it from source control.
+"
" VCSDiff With no arguments, this displays the differences between
" the current file and its parent version under source
" control in a new scratch buffer.
@@ -64,6 +84,9 @@
" VCSGotoOriginal Jumps to the source buffer if the current buffer is a VCS
" scratch buffer. If VCSGotoOriginal[!] is used, remove all
" VCS scratch buffers associated with the original file.
+"
+" VCSInfo Displays extended information about the current file in a
+" new scratch buffer.
"
" VCSLock Locks the current file in order to prevent other users from
" concurrently modifying it. The exact semantics of this
@@ -125,9 +148,11 @@
" <Leader>ca VCSAdd
" <Leader>cn VCSAnnotate
" <Leader>cc VCSCommit
+" <Leader>cD VCSDelete
" <Leader>cd VCSDiff
" <Leader>cg VCSGotoOriginal
" <Leader>cG VCSGotoOriginal!
+" <Leader>ci VCSInfo
" <Leader>cl VCSLog
" <Leader>cL VCSLock
" <Leader>cr VCSReview
@@ -157,6 +182,14 @@
" VCSCommandDiffSplit
" This variable overrides the VCSCommandSplit variable, but only for buffers
" created with VCSVimDiff.
+"
+" VCSCommandDisableMappings
+" This variable, if set to a non-zero value, prevents the default command
+" mappings from being set.
+"
+" VCSCommandDisableExtensionMappings
+" This variable, if set to a non-zero value, prevents the default command
+" mappings from being set for commands specific to an individual VCS.
"
" VCSCommandEdit
" This variable controls whether to split the current window to display a
@@ -219,12 +252,6 @@
" VCSBufferSetup This event is fired just after VCS buffer setup
" occurs, if enabled.
"
-" VCSLoadExtensions This event is fired just before the
-" VCSPluginFinish event. It is intended to be
-" used only by VCS extensions to register
-" themselves with VCSCommand if they are sourced
-" first.
-"
" VCSPluginInit This event is fired when the VCSCommand plugin
" first loads.
"
@@ -276,6 +303,14 @@
" Section: Utility functions {{{1
+" Function: s:ReportError(mapping) {{{2
+" Displays the given error in a consistent faction. This is intended to be
+" invoked from a catch statement.
+
+function! s:ReportError(error)
+ echohl WarningMsg|echomsg 'VCSCommand: ' . a:error|echohl None
+endfunction
+
" Function: s:ExecuteExtensionMapping(mapping) {{{2
" Invokes the appropriate extension mapping depending on the type of the
" current buffer.
@@ -292,79 +327,53 @@
silent execute 'normal' ':' . s:extendedMappings[vcsType][a:mapping] . "\<CR>"
endfunction
-" Function: s:ExecuteVCSCommand(command, buffer, argList) {{{2
-" Calls the indicated plugin-specific VCS command on the indicated buffer.
+" Function: s:ExecuteVCSCommand(command, argList) {{{2
+" Calls the indicated plugin-specific VCS command on the current buffer.
" Returns: buffer number of resulting output scratch buffer, or -1 if an error
" occurs.
-function! s:ExecuteVCSCommand(command, buffer, argList)
+function! s:ExecuteVCSCommand(command, argList, verifyBuffer)
try
- let vcsType = VCSCommandGetVCSType(a:buffer)
+ let buffer = bufnr('%')
+
+ let vcsType = VCSCommandGetVCSType(buffer)
if !has_key(s:plugins, vcsType)
throw 'Unknown VCS type: ' . vcsType
endif
+
+ let originalBuffer = VCSCommandGetOriginalBuffer(buffer)
+ let bufferName = bufname(originalBuffer)
+
+ " It is already known that the directory is under VCS control. No further
+ " checks are needed. Otherwise, perform some basic sanity checks to avoid
+ " VCS-specific error messages from confusing things.
+ if !isdirectory(bufferName)
+ if !filereadable(bufferName)
+ throw 'No such file ' . bufferName
+ endif
+ if(a:verifyBuffer)
+ if isdirectory(bufferName)
+ endif
+ let revision = VCSCommandGetRevision()
+ if revision == ''
+ throw 'Unable to obtain version information.'
+ elseif revision == 'Unknown'
+ throw 'Item not under source control'
+ elseif revision == 'New'
+ throw 'Operation not available on newly-added item.'
+ endif
+ endif
+ endif
+
let functionMap = s:plugins[vcsType]
if !has_key(functionMap, a:command)
throw 'Command ''' . a:command . ''' not implemented for ' . vcsType
endif
return functionMap[a:command](a:argList)
catch
- echohl WarningMsg|echomsg v:exception|echohl None
+ call s:ReportError(v:exception)
return -1
endtry
-endfunction
-
-" Function: s:CreateCommandBuffer(cmd, cmdName, originalBuffer, statusText) {{{2
-" Creates a new scratch buffer and captures the output from execution of the
-" given command. The name of the scratch buffer is returned.
-
-function! s:CreateCommandBuffer(cmd, cmdName, originalBuffer, statusText)
- let output = system(a:cmd)
-
- " HACK: if line endings in the repository have been corrupted, the output
- " of the command will be confused.
- let output = substitute(output, "\r", '', 'g')
-
- " HACK: CVS diff command does not return proper error codes
- if v:shell_error && (a:cmdName != 'diff' || getbufvar(a:originalBuffer, 'VCSCommandVCSType') != 'CVS')
- if strlen(output) == 0
- throw 'Version control command failed'
- else
- let output = substitute(output, '\n', ' ', 'g')
- throw 'Version control command failed: ' . output
- endif
- endif
- if strlen(output) == 0
- " Handle case of no output. In this case, it is important to check the
- " file status, especially since cvs edit/unedit may change the attributes
- " of the file with no visible output.
-
- checktime
- return 0
- endif
-
- call s:EditFile(a:cmdName, a:originalBuffer, a:statusText)
-
- silent 0put=output
-
- " The last command left a blank line at the end of the buffer. If the
- " last line is folded (a side effect of the 'put') then the attempt to
- " remove the blank line will kill the last fold.
- "
- " This could be fixed by explicitly detecting whether the last line is
- " within a fold, but I prefer to simply unfold the result buffer altogether.
-
- if has('folding')
- normal zR
- endif
-
- $d
- 1
-
- " Define the environment and execute user-defined hooks.
-
- silent do VCSCommand User VCSBufferCreated
- return bufnr('%')
endfunction
" Function: s:GenerateResultBufferName(command, originalBuffer, vcsType, statusText) {{{2
@@ -372,7 +381,7 @@
" overridden with the VCSResultBufferNameFunction variable.
function! s:GenerateResultBufferName(command, originalBuffer, vcsType, statusText)
- let fileName=bufname(a:originalBuffer)
+ let fileName = bufname(a:originalBuffer)
let bufferName = a:vcsType . ' ' . a:command
if strlen(a:statusText) > 0
let bufferName .= ' ' . a:statusText
@@ -392,7 +401,7 @@
" file name with the VCS type and command appended as extensions.
function! s:GenerateResultBufferNameWithExtension(command, originalBuffer, vcsType, statusText)
- let fileName=bufname(a:originalBuffer)
+ let fileName = bufname(a:originalBuffer)
let bufferName = a:vcsType . ' ' . a:command
if strlen(a:statusText) > 0
let bufferName .= ' ' . a:statusText
@@ -442,7 +451,7 @@
set buftype=nofile
set noswapfile
- let &filetype=vcsType . a:command
+ let &filetype = vcsType . a:command
if a:statusText != ''
let b:VCSCommandStatusText = a:statusText
@@ -466,8 +475,8 @@
return
endif
- if strlen(&buftype) > 0 || !filereadable(@%)
- " No special status for special buffers.
+ if !isdirectory(@%) && (strlen(&buftype) > 0 || !filereadable(@%))
+ " No special status for special buffers other than directory buffers.
return
endif
@@ -485,7 +494,7 @@
let b:VCSCommandBufferInfo = []
endtry
- let b:VCSCommandBufferSetup=1
+ let b:VCSCommandBufferSetup = 1
endfunction
" Function: s:MarkOrigBufferForSetup(buffer) {{{2
@@ -558,7 +567,7 @@
" All scratch buffers are gone, reset the original.
" Only restore if the source buffer is still in Diff mode
- let sourceWinNR=bufwinnr(s:vimDiffSourceBuffer)
+ let sourceWinNR = bufwinnr(s:vimDiffSourceBuffer)
if sourceWinNR != -1
" The buffer is visible in at least one window
let currentWinNR = winnr()
@@ -597,46 +606,50 @@
endtry
endfunction
-
" Section: Generic VCS command functions {{{1
" Function: s:VCSCommit() {{{2
function! s:VCSCommit(bang, message)
- let vcsType = VCSCommandGetVCSType(bufnr('%'))
- if !has_key(s:plugins, vcsType)
- throw 'Unknown VCS type: ' . vcsType
- endif
-
- let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
-
- " Handle the commit message being specified. If a message is supplied, it
- " is used; if bang is supplied, an empty message is used; otherwise, the
- " user is provided a buffer from which to edit the commit message.
-
- if strlen(a:message) > 0 || a:bang == '!'
- return s:VCSFinishCommit([a:message], originalBuffer)
- endif
-
- call s:EditFile('commitlog', originalBuffer, '')
- set ft=vcscommit
-
- " Create a commit mapping.
-
- nnoremap <silent> <buffer> <Plug>VCSCommit :call <SID>VCSFinishCommitWithBuffer()<CR>
-
- silent 0put ='VCS: ----------------------------------------------------------------------'
- silent put ='VCS: Please enter log message. Lines beginning with ''VCS:'' are removed automatically.'
- silent put ='VCS: To finish the commit, Type <leader>cc (or your own <Plug>VCSCommit mapping)'
-
- if VCSCommandGetOption('VCSCommandCommitOnWrite', 1) == 1
- set buftype=acwrite
- au VCSCommandCommit BufWriteCmd <buffer> call s:VCSFinishCommitWithBuffer()
- silent put ='VCS: or write this buffer'
- endif
-
- silent put ='VCS: ----------------------------------------------------------------------'
- $
- set nomodified
+ try
+ let vcsType = VCSCommandGetVCSType(bufnr('%'))
+ if !has_key(s:plugins, vcsType)
+ throw 'Unknown VCS type: ' . vcsType
+ endif
+
+ let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
+
+ " Handle the commit message being specified. If a message is supplied, it
+ " is used; if bang is supplied, an empty message is used; otherwise, the
+ " user is provided a buffer from which to edit the commit message.
+
+ if strlen(a:message) > 0 || a:bang == '!'
+ return s:VCSFinishCommit([a:message], originalBuffer)
+ endif
+
+ call s:EditFile('commitlog', originalBuffer, '')
+ set ft=vcscommit
+
+ " Create a commit mapping.
+
+ nnoremap <silent> <buffer> <Plug>VCSCommit :call <SID>VCSFinishCommitWithBuffer()<CR>
+
+ silent 0put ='VCS: ----------------------------------------------------------------------'
+ silent put ='VCS: Please enter log message. Lines beginning with ''VCS:'' are removed automatically.'
+ silent put ='VCS: To finish the commit, Type <leader>cc (or your own <Plug>VCSCommit mapping)'
+
+ if VCSCommandGetOption('VCSCommandCommitOnWrite', 1) == 1
+ set buftype=acwrite
+ au VCSCommandCommit BufWriteCmd <buffer> call s:VCSFinishCommitWithBuffer()
+ silent put ='VCS: or write this buffer'
+ endif
+
+ silent put ='VCS: ----------------------------------------------------------------------'
+ $
+ set nomodified
+ catch
+ call s:ReportError(v:exception)
+ return -1
+ endtry
endfunction
" Function: s:VCSFinishCommitWithBuffer() {{{2
@@ -663,7 +676,7 @@
let messageFileName = tempname()
call writefile(a:logMessageList, messageFileName)
try
- let resultBuffer = s:ExecuteVCSCommand('Commit', a:originalBuffer, [messageFileName])
+ let resultBuffer = s:ExecuteVCSCommand('Commit', [messageFileName], 0)
if resultBuffer < 0
return resultBuffer
endif
@@ -701,121 +714,126 @@
" Function: s:VCSVimDiff(...) {{{2
function! s:VCSVimDiff(...)
- let vcsType = VCSCommandGetVCSType(bufnr('%'))
- if !has_key(s:plugins, vcsType)
- throw 'Unknown VCS type: ' . vcsType
- endif
- let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
- let s:isEditFileRunning = s:isEditFileRunning + 1
try
- " If there's already a VimDiff'ed window, restore it.
- " There may only be one VCSVimDiff original window at a time.
-
- if exists('s:vimDiffSourceBuffer') && s:vimDiffSourceBuffer != originalBuffer
- " Clear the existing vimdiff setup by removing the result buffers.
- call s:WipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff')
- endif
-
- " Split and diff
- if(a:0 == 2)
- " Reset the vimdiff system, as 2 explicit versions were provided.
- if exists('s:vimDiffSourceBuffer')
+ let vcsType = VCSCommandGetVCSType(bufnr('%'))
+ if !has_key(s:plugins, vcsType)
+ throw 'Unknown VCS type: ' . vcsType
+ endif
+ let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
+ let s:isEditFileRunning = s:isEditFileRunning + 1
+ try
+ " If there's already a VimDiff'ed window, restore it.
+ " There may only be one VCSVimDiff original window at a time.
+
+ if exists('s:vimDiffSourceBuffer') && s:vimDiffSourceBuffer != originalBuffer
+ " Clear the existing vimdiff setup by removing the result buffers.
call s:WipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff')
endif
- let resultBuffer = s:plugins[vcsType].Review([a:1])
- if resultBuffer < 0
- echomsg 'Can''t open revision ' . a:1
- return resultBuffer
- endif
- let b:VCSCommandCommand = 'vimdiff'
- diffthis
- let s:vimDiffScratchList = [resultBuffer]
- " If no split method is defined, cheat, and set it to vertical.
- try
- call s:OverrideOption('VCSCommandSplit', VCSCommandGetOption('VCSCommandDiffSplit', VCSCommandGetOption('VCSCommandSplit', 'vertical')))
- let resultBuffer=s:plugins[vcsType].Review([a:2])
- finally
- call s:OverrideOption('VCSCommandSplit')
- endtry
- if resultBuffer < 0
- echomsg 'Can''t open revision ' . a:1
- return resultBuffer
- endif
- let b:VCSCommandCommand = 'vimdiff'
- diffthis
- let s:vimDiffScratchList += [resultBuffer]
- else
- " Add new buffer
- call s:OverrideOption('VCSCommandEdit', 'split')
- try
- " Force splitting behavior, otherwise why use vimdiff?
- call s:OverrideOption('VCSCommandSplit', VCSCommandGetOption('VCSCommandDiffSplit', VCSCommandGetOption('VCSCommandSplit', 'vertical')))
+
+ " Split and diff
+ if(a:0 == 2)
+ " Reset the vimdiff system, as 2 explicit versions were provided.
+ if exists('s:vimDiffSourceBuffer')
+ call s:WipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff')
+ endif
+ let resultBuffer = s:plugins[vcsType].Review([a:1])
+ if resultBuffer < 0
+ echomsg 'Can''t open revision ' . a:1
+ return resultBuffer
+ endif
+ let b:VCSCommandCommand = 'vimdiff'
+ diffthis
+ let s:vimDiffScratchList = [resultBuffer]
+ " If no split method is defined, cheat, and set it to vertical.
try
- if(a:0 == 0)
- let resultBuffer=s:plugins[vcsType].Review([])
- else
- let resultBuffer=s:plugins[vcsType].Review([a:1])
- endif
+ call s:OverrideOption('VCSCommandSplit', VCSCommandGetOption('VCSCommandDiffSplit', VCSCommandGetOption('VCSCommandSplit', 'vertical')))
+ let resultBuffer = s:plugins[vcsType].Review([a:2])
finally
call s:OverrideOption('VCSCommandSplit')
endtry
+ if resultBuffer < 0
+ echomsg 'Can''t open revision ' . a:1
+ return resultBuffer
+ endif
+ let b:VCSCommandCommand = 'vimdiff'
+ diffthis
+ let s:vimDiffScratchList += [resultBuffer]
+ else
+ " Add new buffer
+ call s:OverrideOption('VCSCommandEdit', 'split')
+ try
+ " Force splitting behavior, otherwise why use vimdiff?
+ call s:OverrideOption('VCSCommandSplit', VCSCommandGetOption('VCSCommandDiffSplit', VCSCommandGetOption('VCSCommandSplit', 'vertical')))
+ try
+ if(a:0 == 0)
+ let resultBuffer = s:plugins[vcsType].Review([])
+ else
+ let resultBuffer = s:plugins[vcsType].Review([a:1])
+ endif
+ finally
+ call s:OverrideOption('VCSCommandSplit')
+ endtry
+ finally
+ call s:OverrideOption('VCSCommandEdit')
+ endtry
+ if resultBuffer < 0
+ echomsg 'Can''t open current revision'
+ return resultBuffer
+ endif
+ let b:VCSCommandCommand = 'vimdiff'
+ diffthis
+
+ if !exists('s:vimDiffSourceBuffer')
+ " New instance of vimdiff.
+ let s:vimDiffScratchList = [resultBuffer]
+
+ " This could have been invoked on a VCS result buffer, not the
+ " original buffer.
+ wincmd W
+ execute 'buffer' originalBuffer
+ " Store info for later original buffer restore
+ let s:vimDiffRestoreCmd =
+ \ 'call setbufvar('.originalBuffer.', ''&diff'', '.getbufvar(originalBuffer, '&diff').')'
+ \ . '|call setbufvar('.originalBuffer.', ''&foldcolumn'', '.getbufvar(originalBuffer, '&foldcolumn').')'
+ \ . '|call setbufvar('.originalBuffer.', ''&foldenable'', '.getbufvar(originalBuffer, '&foldenable').')'
+ \ . '|call setbufvar('.originalBuffer.', ''&foldmethod'', '''.getbufvar(originalBuffer, '&foldmethod').''')'
+ \ . '|call setbufvar('.originalBuffer.', ''&scrollbind'', '.getbufvar(originalBuffer, '&scrollbind').')'
+ \ . '|call setbufvar('.originalBuffer.', ''&wrap'', '.getbufvar(originalBuffer, '&wrap').')'
+ \ . '|if &foldmethod==''manual''|execute ''normal zE''|endif'
+ diffthis
+ wincmd w
+ else
+ " Adding a window to an existing vimdiff
+ let s:vimDiffScratchList += [resultBuffer]
+ endif
+ endif
+
+ let s:vimDiffSourceBuffer = originalBuffer
+
+ " Avoid executing the modeline in the current buffer after the autocommand.
+
+ let currentBuffer = bufnr('%')
+ let saveModeline = getbufvar(currentBuffer, '&modeline')
+ try
+ call setbufvar(currentBuffer, '&modeline', 0)
+ silent do VCSCommand User VCSVimDiffFinish
finally
- call s:OverrideOption('VCSCommandEdit')
+ call setbufvar(currentBuffer, '&modeline', saveModeline)
endtry
- if resultBuffer < 0
- echomsg 'Can''t open current revision'
- return resultBuffer
- endif
- let b:VCSCommandCommand = 'vimdiff'
- diffthis
-
- if !exists('s:vimDiffSourceBuffer')
- " New instance of vimdiff.
- let s:vimDiffScratchList = [resultBuffer]
-
- " This could have been invoked on a VCS result buffer, not the
- " original buffer.
- wincmd W
- execute 'buffer' originalBuffer
- " Store info for later original buffer restore
- let s:vimDiffRestoreCmd =
- \ 'call setbufvar('.originalBuffer.', ''&diff'', '.getbufvar(originalBuffer, '&diff').')'
- \ . '|call setbufvar('.originalBuffer.', ''&foldcolumn'', '.getbufvar(originalBuffer, '&foldcolumn').')'
- \ . '|call setbufvar('.originalBuffer.', ''&foldenable'', '.getbufvar(originalBuffer, '&foldenable').')'
- \ . '|call setbufvar('.originalBuffer.', ''&foldmethod'', '''.getbufvar(originalBuffer, '&foldmethod').''')'
- \ . '|call setbufvar('.originalBuffer.', ''&scrollbind'', '.getbufvar(originalBuffer, '&scrollbind').')'
- \ . '|call setbufvar('.originalBuffer.', ''&wrap'', '.getbufvar(originalBuffer, '&wrap').')'
- \ . '|if &foldmethod==''manual''|execute ''normal zE''|endif'
- diffthis
- wincmd w
- else
- " Adding a window to an existing vimdiff
- let s:vimDiffScratchList += [resultBuffer]
- endif
- endif
-
- let s:vimDiffSourceBuffer = originalBuffer
-
- " Avoid executing the modeline in the current buffer after the autocommand.
-
- let currentBuffer = bufnr('%')
- let saveModeline = getbufvar(currentBuffer, '&modeline')
- try
- call setbufvar(currentBuffer, '&modeline', 0)
- silent do VCSCommand User VCSVimDiffFinish
+ return resultBuffer
finally
- call setbufvar(currentBuffer, '&modeline', saveModeline)
+ let s:isEditFileRunning = s:isEditFileRunning - 1
endtry
- return resultBuffer
- finally
- let s:isEditFileRunning = s:isEditFileRunning - 1
+ catch
+ call s:ReportError(v:exception)
+ return -1
endtry
endfunction
" Section: Public functions {{{1
-" Function: VCSCommandGetVCSType(buffer) {{{2
-" Sets the b:VCSCommandVCSType variable in the current buffer to the
+" Function: VCSCommandGetVCSType() {{{2
+" Sets the b:VCSCommandVCSType variable in the given buffer to the
" appropriate source control system name.
function! VCSCommandGetVCSType(buffer)
@@ -832,14 +850,25 @@
throw 'No suitable plugin'
endfunction
+" Function: VCSCommandChdir(directory) {{{2
+" Changes the current directory, respecting :lcd changes.
+
+function! VCSCommandChdir(directory)
+ let command = 'cd'
+ if exists("*haslocaldir") && haslocaldir()
+ let command = 'lcd'
+ endif
+ execute command escape(a:directory, ' ')
+endfunction
+
" Function: VCSCommandChangeToCurrentFileDir() {{{2
" Go to the directory in which the given file is located.
function! VCSCommandChangeToCurrentFileDir(fileName)
- let oldCwd=getcwd()
- let newCwd=fnamemodify(resolve(a:fileName), ':p:h')
+ let oldCwd = getcwd()
+ let newCwd = fnamemodify(resolve(a:fileName), ':p:h')
if strlen(newCwd) > 0
- execute 'cd' escape(newCwd, ' ')
+ call VCSCommandChdir(newCwd)
endif
return oldCwd
endfunction
@@ -870,7 +899,9 @@
let s:plugins[a:name] = a:commandMap
call add(s:pluginFiles, a:file)
let s:extendedMappings[a:name] = a:mappingMap
- if(!empty(a:mappingMap))
+ if !empty(a:mappingMap)
+ \ && !VCSCommandGetOption('VCSCommandDisableMappings', 0)
+ \ && !VCSCommandGetOption('VCSCommandDisableExtensionMappings', 0)
for mapname in keys(a:mappingMap)
execute 'noremap <silent> <Leader>' . mapname ':call <SID>ExecuteExtensionMapping(''' . mapname . ''')<CR>'
endfor
@@ -887,7 +918,7 @@
throw 'Original buffer no longer exists, aborting.'
endif
- let fileName=bufname(originalBuffer)
+ let fileName = resolve(bufname(originalBuffer))
" Work with netrw or other systems where a directory listing is displayed in
" a buffer.
@@ -895,17 +926,63 @@
if isdirectory(fileName)
let realFileName = '.'
else
- let realFileName = fnamemodify(resolve(fileName), ':t')
- endif
-
- let oldCwd=VCSCommandChangeToCurrentFileDir(fileName)
+ let realFileName = fnamemodify(fileName, ':t')
+ endif
+
+ " Change to the directory of the current buffer. This is done for CVS, but
+ " is left in for other systems as it does not affect them negatively.
+
+ let oldCwd = VCSCommandChangeToCurrentFileDir(fileName)
try
- let fullCmd = a:cmd . ' "' . realFileName . '"'
- let resultBuffer=s:CreateCommandBuffer(fullCmd, a:cmdName, originalBuffer, a:statusText)
- return resultBuffer
+ let output = system(a:cmd . ' "' . realFileName . '"')
finally
- execute 'cd' escape(oldCwd, ' ')
+ call VCSCommandChdir(oldCwd)
endtry
+
+ " HACK: if line endings in the repository have been corrupted, the output
+ " of the command will be confused.
+ let output = substitute(output, "\r", '', 'g')
+
+ " HACK: CVS diff command does not return proper error codes
+ if v:shell_error && (a:cmdName != 'diff' || getbufvar(originalBuffer, 'VCSCommandVCSType') != 'CVS')
+ if strlen(output) == 0
+ throw 'Version control command failed'
+ else
+ let output = substitute(output, '\n', ' ', 'g')
+ throw 'Version control command failed: ' . output
+ endif
+ endif
+ if strlen(output) == 0
+ " Handle case of no output. In this case, it is important to check the
+ " file status, especially since cvs edit/unedit may change the attributes
+ " of the file with no visible output.
+
+ checktime
+ return 0
+ endif
+
+ call s:EditFile(a:cmdName, originalBuffer, a:statusText)
+
+ silent 0put=output
+
+ " The last command left a blank line at the end of the buffer. If the
+ " last line is folded (a side effect of the 'put') then the attempt to
+ " remove the blank line will kill the last fold.
+ "
+ " This could be fixed by explicitly detecting whether the last line is
+ " within a fold, but I prefer to simply unfold the result buffer altogether.
+
+ if has('folding')
+ normal zR
+ endif
+
+ $d
+ 1
+
+ " Define the environment and execute user-defined hooks.
+
+ silent do VCSCommand User VCSBufferCreated
+ return bufnr('%')
endfunction
" Function: VCSCommandGetOption(name, default) {{{2
@@ -991,18 +1068,20 @@
" Section: Command definitions {{{1
" Section: Primary commands {{{2
-com! -nargs=0 VCSAdd call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Add', bufnr('%'), []))
-com! -nargs=? VCSAnnotate call s:ExecuteVCSCommand('Annotate', bufnr('%'), [<f-args>])
+com! -nargs=* VCSAdd call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Add', [<f-args>], 0))
+com! -nargs=* VCSAnnotate call s:ExecuteVCSCommand('Annotate', [<f-args>], 1)
com! -nargs=? -bang VCSCommit call s:VCSCommit(<q-bang>, <q-args>)
-com! -nargs=* VCSDiff call s:ExecuteVCSCommand('Diff', bufnr('%'), [<f-args>])
+com! -nargs=* VCSDelete call s:ExecuteVCSCommand('Delete', [<f-args>], 1)
+com! -nargs=* VCSDiff call s:ExecuteVCSCommand('Diff', [<f-args>], 1)
com! -nargs=0 -bang VCSGotoOriginal call s:VCSGotoOriginal(<q-bang>)
-com! -nargs=0 VCSLock call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Lock', bufnr('%'), []))
-com! -nargs=? VCSLog call s:ExecuteVCSCommand('Log', bufnr('%'), [<f-args>])
-com! -nargs=0 VCSRevert call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Revert', bufnr('%'), []))
-com! -nargs=? VCSReview call s:ExecuteVCSCommand('Review', bufnr('%'), [<f-args>])
-com! -nargs=0 VCSStatus call s:ExecuteVCSCommand('Status', bufnr('%'), [])
-com! -nargs=0 VCSUnlock call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Unlock', bufnr('%'), []))
-com! -nargs=0 VCSUpdate call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Update', bufnr('%'), []))
+com! -nargs=* VCSInfo call s:ExecuteVCSCommand('Info', [<f-args>], 1)
+com! -nargs=* VCSLock call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Lock', [<f-args>], 1))
+com! -nargs=* VCSLog call s:ExecuteVCSCommand('Log', [<f-args>], 1)
+com! -nargs=0 VCSRevert call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Revert', [], 1))
+com! -nargs=? VCSReview call s:ExecuteVCSCommand('Review', [<f-args>], 1)
+com! -nargs=* VCSStatus call s:ExecuteVCSCommand('Status', [<f-args>], 1)
+com! -nargs=* VCSUnlock call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Unlock', [<f-args>], 1))
+com! -nargs=0 VCSUpdate call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Update', [], 1))
com! -nargs=* VCSVimDiff call s:VCSVimDiff(<f-args>)
" Section: VCS buffer management commands {{{2
@@ -1016,9 +1095,11 @@
nnoremap <silent> <Plug>VCSAdd :VCSAdd<CR>
nnoremap <silent> <Plug>VCSAnnotate :VCSAnnotate<CR>
nnoremap <silent> <Plug>VCSCommit :VCSCommit<CR>
+nnoremap <silent> <Plug>VCSDelete :VCSDelete<CR>
nnoremap <silent> <Plug>VCSDiff :VCSDiff<CR>
nnoremap <silent> <Plug>VCSGotoOriginal :VCSGotoOriginal<CR>
nnoremap <silent> <Plug>VCSClearAndGotoOriginal :VCSGotoOriginal!<CR>
+nnoremap <silent> <Plug>VCSInfo :VCSInfo<CR>
nnoremap <silent> <Plug>VCSLock :VCSLock<CR>
nnoremap <silent> <Plug>VCSLog :VCSLog<CR>
nnoremap <silent> <Plug>VCSRevert :VCSRevert<CR>
@@ -1029,54 +1110,65 @@
nnoremap <silent> <Plug>VCSVimDiff :VCSVimDiff<CR>
" Section: Default mappings {{{1
-if !hasmapto('<Plug>VCSAdd')
- nmap <unique> <Leader>ca <Plug>VCSAdd
-endif
-if !hasmapto('<Plug>VCSAnnotate')
- nmap <unique> <Leader>cn <Plug>VCSAnnotate
-endif
-if !hasmapto('<Plug>VCSClearAndGotoOriginal')
- nmap <unique> <Leader>cG <Plug>VCSClearAndGotoOriginal
-endif
-if !hasmapto('<Plug>VCSCommit')
- nmap <unique> <Leader>cc <Plug>VCSCommit
-endif
-if !hasmapto('<Plug>VCSDiff')
- nmap <unique> <Leader>cd <Plug>VCSDiff
-endif
-if !hasmapto('<Plug>VCSGotoOriginal')
- nmap <unique> <Leader>cg <Plug>VCSGotoOriginal
-endif
-if !hasmapto('<Plug>VCSLock')
- nmap <unique> <Leader>cL <Plug>VCSLock
-endif
-if !hasmapto('<Plug>VCSLog')
- nmap <unique> <Leader>cl <Plug>VCSLog
-endif
-if !hasmapto('<Plug>VCSRevert')
- nmap <unique> <Leader>cq <Plug>VCSRevert
-endif
-if !hasmapto('<Plug>VCSReview')
- nmap <unique> <Leader>cr <Plug>VCSReview
-endif
-if !hasmapto('<Plug>VCSStatus')
- nmap <unique> <Leader>cs <Plug>VCSStatus
-endif
-if !hasmapto('<Plug>VCSUnlock')
- nmap <unique> <Leader>cU <Plug>VCSUnlock
-endif
-if !hasmapto('<Plug>VCSUpdate')
- nmap <unique> <Leader>cu <Plug>VCSUpdate
-endif
-if !hasmapto('<Plug>VCSVimDiff')
- nmap <unique> <Leader>cv <Plug>VCSVimDiff
+
+if !VCSCommandGetOption('VCSCommandDisableMappings', 0)
+ if !hasmapto('<Plug>VCSAdd')
+ nmap <unique> <Leader>ca <Plug>VCSAdd
+ endif
+ if !hasmapto('<Plug>VCSAnnotate')
+ nmap <unique> <Leader>cn <Plug>VCSAnnotate
+ endif
+ if !hasmapto('<Plug>VCSClearAndGotoOriginal')
+ nmap <unique> <Leader>cG <Plug>VCSClearAndGotoOriginal
+ endif
+ if !hasmapto('<Plug>VCSCommit')
+ nmap <unique> <Leader>cc <Plug>VCSCommit
+ endif
+ if !hasmapto('<Plug>VCSDelete')
+ nmap <unique> <Leader>cD <Plug>VCSDelete
+ endif
+ if !hasmapto('<Plug>VCSDiff')
+ nmap <unique> <Leader>cd <Plug>VCSDiff
+ endif
+ if !hasmapto('<Plug>VCSGotoOriginal')
+ nmap <unique> <Leader>cg <Plug>VCSGotoOriginal
+ endif
+ if !hasmapto('<Plug>VCSInfo')
+ nmap <unique> <Leader>ci <Plug>VCSInfo
+ endif
+ if !hasmapto('<Plug>VCSLock')
+ nmap <unique> <Leader>cL <Plug>VCSLock
+ endif
+ if !hasmapto('<Plug>VCSLog')
+ nmap <unique> <Leader>cl <Plug>VCSLog
+ endif
+ if !hasmapto('<Plug>VCSRevert')
+ nmap <unique> <Leader>cq <Plug>VCSRevert
+ endif
+ if !hasmapto('<Plug>VCSReview')
+ nmap <unique> <Leader>cr <Plug>VCSReview
+ endif
+ if !hasmapto('<Plug>VCSStatus')
+ nmap <unique> <Leader>cs <Plug>VCSStatus
+ endif
+ if !hasmapto('<Plug>VCSUnlock')
+ nmap <unique> <Leader>cU <Plug>VCSUnlock
+ endif
+ if !hasmapto('<Plug>VCSUpdate')
+ nmap <unique> <Leader>cu <Plug>VCSUpdate
+ endif
+ if !hasmapto('<Plug>VCSVimDiff')
+ nmap <unique> <Leader>cv <Plug>VCSVimDiff
+ endif
endif
" Section: Menu items {{{1
amenu <silent> &Plugin.VCS.&Add <Plug>VCSAdd
amenu <silent> &Plugin.VCS.A&nnotate <Plug>VCSAnnotate
amenu <silent> &Plugin.VCS.&Commit <Plug>VCSCommit
+amenu <silent> &Plugin.VCS.Delete <Plug>VCSDelete
amenu <silent> &Plugin.VCS.&Diff <Plug>VCSDiff
+amenu <silent> &Plugin.VCS.&Info <Plug>VCSInfo
amenu <silent> &Plugin.VCS.&Log <Plug>VCSLog
amenu <silent> &Plugin.VCS.Revert <Plug>VCSRevert
amenu <silent> &Plugin.VCS.&Review <Plug>VCSReview
@@ -1096,12 +1188,33 @@
call VCSCommandEnableBufferSetup()
endif
+" Section: VIM shutdown hook {{{1
+
+" Close all result buffers when VIM exits, to prevent them from being restored
+" via viminfo.
+
+" Function: s:CloseAllResultBuffers() {{{2
+" Closes all vcscommand result buffers.
+function! s:CloseAllResultBuffers()
+ " This avoids using bufdo as that may load buffers already loaded in another
+ " vim process, resulting in an error.
+ let buffnr = 1
+ let buffmaxnr = bufnr('$')
+ while buffnr <= buffmaxnr
+ if getbufvar(buffnr, 'VCSCommandOriginalBuffer') != ""
+ execute 'bw' buffnr
+ endif
+ let buffnr = buffnr + 1
+ endwhile
+endfunction
+
+augroup VCSCommandVIMShutdown
+ au!
+ au VimLeavePre * call s:CloseAllResultBuffers()
+augroup END
+
" Section: Plugin completion {{{1
-let loaded_VCSCommand=2
-
-" Load delayed extension plugin registration.
-silent do VCSCommand User VCSLoadExtensions
-au! VCSCommand User VCSLoadExtensions
+let loaded_VCSCommand = 2
silent do VCSCommand User VCSPluginFinish
Modified: trunk/packages/vim-scripts/plugin/vcscvs.vim
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/plugin/vcscvs.vim?rev=958&op=diff
==============================================================================
--- trunk/packages/vim-scripts/plugin/vcscvs.vim (original)
+++ trunk/packages/vim-scripts/plugin/vcscvs.vim Thu Jun 21 10:27:19 2007
@@ -2,10 +2,28 @@
"
" CVS extension for VCSCommand.
"
-" Last Change:
" Version: VCS development
" Maintainer: Bob Hiestand <bob.hiestand at gmail.com>
-" License: This file is placed in the public domain.
+" License:
+" Copyright (c) 2007 Bob Hiestand
+"
+" Permission is hereby granted, free of charge, to any person obtaining a copy
+" of this software and associated documentation files (the "Software"), to
+" deal in the Software without restriction, including without limitation the
+" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+" sell copies of the Software, and to permit persons to whom the Software is
+" furnished to do so, subject to the following conditions:
+"
+" The above copyright notice and this permission notice shall be included in
+" all copies or substantial portions of the Software.
+"
+" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+" IN THE SOFTWARE.
"
" Section: Documentation {{{1
"
@@ -43,7 +61,7 @@
" The default mappings are as follow:
"
" <Leader>ce CVSEdit
-" <Leader>ci CVSEditors
+" <Leader>cE CVSEditors
" <Leader>ct CVSUnedit
" <Leader>cwv CVSWatchers
" <Leader>cwa CVSWatchAdd
@@ -65,6 +83,13 @@
finish
endif
+runtime plugin/vcscommand.vim
+
+if !executable(VCSCommandGetOption('VCSCommandCVSExec', 'cvs'))
+ " CVS is not installed
+ finish
+endif
+
" Section: Variable initialization {{{1
let s:cvsFunctions = {}
@@ -75,16 +100,12 @@
" Wrapper to VCSCommandDoCommand to add the name of the CVS executable to the
" command argument.
function! s:DoCommand(cmd, cmdName, statusText)
- try
- if VCSCommandGetVCSType(expand('%')) == 'CVS'
- let fullCmd = VCSCommandGetOption('VCSCommandCVSExec', 'cvs') . ' ' . a:cmd
- return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText)
- else
- throw 'No suitable plugin'
- endif
- catch /No suitable plugin/
- echohl WarningMsg|echomsg 'Cannot apply CVS commands to this file.'|echohl None
- endtry
+ if VCSCommandGetVCSType(expand('%')) == 'CVS'
+ let fullCmd = VCSCommandGetOption('VCSCommandCVSExec', 'cvs') . ' ' . a:cmd
+ return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText)
+ else
+ throw 'CVS VCSCommand plugin called on non-CVS item.'
+ endif
endfunction
" Section: VCS function implementations {{{1
@@ -93,12 +114,12 @@
function! s:cvsFunctions.Identify(buffer)
let fileName = resolve(bufname(a:buffer))
if isdirectory(fileName)
- let directory = fileName
- else
- let directory = fnamemodify(fileName, ':h')
- endif
- if strlen(directory) > 0
- let CVSRoot = directory . '/CVS/Root'
+ let directoryName = fileName
+ else
+ let directoryName = fnamemodify(fileName, ':h')
+ endif
+ if strlen(directoryName) > 0
+ let CVSRoot = directoryName . '/CVS/Root'
else
let CVSRoot = 'CVS/Root'
endif
@@ -109,9 +130,9 @@
endif
endfunction
-" Function: s:cvsFunctions.Add() {{{2
+" Function: s:cvsFunctions.Add(argList) {{{2
function! s:cvsFunctions.Add(argList)
- return s:DoCommand('add', 'add', '')
+ return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '))
endfunction
" Function: s:cvsFunctions.Annotate(argList) {{{2
@@ -120,26 +141,37 @@
if &filetype == 'CVSAnnotate'
" This is a CVSAnnotate buffer. Perform annotation of the version
" indicated by the current line.
- let revision = matchstr(getline('.'),'\v%(^[0-9.]+)')
+ let caption = matchstr(getline('.'),'\v^[0-9.]+')
+
+ if VCSCommandGetOption('VCSCommandCVSAnnotateParent', 0) != 0
+ if caption != '1.1'
+ let revmaj = matchstr(caption,'\v[0-9.]+\ze\.[0-9]+')
+ let revmin = matchstr(caption,'\v[0-9.]+\.\zs[0-9]+') - 1
+ if revmin == 0
+ " Jump to ancestor branch
+ let caption = matchstr(revmaj,'\v[0-9.]+\ze\.[0-9]+')
+ else
+ let caption = revmaj . "." . revmin
+ endif
+ endif
+ endif
+
+ let options = ['-r' . caption]
else
- let revision=VCSCommandGetRevision()
- if revision == ''
- throw 'Unable to obtain version information.'
- elseif revision == 'Unknown'
- throw 'File not under source control'
- elseif revision == 'New'
- throw 'No annotatation available for new file.'
- endif
+ " CVS defaults to pulling HEAD, regardless of current branch.
+ " Therefore, always pass desired revision.
+ let caption = ''
+ let options = ['-r' . VCSCommandGetRevision()]
endif
- else
- let revision=a:argList[0]
- endif
-
- if revision == 'New'
- throw 'No annotatation available for new file.'
- endif
-
- let resultBuffer=s:DoCommand('-q annotate -r ' . revision, 'annotate', revision)
+ elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
+ let caption = a:argList[0]
+ let options = ['-r' . caption]
+ else
+ let caption = join(a:argList)
+ let options = a:argList
+ endif
+
+ let resultBuffer = s:DoCommand(join(['-q', 'annotate'] + options), 'annotate', caption)
if resultBuffer > 0
set filetype=CVSAnnotate
" Remove header lines from standard error
@@ -157,28 +189,41 @@
return resultBuffer
endfunction
+" Function: s:cvsFunctions.Delete() {{{2
+" By default, use the -f option to remove the file first. If options are
+" passed in, use those instead.
+function! s:cvsFunctions.Delete(argList)
+ let options = ['-f']
+ let caption = ''
+ if len(a:argList) > 0
+ let options = a:argList
+ let caption = join(a:argList, ' ')
+ endif
+ return s:DoCommand(join(['remove'] + options, ' '), 'delete', caption)
+endfunction
+
" Function: s:cvsFunctions.Diff(argList) {{{2
function! s:cvsFunctions.Diff(argList)
- if len(a:argList) == 1
- let revOptions = '-r ' . a:argList[0]
- let caption = '(' . a:argList[0] . ' : current)'
- elseif len(a:argList) == 2
- let revOptions = '-r ' . a:argList[0] . ' -r ' . a:argList[1]
- let caption = '(' . a:argList[0] . ' : ' . a:argList[1] . ')'
- else
- let revOptions = ''
+ if len(a:argList) == 0
+ let revOptions = []
let caption = ''
- endif
-
- let cvsdiffopt = VCSCommandGetOption('VCSCommandCVSDiffOpt', 'u')
-
- if cvsdiffopt == ''
- let diffoptionstring = ''
- else
- let diffoptionstring = ' -' . cvsdiffopt . ' '
- endif
-
- let resultBuffer = s:DoCommand('diff ' . diffoptionstring . revOptions , 'diff', caption)
+ elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
+ let revOptions = ['-r' . join(a:argList, ' -r')]
+ let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
+ else
+ " Pass-through
+ let caption = join(a:argList, ' ')
+ let revOptions = a:argList
+ endif
+
+ let cvsDiffOpt = VCSCommandGetOption('VCSCommandCVSDiffOpt', 'u')
+ if cvsDiffOpt == ''
+ let diffOptions = []
+ else
+ let diffOptions = ['-' . cvsDiffOpt]
+ endif
+
+ let resultBuffer = s:DoCommand(join(['diff'] + diffOptions + revOptions), 'diff', caption)
if resultBuffer > 0
set filetype=diff
else
@@ -197,11 +242,21 @@
function! s:cvsFunctions.GetBufferInfo()
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
let fileName = bufname(originalBuffer)
+ if isdirectory(fileName)
+ let tag = ''
+ if filereadable(fileName . '/CVS/Tag')
+ let tagFile = readfile(fileName . '/CVS/Tag')
+ if len(tagFile) == 1
+ let tag = substitute(tagFile[0], '^T', '', '')
+ endif
+ endif
+ return [tag]
+ endif
let realFileName = fnamemodify(resolve(fileName), ':t')
if !filereadable(fileName)
return ['Unknown']
endif
- let oldCwd=VCSCommandChangeToCurrentFileDir(fileName)
+ let oldCwd = VCSCommandChangeToCurrentFileDir(fileName)
try
let statusText=system(VCSCommandGetOption('VCSCommandCVSExec', 'cvs') . ' status "' . realFileName . '"')
if(v:shell_error)
@@ -222,21 +277,25 @@
let repository=substitute(repository, '^New file!\|No revision control file$', 'New', '')
return [revision, repository, branch]
finally
- execute 'cd' escape(oldCwd, ' ')
+ call VCSCommandChdir(oldCwd)
endtry
endfunction
" Function: s:cvsFunctions.Log() {{{2
function! s:cvsFunctions.Log(argList)
if len(a:argList) == 0
- let versionOption = ''
+ let options = []
let caption = ''
- else
- let versionOption=' -r' . a:argList[0]
- let caption = a:argList[0]
- endif
-
- let resultBuffer=s:DoCommand('log' . versionOption, 'log', caption)
+ elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
+ let options = ['-r' . join(a:argList, ':')]
+ let caption = options[0]
+ else
+ " Pass-through
+ let options = a:argList
+ let caption = join(a:argList, ' ')
+ endif
+
+ let resultBuffer=s:DoCommand(join(['log'] + options), 'log', caption)
if resultBuffer > 0
set filetype=rcslog
endif
@@ -267,7 +326,7 @@
" Function: s:cvsFunctions.Status(argList) {{{2
function! s:cvsFunctions.Status(argList)
- return s:DoCommand('status', 'status', '')
+ return s:DoCommand(join(['status'] + a:argList, ' '), 'status', join(a:argList, ' '))
endfunction
" Function: s:cvsFunctions.Update(argList) {{{2
@@ -323,7 +382,7 @@
let s:cvsExtensionMappings = {}
let mappingInfo = [
\['CVSEdit', 'CVSEdit', 'ce'],
- \['CVSEditors', 'CVSEditors', 'ci'],
+ \['CVSEditors', 'CVSEditors', 'cE'],
\['CVSUnedit', 'CVSUnedit', 'ct'],
\['CVSWatchers', 'CVSWatchers', 'cwv'],
\['CVSWatchAdd', 'CVSWatch add', 'cwa'],
@@ -351,12 +410,4 @@
amenu <silent> &Plugin.VCS.CVS.WatchRemove <Plug>CVSWatchRemove
" Section: Plugin Registration {{{1
-" If the vcscommand.vim plugin hasn't loaded, delay registration until it
-" loads.
-if exists('g:loaded_VCSCommand')
- call VCSCommandRegisterModule('CVS', expand('<sfile>'), s:cvsFunctions, s:cvsExtensionMappings)
-else
- augroup VCSCommand
- au User VCSLoadExtensions call VCSCommandRegisterModule('CVS', expand('<sfile>'), s:cvsFunctions, s:cvsExtensionMappings)
- augroup END
-endif
+call VCSCommandRegisterModule('CVS', expand('<sfile>'), s:cvsFunctions, s:cvsExtensionMappings)
Added: trunk/packages/vim-scripts/plugin/vcssvk.vim
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/plugin/vcssvk.vim?rev=958&op=file
==============================================================================
--- trunk/packages/vim-scripts/plugin/vcssvk.vim (added)
+++ trunk/packages/vim-scripts/plugin/vcssvk.vim Thu Jun 21 10:27:19 2007
@@ -1,0 +1,250 @@
+" vim600: set foldmethod=marker:
+"
+" SVK extension for VCSCommand.
+"
+" Version: VCS development
+" Maintainer: Bob Hiestand <bob.hiestand at gmail.com>
+" License:
+" Copyright (c) 2007 Bob Hiestand
+"
+" Permission is hereby granted, free of charge, to any person obtaining a copy
+" of this software and associated documentation files (the "Software"), to
+" deal in the Software without restriction, including without limitation the
+" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+" sell copies of the Software, and to permit persons to whom the Software is
+" furnished to do so, subject to the following conditions:
+"
+" The above copyright notice and this permission notice shall be included in
+" all copies or substantial portions of the Software.
+"
+" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+" IN THE SOFTWARE.
+"
+" Section: Documentation {{{1
+"
+" Options documentation: {{{2
+"
+" VCSCommandSVKExec
+" This variable specifies the SVK executable. If not set, it defaults to
+" 'svk' executed from the user's executable path.
+
+if v:version < 700
+ finish
+endif
+
+runtime plugin/vcscommand.vim
+
+if !executable(VCSCommandGetOption('VCSCommandSVKExec', 'svk'))
+ " SVK is not installed
+ finish
+endif
+
+" Section: Variable initialization {{{1
+
+let s:svkFunctions = {}
+
+" Section: Utility functions {{{1
+
+" Function: s:DoCommand(cmd, cmdName, statusText) {{{2
+" Wrapper to VCSCommandDoCommand to add the name of the SVK executable to the
+" command argument.
+function! s:DoCommand(cmd, cmdName, statusText)
+ if VCSCommandGetVCSType(expand('%')) == 'SVK'
+ let fullCmd = VCSCommandGetOption('VCSCommandSVKExec', 'svk') . ' ' . a:cmd
+ return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText)
+ else
+ throw 'SVK VCSCommand plugin called on non-SVK item.'
+ endif
+endfunction
+
+" Section: VCS function implementations {{{1
+
+" Function: s:svkFunctions.Identify(buffer) {{{2
+function! s:svkFunctions.Identify(buffer)
+ let fileName = resolve(bufname(a:buffer))
+ if isdirectory(fileName)
+ let directoryName = fileName
+ else
+ let directoryName = fnamemodify(fileName, ':p:h')
+ endif
+ let statusText = system(VCSCommandGetOption('VCSCommandSVKExec', 'svk') . ' info "' . directoryName . '"')
+ if(v:shell_error)
+ return 0
+ else
+ return 1
+ endif
+endfunction
+
+" Function: s:svkFunctions.Add() {{{2
+function! s:svkFunctions.Add(argList)
+ return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '))
+endfunction
+
+" Function: s:svkFunctions.Annotate(argList) {{{2
+function! s:svkFunctions.Annotate(argList)
+ if len(a:argList) == 0
+ if &filetype == 'SVKAnnotate'
+ " Perform annotation of the version indicated by the current line.
+ let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
+ let options = ' -r' . caption
+ else
+ let caption = ''
+ let options = ''
+ endif
+ elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
+ let caption = a:argList[0]
+ let options = ' -r' . caption
+ else
+ let caption = join(a:argList, ' ')
+ let options = ' ' . caption
+ endif
+
+ let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption)
+ if resultBuffer > 0
+ normal 1G2dd
+ set filetype=SVKAnnotate
+ endif
+ return resultBuffer
+endfunction
+
+" Function: s:svkFunctions.Commit(argList) {{{2
+function! s:svkFunctions.Commit(argList)
+ let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '')
+ if resultBuffer == 0
+ echomsg 'No commit needed.'
+ endif
+endfunction
+
+" Function: s:svkFunctions.Delete() {{{2
+function! s:svkFunctions.Delete(argList)
+ return s:DoCommand(join(['delete'] + a:argList, ' '), 'delete', join(a:argList, ' '))
+endfunction
+
+" Function: s:svkFunctions.Diff(argList) {{{2
+function! s:svkFunctions.Diff(argList)
+ if len(a:argList) == 0
+ let revOptions = []
+ let caption = ''
+ elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
+ let revOptions = ['-r' . join(a:argList, ':')]
+ let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
+ else
+ " Pass-through
+ let caption = join(a:argList, ' ')
+ let revOptions = a:argList
+ endif
+
+ let resultBuffer = s:DoCommand(join(['diff'] + revOptions), 'diff', caption)
+ if resultBuffer > 0
+ set filetype=diff
+ else
+ echomsg 'No differences found'
+ endif
+ return resultBuffer
+endfunction
+
+" Function: s:svkFunctions.GetBufferInfo() {{{2
+" Provides version control details for the current file. Current version
+" number and current repository version number are required to be returned by
+" the vcscommand plugin.
+" Returns: List of results: [revision, repository]
+
+function! s:svkFunctions.GetBufferInfo()
+ let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
+ let fileName = resolve(bufname(originalBuffer))
+ let statusText = system(VCSCommandGetOption('VCSCommandSVKExec', 'svk') . ' status -v "' . fileName . '"')
+ if(v:shell_error)
+ return []
+ endif
+
+ " File not under SVK control.
+ if statusText =~ '^?'
+ return ['Unknown']
+ endif
+
+ let [flags, revision, repository] = matchlist(statusText, '^\(.\{3}\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s')[1:3]
+ if revision == ''
+ " Error
+ return ['Unknown']
+ elseif flags =~ '^A'
+ return ['New', 'New']
+ else
+ return [revision, repository]
+ endif
+endfunction
+
+" Function: s:svkFunctions.Info(argList) {{{2
+function! s:svkFunctions.Info(argList)
+ return s:DoCommand(join(['info'] + a:argList, ' '), 'info', join(a:argList, ' '))
+endfunction
+
+" Function: s:svkFunctions.Lock(argList) {{{2
+function! s:svkFunctions.Lock(argList)
+ return s:DoCommand(join(['lock'] + a:argList, ' '), 'lock', join(a:argList, ' '))
+endfunction
+
+" Function: s:svkFunctions.Log() {{{2
+function! s:svkFunctions.Log(argList)
+ if len(a:argList) == 0
+ let options = []
+ let caption = ''
+ elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
+ let options = ['-r' . join(a:argList, ':')]
+ let caption = options[0]
+ else
+ " Pass-through
+ let options = a:argList
+ let caption = join(a:argList, ' ')
+ endif
+
+ let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption)
+ return resultBuffer
+endfunction
+
+" Function: s:svkFunctions.Revert(argList) {{{2
+function! s:svkFunctions.Revert(argList)
+ return s:DoCommand('revert', 'revert', '')
+endfunction
+
+" Function: s:svkFunctions.Review(argList) {{{2
+function! s:svkFunctions.Review(argList)
+ if len(a:argList) == 0
+ let versiontag = '(current)'
+ let versionOption = ''
+ else
+ let versiontag = a:argList[0]
+ let versionOption = ' -r ' . versiontag . ' '
+ endif
+
+ let resultBuffer = s:DoCommand('cat' . versionOption, 'review', versiontag)
+ if resultBuffer > 0
+ let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
+ endif
+ return resultBuffer
+endfunction
+
+" Function: s:svkFunctions.Status(argList) {{{2
+function! s:svkFunctions.Status(argList)
+ let options = ['-v']
+ if len(a:argList) == 0
+ let options = a:argList
+ endif
+ return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '))
+endfunction
+
+" Function: s:svkFunctions.Unlock(argList) {{{2
+function! s:svkFunctions.Unlock(argList)
+ return s:DoCommand(join(['unlock'] + a:argList, ' '), 'unlock', join(a:argList, ' '))
+endfunction
+" Function: s:svkFunctions.Update(argList) {{{2
+function! s:svkFunctions.Update(argList)
+ return s:DoCommand('update', 'update', '')
+endfunction
+
+" Section: Plugin Registration {{{1
+call VCSCommandRegisterModule('SVK', expand('<sfile>'), s:svkFunctions, [])
Modified: trunk/packages/vim-scripts/plugin/vcssvn.vim
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/plugin/vcssvn.vim?rev=958&op=diff
==============================================================================
--- trunk/packages/vim-scripts/plugin/vcssvn.vim (original)
+++ trunk/packages/vim-scripts/plugin/vcssvn.vim Thu Jun 21 10:27:19 2007
@@ -2,29 +2,30 @@
"
" SVN extension for VCSCommand.
"
-" Last Change:
" Version: VCS development
" Maintainer: Bob Hiestand <bob.hiestand at gmail.com>
-" License: This file is placed in the public domain.
+" License:
+" Copyright (c) 2007 Bob Hiestand
+"
+" Permission is hereby granted, free of charge, to any person obtaining a copy
+" of this software and associated documentation files (the "Software"), to
+" deal in the Software without restriction, including without limitation the
+" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+" sell copies of the Software, and to permit persons to whom the Software is
+" furnished to do so, subject to the following conditions:
+"
+" The above copyright notice and this permission notice shall be included in
+" all copies or substantial portions of the Software.
+"
+" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+" IN THE SOFTWARE.
"
" Section: Documentation {{{1
-"
-" Command documentation {{{2
-"
-" The following command only applies to files under SVN source control.
-"
-" SVNInfo Performs "svn info" on the current file.
-"
-" Mapping documentation: {{{2
-"
-" By default, a mapping is defined for each command. User-provided mappings
-" can be used instead by mapping to <Plug>CommandName, for instance:
-"
-" nnoremap ,si <Plug>SVNInfo
-"
-" The default mappings are as follow:
-"
-" <Leader>si SVNInfo
"
" Options documentation: {{{2
"
@@ -32,11 +33,21 @@
" This variable specifies the SVN executable. If not set, it defaults to
" 'svn' executed from the user's executable path.
"
+" VCSCommandSVNDiffExt
+" This variable, if set, sets the external diff program used by Subversion.
+"
" VCSCommandSVNDiffOpt
" This variable, if set, determines the options passed to the svn diff
" command (such as 'u', 'w', or 'b').
if v:version < 700
+ finish
+endif
+
+runtime plugin/vcscommand.vim
+
+if !executable(VCSCommandGetOption('VCSCommandSVNExec', 'svn'))
+ " SVN is not installed
finish
endif
@@ -50,16 +61,12 @@
" Wrapper to VCSCommandDoCommand to add the name of the SVN executable to the
" command argument.
function! s:DoCommand(cmd, cmdName, statusText)
- try
- if VCSCommandGetVCSType(expand('%')) == 'SVN'
- let fullCmd = VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' ' . a:cmd
- return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText)
- else
- throw 'No suitable plugin'
- endif
- catch /No suitable plugin/
- echohl WarningMsg|echomsg 'Cannot apply SVN commands to this file.'|echohl None
- endtry
+ if VCSCommandGetVCSType(expand('%')) == 'SVN'
+ let fullCmd = VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' ' . a:cmd
+ return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText)
+ else
+ throw 'SVN VCSCommand plugin called on non-SVN item.'
+ endif
endfunction
" Section: VCS function implementations {{{1
@@ -68,12 +75,12 @@
function! s:svnFunctions.Identify(buffer)
let fileName = resolve(bufname(a:buffer))
if isdirectory(fileName)
- let directory = fileName
- else
- let directory = fnamemodify(fileName, ':h')
- endif
- if strlen(directory) > 0
- let svnDir = directory . '/.svn'
+ let directoryName = fileName
+ else
+ let directoryName = fnamemodify(fileName, ':h')
+ endif
+ if strlen(directoryName) > 0
+ let svnDir = directoryName . '/.svn'
else
let svnDir = '.svn'
endif
@@ -86,7 +93,7 @@
" Function: s:svnFunctions.Add() {{{2
function! s:svnFunctions.Add(argList)
- return s:DoCommand('add', 'add', '')
+ return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '))
endfunction
" Function: s:svnFunctions.Annotate(argList) {{{2
@@ -94,22 +101,21 @@
if len(a:argList) == 0
if &filetype == 'SVNAnnotate'
" Perform annotation of the version indicated by the current line.
- let revision = matchstr(getline('.'),'\v^\s+\zs\d+')
+ let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
+ let options = ' -r' . caption
else
- let revision=VCSCommandGetRevision()
- if revision == ''
- throw 'Unable to obtain version information.'
- elseif revision == 'Unknown'
- throw 'File not under source control'
- elseif revision == 'New'
- throw 'No annotatation available for new file.'
- endif
+ let caption = ''
+ let options = ''
endif
- else
- let revision=a:argList[0]
- endif
-
- let resultBuffer=s:DoCommand('blame -r' . revision, 'annotate', revision)
+ elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
+ let caption = a:argList[0]
+ let options = ' -r' . caption
+ else
+ let caption = join(a:argList, ' ')
+ let options = ' ' . caption
+ endif
+
+ let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption)
if resultBuffer > 0
set filetype=SVNAnnotate
endif
@@ -124,32 +130,46 @@
endif
endfunction
+" Function: s:svnFunctions.Delete() {{{2
+function! s:svnFunctions.Delete(argList)
+ return s:DoCommand(join(['delete'] + a:argList, ' '), 'delete', join(a:argList, ' '))
+endfunction
+
" Function: s:svnFunctions.Diff(argList) {{{2
function! s:svnFunctions.Diff(argList)
- if len(a:argList) == 1
- let revOptions = ' -r' . a:argList[0]
- let caption = '(' . a:argList[0] . ' : current)'
- elseif len(a:argList) == 2
- let revOptions = ' -r' . a:argList[0] . ':' . a:argList[1]
- let caption = '(' . a:argList[0] . ' : ' . a:argList[1] . ')'
- else
- let revOptions = ''
+ if len(a:argList) == 0
+ let revOptions = []
let caption = ''
- endif
-
- let svndiffopt = VCSCommandGetOption('VCSCommandSVNDiffOpt', '')
-
- if svndiffopt == ''
- let diffoptionstring = ''
- else
- let diffoptionstring = ' -x -' . svndiffopt . ' '
- endif
-
- let resultBuffer = s:DoCommand('diff' . diffoptionstring . revOptions , 'diff', caption)
+ elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
+ let revOptions = ['-r' . join(a:argList, ':')]
+ let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
+ else
+ " Pass-through
+ let caption = join(a:argList, ' ')
+ let revOptions = a:argList
+ endif
+
+ let svnDiffExt = VCSCommandGetOption('VCSCommandSVNDiffExt', '')
+ if svnDiffExt == ''
+ let diffExt = []
+ else
+ let diffExt = ['--diff-cmd ' . svnDiffExt]
+ endif
+
+ let svnDiffOpt = VCSCommandGetOption('VCSCommandSVNDiffOpt', '')
+ if svnDiffOpt == ''
+ let diffOptions = []
+ else
+ let diffOptions = ['-x -' . svnDiffOpt]
+ endif
+
+ let resultBuffer = s:DoCommand(join(['diff'] + diffExt + diffOptions + revOptions), 'diff', caption)
if resultBuffer > 0
set filetype=diff
else
- echomsg 'No differences found'
+ if svnDiffExt == ''
+ echomsg 'No differences found'
+ endif
endif
return resultBuffer
endfunction
@@ -161,54 +181,54 @@
" Returns: List of results: [revision, repository, branch]
function! s:svnFunctions.GetBufferInfo()
- let originalBuffer=VCSCommandGetOriginalBuffer(bufnr('%'))
- let fileName=bufname(originalBuffer)
- let realFileName = fnamemodify(resolve(fileName), ':t')
- if !filereadable(fileName)
+ let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
+ let fileName = bufname(originalBuffer)
+ let statusText = system(VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' status -vu "' . fileName . '"')
+ if(v:shell_error)
+ return []
+ endif
+
+ " File not under SVN control.
+ if statusText =~ '^?'
return ['Unknown']
endif
- let oldCwd=VCSCommandChangeToCurrentFileDir(fileName)
- try
- let statusText=system(VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' status -vu "' . realFileName . '"')
- if(v:shell_error)
- return []
- endif
-
- " File not under SVN control.
- if statusText =~ '^?'
- return ['Unknown']
- endif
-
- let [flags, revision, repository] = matchlist(statusText, '^\(.\{8}\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s')[1:3]
- if revision == ''
- " Error
- return ['Unknown']
- elseif flags =~ '^A'
- return ['New', 'New']
- else
- return [revision, repository]
- endif
- finally
- execute 'cd' escape(oldCwd, ' ')
- endtry
+
+ let [flags, revision, repository] = matchlist(statusText, '^\(.\{8}\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s')[1:3]
+ if revision == ''
+ " Error
+ return ['Unknown']
+ elseif flags =~ '^A'
+ return ['New', 'New']
+ else
+ return [revision, repository]
+ endif
+endfunction
+
+" Function: s:svnFunctions.Info(argList) {{{2
+function! s:svnFunctions.Info(argList)
+ return s:DoCommand(join(['info'] + a:argList, ' '), 'info', join(a:argList, ' '))
endfunction
" Function: s:svnFunctions.Lock(argList) {{{2
function! s:svnFunctions.Lock(argList)
- return s:DoCommand('lock', 'lock', '')
-endfunction
-
-" Function: s:svnFunctions.Log() {{{2
+ return s:DoCommand(join(['lock'] + a:argList, ' '), 'lock', join(a:argList, ' '))
+endfunction
+
+" Function: s:svnFunctions.Log(argList) {{{2
function! s:svnFunctions.Log(argList)
if len(a:argList) == 0
- let versionOption = ''
+ let options = []
let caption = ''
- else
- let versionOption=' -r' . a:argList[0]
- let caption = a:argList[0]
- endif
-
- let resultBuffer=s:DoCommand('log -v' . versionOption, 'log', caption)
+ elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
+ let options = ['-r' . join(a:argList, ':')]
+ let caption = options[0]
+ else
+ " Pass-through
+ let options = a:argList
+ let caption = join(a:argList, ' ')
+ endif
+
+ let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption)
return resultBuffer
endfunction
@@ -229,58 +249,28 @@
let resultBuffer = s:DoCommand('cat' . versionOption, 'review', versiontag)
if resultBuffer > 0
- let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
+ let &filetype = getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
endif
return resultBuffer
endfunction
" Function: s:svnFunctions.Status(argList) {{{2
function! s:svnFunctions.Status(argList)
- return s:DoCommand('status -u -v', 'status', '')
+ let options = ['-u', '-v']
+ if len(a:argList) == 0
+ let options = a:argList
+ endif
+ return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '))
endfunction
" Function: s:svnFunctions.Unlock(argList) {{{2
function! s:svnFunctions.Unlock(argList)
- return s:DoCommand('unlock', 'unlock', '')
+ return s:DoCommand(join(['unlock'] + a:argList, ' '), 'unlock', join(a:argList, ' '))
endfunction
" Function: s:svnFunctions.Update(argList) {{{2
function! s:svnFunctions.Update(argList)
return s:DoCommand('update', 'update', '')
endfunction
-" Section: SVN-specific functions {{{1
-
-" Function: s:SVNInfo() {{{2
-function! s:SVNInfo()
- return s:DoCommand('info', 'svninfo', '')
-endfunction
-
-" Section: Command definitions {{{1
-" Section: Primary commands {{{2
-com! SVNInfo call s:SVNInfo()
-
-" Section: Plugin command mappings {{{1
-
-let s:svnExtensionMappings = {}
-let mappingInfo = [['SVNInfo', 'SVNInfo', 'ci']]
-for [pluginName, commandText, shortCut] in mappingInfo
- execute 'nnoremap <silent> <Plug>' . pluginName . ' :' . commandText . '<CR>'
- if !hasmapto('<Plug>' . pluginName)
- let s:svnExtensionMappings[shortCut] = commandText
- endif
-endfor
-
-
-" Section: Menu items {{{1
-amenu <silent> &Plugin.VCS.SVN.&Info <Plug>SVNInfo
-
" Section: Plugin Registration {{{1
-" If the vcscommand.vim plugin hasn't loaded, delay registration until it
-" loads.
-if exists('g:loaded_VCSCommand')
- call VCSCommandRegisterModule('SVN', expand('<sfile>'), s:svnFunctions, s:svnExtensionMappings)
-else
- augroup VCSCommand
- au User VCSLoadExtensions call VCSCommandRegisterModule('SVN', expand('<sfile>'), s:svnFunctions, s:svnExtensionMappings)
- augroup END
-endif
+call VCSCommandRegisterModule('SVN', expand('<sfile>'), s:svnFunctions, [])
More information about the pkg-vim-maintainers
mailing list