[SCM] vim-scripts packaging branch, master, updated. v20091011-30-gc476b42
James Vega
jamessan at debian.org
Sun Aug 14 03:26:57 UTC 2011
The following commit has been merged in the master branch:
commit 97f5f1001cc4cd20f090af60c085f3cd3dc3e65d
Author: James Vega <jamessan at debian.org>
Date: Sat Jun 25 23:05:06 2011 -0400
Update supertab to 1.5
Signed-off-by: James Vega <jamessan at debian.org>
diff --git a/debian/changelog b/debian/changelog
index c04ff77..5186da8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,7 +3,7 @@ vim-scripts (20091012) UNRELEASED; urgency=low
* Rename "colors sampler pack" to "colors-sampler-pack" so it's easier to
manage with vim-addon-manager. (Closes: #555621)
* Updated addons:
- - supertab: Updated to 1.0
+ - supertab: Updated to 1.5
- DoxygenToolkit: Update to 0.2.7
- Color Sampler Pack: Update to 8.03
- vcscommand: Update to 1.99.35
diff --git a/debian/vim-scripts.status b/debian/vim-scripts.status
index 35da885..657c2bc 100644
--- a/debian/vim-scripts.status
+++ b/debian/vim-scripts.status
@@ -322,7 +322,7 @@ email: ervandew at gmail.com
license: BSD, see /usr/share/common-licenses/BSD
extras: doc/supertab.txt
disabledby: let loaded_supertab = 1
-version: 1.0
+version: 1.5
script_name: plugin/lbdbq.vim
addon: lbdbq
diff --git a/doc/supertab.txt b/doc/supertab.txt
index 3eadefe..038bcb5 100644
--- a/doc/supertab.txt
+++ b/doc/supertab.txt
@@ -15,20 +15,21 @@ supertab.vim for the license in its entirety.
==============================================================================
Supertab *supertab*
-1. Introduction |supertab-intro|
-2. Supertab Usage |supertab-usage|
-3. Supertab Options |supertab-options|
- Default completion type |supertab-defaultcompletion|
- Secondary default completion type |supertab-contextdefault|
- Completion contexts |supertab-completioncontexts|
- Context text |supertab-contexttext|
- Context Discover |supertab-contextdiscover|
- Example |supertab-contextexample|
- Completion Duration |supertab-duration|
- Midword completion |supertab-midword|
- Changing default mapping |supertab-forwardbackward|
- Inserting true tabs |supertab-mappingtabliteral|
- Preselecting the first entry |supertab-longesthighlight|
+1. Introduction |supertab-intro|
+2. Supertab Usage |supertab-usage|
+3. Supertab Options |supertab-options|
+ Default completion type |supertab-defaultcompletion|
+ Secondary default completion type |supertab-contextdefault|
+ Completion contexts |supertab-completioncontexts|
+ Context text |supertab-contexttext|
+ Context Discover |supertab-contextdiscover|
+ Example |supertab-contextexample|
+ Completion Duration |supertab-duration|
+ Preventing Completion After/Before... |supertab-preventcomplete|
+ Changing default mapping |supertab-forwardbackward|
+ Inserting true tabs |supertab-mappingtabliteral|
+ Enhanced longest match support |supertab-longestenhanced|
+ Preselecting the first entry |supertab-longesthighlight|
==============================================================================
1. Introduction *supertab-intro*
@@ -60,48 +61,6 @@ Supertab is configured via several global variables that you can set in your
|vimrc| file according to your needs. Below is a comprehensive list of
the variables available.
-g:SuperTabDefaultCompletionType |supertab-defaultcompletion|
- The default completion type to use. If you program in languages that support
- omni or user completions, it is highly recommended setting this to
- 'context'.
-
- For help about built in completion types in vim, see |i_CTRL-X_index|.
-
-g:SuperTabContextDefaultCompletionType |supertab-contextdefault|
- The default completion type to use when 'context' is the global default, but
- context completion has determined that neither omni, user, or file
- completion should be used in the current context.
-
-g:SuperTabCompletionContexts |supertab-completioncontexts|
- Used to configure a list of function names which are used when the global
- default type is 'context'. These functions will be consulted in order to
- determine which completion type to use. Advanced users can plug in their own
- functions here to customize their 'context' completion.
-
-g:SuperTabRetainCompletionDuration |supertab-duration|
- This setting determines how long a non-default completion type should be
- retained as the temporary default. By default supertab will retain the
- alternate completion type until you leave insert mode.
-
-g:SuperTabMidWordCompletion |supertab-midword|
- This can be used to turn off completion if you are in the middle of a word
- (word characters immediately preceding and following the cursor).
-
-g:SuperTabMappingForward |supertab-forwardbackward|
-g:SuperTabMappingBackward |supertab-forwardbackward|
- If using the tab key for completion isn't for you, then you can use these to
- set an alternate key to be used for your insert completion needs.
-
-g:SuperTabMappingTabLiteral |supertab-mappingtabliteral|
- For those rare cases where supertab would normal want to start insert
- completion, but you just want to insert a tab, this setting is used to
- define the key combination to use to do just that. By default Ctrl-Tab is
- used.
-
-g:SuperTabLongestHighlight |supertab-longesthighlight|
- When enabled and you have the completion popup enable and 'longest' in your
- completeopt, supertab will auto highlight the first selection in the popup.
-
Default Completion Type *supertab-defaultcompletion*
*g:SuperTabDefaultCompletionType*
@@ -247,17 +206,24 @@ The possible values include:
mode.
-Midword completion *supertab-midword*
- *g:SuperTabMidWordCompletion*
+Preventing completion after... *supertab-preventcomplete*
+ *g:SuperTabNoCompleteBefore*
+ *g:SuperTabNoCompleteAfter*
-g:SuperTabMidWordCompletion (default value: 1)
+g:SuperTabNoCompleteBefore (default value: [])
+g:SuperTabNoCompleteAfter (default value: ['\s'])
-Sets whether or not mid word completion is enabled. When enabled, <tab> will
-kick off completion when ever a non whitespace character is to the left of the
-cursor. When disabled, completion will only occur if the char to the left is
-non whitespace char and the char to the right is not a keyword character (you
-are at the end of the word).
+These two variables are used to control when supertab will attempt completion
+or instead fall back to inserting a literal <tab>, by specifying a list of
+patterns which are tested against the text before and after the current cursor
+position that when matched, prevent completion. So if you don't want supertab
+to start completion after a comma or space, you can set
+g:SuperTabNoCompleteAfter to [',', '\s'].
+Note: That a buffer local version of these variables
+(b:SuperTabNoCompleteBefore, b:SuperTabNoCompleteAfter) is also supported
+should you wish to have different values depending on the file type for
+instance.
Changing the default mapping *supertab-forwardbackward*
*g:SuperTabMappingForward*
@@ -295,6 +261,31 @@ something that is supported. Alternatively, you can escape the <tab> with
<c-v> (see |i_CTRL-V| for more infos).
+Enhanced longest match support *supertab-longestenhanced*
+ *g:SuperTabLongestEnhanced*
+
+g:SuperTabLongestEnhanced (default value: 0)
+
+When enabled and 'longest' is in your |completeopt| setting, supertab will
+provide an enhanced longest match support where typing one or more letters and
+hitting tab again while in a completion mode will complete the longest common
+match using the new text in the buffer.
+
+For example, say you have a buffer with the following contents:
+ FooBarFoo
+ FooBar
+ Foo
+ FooBarBaz
+And you then type F<tab>. Vim's builtin longest support will complete the
+longest common text 'Foo' and offer 'FooBarFoo', 'FooBar', 'Foo', and
+'FooBarBaz' as possible completions. With supertab's longest match
+enhancement disabled, typing B<tab> while still in the completion mode will
+end up completing 'FooBarBaz' or 'FooBarFoo' depending your settings, instead
+of the next longest common match of 'FooBar'. With supertab's enhanced
+longest match feature enabled, the typing of B<tab> will result in the next
+longest text being completed.
+
+
Preselecting the first entry *supertab-longesthighlight*
*g:SuperTabLongestHighlight*
@@ -305,4 +296,12 @@ popup menu enabled and the 'longest' option as well. When enabled, <tab> will
kick off completion and pre-select the first entry in the popup menu, allowing
you to simply hit <enter> to use it.
+
+Mapping <cr> to end completion *supertab-crmapping*
+ *g:SuperTabCrMapping*
+
+g:SuperTabCrMapping (default value: 1)
+
+When enabled, <cr> will cancel completion mode preserving the current text.
+
vim:tw=78:ts=8:ft=help:norl:
diff --git a/html/index.html b/html/index.html
index 68b6ef6..5dd31e7 100644
--- a/html/index.html
+++ b/html/index.html
@@ -50,7 +50,7 @@
<li><a href="syntax_mkd.vim.html">syntax/mkd.vim.html</a></li>
</ul>
<p>
- Page generated on Sat, 25 Jun 2011 22:56:54 -0400
+ Page generated on Sat, 25 Jun 2011 23:04:12 -0400
.
</p>
</body>
diff --git a/html/plugin_supertab.vim.html b/html/plugin_supertab.vim.html
index ede55ec..51081a7 100644
--- a/html/plugin_supertab.vim.html
+++ b/html/plugin_supertab.vim.html
@@ -166,8 +166,14 @@
<tr>
<td class="lightbg"><b> script karma </b></td>
<td>
- Rating <b>1081/332</b>,
- Downloaded by 21205 </td>
+ Rating <b>1586/486</b>,
+ Downloaded by 37810 </td>
+ <td class="lightbg">
+ <b> Comments, bugs, improvements </b>
+ </td>
+ <td>
+ <a href="http://vim.wikia.com/wiki/Script:1643">Vim wiki</a>
+ </td>
</tr>
</table>
<p>
@@ -180,7 +186,7 @@
<tr><td>utility</td></tr>
<tr><td> </td></tr>
<tr><td class="prompt">description</td></tr>
-<tr><td>Supertab aims to provide tab completion to satisfy all your insert completion
<br>needs (:help ins-completion).
<br>
<br>This version is a continuation of <a href="/scripts/script.php?script_id=182">vimscript #182</a> by Gergely Kontra, who has
<br>asked me to take over support and maintenance. This version contains many
<br>enhancements.
<br>
<br>You can also find supertab in my vimfiles github repository:
<br><a target="_blank" href="http://github.com/ervandew/vimfiles">http://github.com/ervandew/vimfiles</A>
<br>
<br>Supertab provides several features to enhance your insert completion
<br>experience:
<br>- You can set your favorite insert completion type (keyword, omni, etc.) as
<br> supertab's default.
<br>- When using another completion type (ctrl-x ctrl-f), supertab will
<br> temporarily make that the default allowing you to continue to use tab for
<br> that completion. The duration is configurable to one of 'completion'
<br> (retained until you exit the current completion mode), 'insert' (retained
<br> until you leave insert mode), or 'session' (retained for the remainder of
<br> your vim session).
<br>- Supertab provides a 'context' completion type which examines the text
<br> preceding the cursor to decide which type of completion should be used
<br> (omni, user, file, or keyword). You can also plug in your own functions
<br> which will be used to determine which completion type to use according to
<br> your new functionality.
<br>- The 'context' completion can also be used to set the default completion type
<br> according to what the file supports, based on a discovery mechanism which
<br> you specify.
<br>- For users not yet familiar with all the various insert completion types that
<br> vim supports, supertab also provides a :SuperTabHelp command which opens a
<br> temporary buffer listing all the available types and the ability to easily
<br> switch to that type.
<br>
<br>After installing, see the supertab help for more information (:h supertab).
<br></td></tr>
+<tr><td>Supertab aims to provide tab completion to satisfy all your insert completion
<br>needs (:help ins-completion).
<br>
<br>This version is a continuation of <a href="/scripts/script.php?script_id=182">vimscript #182</a> by Gergely Kontra, who has
<br>asked me to take over support and maintenance. This version contains many
<br>enhancements.
<br>
<br>You can also find supertab in my github repository:
<br><a target="_blank" href="http://github.com/ervandew/supertab">http://github.com/ervandew/supertab</A>
<br>
<br>Supertab provides several features to enhance your insert completion
<br>experience:
<br>- You can set your favorite insert completion type (keyword, omni, etc.) as
<br> supertab's default.
<br>- When using another completion type (ctrl-x ctrl-f), supertab will
<br> temporarily make that the default allowing you to continue to use tab for
<br> that completion. The duration is configurable to one of 'completion'
<br> (retained until you exit the current completion mode), 'insert' (retained
<br> until you leave insert mode), or 'session' (retained for the remainder of
<br> your vim session).
<br>- Supertab provides a 'context' completion type which examines the text
<br> preceding the cursor to decide which type of completion should be used
<br> (omni, user, file, or keyword). You can also plug in your own functions
<br> which will be used to determine which completion type to use according to
<br> your new functionality.
<br>- The 'context' completion can also be used to set the default completion type
<br> according to what the file supports, based on a discovery mechanism which
<br> you specify.
<br>- For users not yet familiar with all the various insert completion types that
<br> vim supports, supertab also provides a :SuperTabHelp command which opens a
<br> temporary buffer listing all the available types and the ability to easily
<br> switch to that type.
<br>
<br>After installing, see the supertab help for more information (:h supertab).
<br></td></tr>
<tr><td> </td></tr>
<tr><td class="prompt">install details</td></tr>
<tr><td>1. Download supertab.vba to any directory.
<br>2. Open the file in vim ($ vim supertab.vba).
<br>3. Source the file (:so %).</td></tr>
@@ -217,116 +223,156 @@ Click on the package to download.
<th valign="top">release notes</th>
</tr>
<tr>
- <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=11853">supertab.vba</a></td>
- <td class="rowodd" valign="top" nowrap><b>1.0</b></td>
- <td class="rowodd" valign="top" nowrap><i>2009-12-03</i></td>
+ <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=15029">supertab.vba</a></td>
+ <td class="rowodd" valign="top" nowrap><b>1.5</b></td>
+ <td class="rowodd" valign="top" nowrap><i>2011-02-16</i></td>
<td class="rowodd" valign="top" nowrap>7.0</td>
<td class="rowodd" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
- <td class="rowodd" valign="top" width="2000">- fixed reverse cycling through result when using <c-n> completion
<br>- now distributed as a vimball with a help file (:h supertab). Thanks to Christophe-Marie Duquesne.</td>
+ <td class="rowodd" valign="top" width="2000">- updated to support user mapped <c-n>/<c-p>
<br>- fix logic to decide whether to scroll up or down based on current completion context
<br>- fix <c-x><c-*> w/ longest enhancement enabled</td>
</tr>
<tr>
- <td class="roweven" valign="top" nowrap><a href="download_script.php?src_id=11533">supertab.vim</a></td>
- <td class="roweven" valign="top" nowrap><b>0.61</b></td>
- <td class="roweven" valign="top" nowrap><i>2009-10-16</i></td>
+ <td class="roweven" valign="top" nowrap><a href="download_script.php?src_id=14882">supertab.vba</a></td>
+ <td class="roweven" valign="top" nowrap><b>1.4</b></td>
+ <td class="roweven" valign="top" nowrap><i>2011-01-27</i></td>
<td class="roweven" valign="top" nowrap>7.0</td>
<td class="roweven" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
- <td class="roweven" valign="top" width="2000">Fixed a possible error that may occur in some rare conditions.</td>
+ <td class="roweven" valign="top" width="2000">Fix error that occurs attempting to complete after optional alternate completion mapping or :SuperTabHelp have set the completion type.</td>
</tr>
<tr>
- <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=11386">supertab.vim</a></td>
- <td class="rowodd" valign="top" nowrap><b>0.60</b></td>
- <td class="rowodd" valign="top" nowrap><i>2009-09-16</i></td>
+ <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=14782">supertab.vba</a></td>
+ <td class="rowodd" valign="top" nowrap><b>1.3</b></td>
+ <td class="rowodd" valign="top" nowrap><i>2011-01-18</i></td>
<td class="rowodd" valign="top" nowrap>7.0</td>
<td class="rowodd" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
- <td class="rowodd" valign="top" width="2000">- Refactored the contextual completion and default discovery support.
<br> - Context completion now supports plugable functions to determine which
<br> completion type to use.
<br> - Default discovery is now a part of context completion.
<br>- NOTE: Several non-backwards compatible configuration changes where made.
<br> - g:SuperTabRetainCompletionType is now g:SuperTabRetainCompletionDuration
<br> and accepts one of 'none', 'insert', or 'session'.
<br> - new setting g:SuperTabCompletionContexts defines which context completion
<br> functions are consulted.
<br> - g:SuperTabDefaultCompletionTypeDiscovery is now
<br> g:SuperTabContextDiscoverDiscovery and requires that
<br> g:SuperTabContextDefaultCompletionType is set to 'context' and that
<br> 's:ContextDiscover' is in your g:SuperTabCompletionContexts list.
<br>Please see the updated "Global Variables" fold in supertab.vim for additional
<br>details and examples.</td>
+ <td class="rowodd" valign="top" width="2000">- fix error attempting tab completion if buffer was loaded with no autocmds fired
<br>- fix tabbing through completion results with longest enabled when the longest text expanded is the empty string.</td>
</tr>
<tr>
- <td class="roweven" valign="top" nowrap><a href="download_script.php?src_id=10998">supertab.vim</a></td>
- <td class="roweven" valign="top" nowrap><b>0.51</b></td>
- <td class="roweven" valign="top" nowrap><i>2009-07-11</i></td>
+ <td class="roweven" valign="top" nowrap><a href="download_script.php?src_id=14717">supertab.vba</a></td>
+ <td class="roweven" valign="top" nowrap><b>1.2</b></td>
+ <td class="roweven" valign="top" nowrap><i>2011-01-09</i></td>
<td class="roweven" valign="top" nowrap>7.0</td>
<td class="roweven" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
- <td class="roweven" valign="top" width="2000">Replaced internal function s:IsWordChar with vim's keyword character class (Thanks to Ingo Karkat for the patch).</td>
+ <td class="roweven" valign="top" width="2000">- fix to not break abbreviation expansion on <cr>
<br>- when using longest enhancement, save/restore any previous mappings for <bs>/<c-h>
<br>- fix <cr> mapping to cooperate better with <cr> mappings of other plugins (ex. endwise)
<br>- created variables to set user defined list of before or after patterns for which completion should not be attempted (:h supertab-preventcomplete)</td>
</tr>
<tr>
- <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=10900">supertab.vim</a></td>
- <td class="rowodd" valign="top" nowrap><b>0.50</b></td>
- <td class="rowodd" valign="top" nowrap><i>2009-06-26</i></td>
+ <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=13928">supertab.vba</a></td>
+ <td class="rowodd" valign="top" nowrap><b>1.1</b></td>
+ <td class="rowodd" valign="top" nowrap><i>2010-09-27</i></td>
<td class="rowodd" valign="top" nowrap>7.0</td>
<td class="rowodd" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
- <td class="rowodd" valign="top" width="2000">Added check for vim 7 or greater, otherwise disable supertab support (suggested by Vincent Lee). Also, removed any remaining pre vim 7 logic that is no longer applicable.</td>
+ <td class="rowodd" valign="top" width="2000">- added optional default <cr> mapping to end completion mode (enabled by default)
<br>- added support for an enhanced longest match completion (disabled by default)
<br>- other minor enhancements + bug fixes</td>
</tr>
<tr>
- <td class="roweven" valign="top" nowrap><a href="download_script.php?src_id=9918">supertab.vim</a></td>
- <td class="roweven" valign="top" nowrap><b>0.49</b></td>
- <td class="roweven" valign="top" nowrap><i>2009-02-05</i></td>
+ <td class="roweven" valign="top" nowrap><a href="download_script.php?src_id=11853">supertab.vba</a></td>
+ <td class="roweven" valign="top" nowrap><b>1.0</b></td>
+ <td class="roweven" valign="top" nowrap><i>2009-12-03</i></td>
<td class="roweven" valign="top" nowrap>7.0</td>
<td class="roweven" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
- <td class="roweven" valign="top" width="2000">fixed case where new buffer may not be initialized by super tab (thanks to Tammer Saleh for reporting the issue).</td>
+ <td class="roweven" valign="top" width="2000">- fixed reverse cycling through result when using <c-n> completion
<br>- now distributed as a vimball with a help file (:h supertab). Thanks to Christophe-Marie Duquesne.</td>
</tr>
<tr>
- <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=9837">supertab.vim</a></td>
- <td class="rowodd" valign="top" nowrap><b>0.48</b></td>
- <td class="rowodd" valign="top" nowrap><i>2009-01-18</i></td>
+ <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=11533">supertab.vim</a></td>
+ <td class="rowodd" valign="top" nowrap><b>0.61</b></td>
+ <td class="rowodd" valign="top" nowrap><i>2009-10-16</i></td>
<td class="rowodd" valign="top" nowrap>7.0</td>
<td class="rowodd" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
- <td class="rowodd" valign="top" width="2000">Fixed command line completion (ctrl-x ctrl-v) when invoked from supertab. Thanks to Frank Chang for the patch.</td>
+ <td class="rowodd" valign="top" width="2000">Fixed a possible error that may occur in some rare conditions.</td>
</tr>
<tr>
- <td class="roweven" valign="top" nowrap><a href="download_script.php?src_id=9795">supertab.vim</a></td>
- <td class="roweven" valign="top" nowrap><b>0.47</b></td>
- <td class="roweven" valign="top" nowrap><i>2009-01-11</i></td>
+ <td class="roweven" valign="top" nowrap><a href="download_script.php?src_id=11386">supertab.vim</a></td>
+ <td class="roweven" valign="top" nowrap><b>0.60</b></td>
+ <td class="roweven" valign="top" nowrap><i>2009-09-16</i></td>
<td class="roweven" valign="top" nowrap>7.0</td>
<td class="roweven" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
- <td class="roweven" valign="top" width="2000">fixed issue with default completion discovery option if desired type is dependent on file type plugins. Thanks to Andreas Schneider for reporting the issue.</td>
+ <td class="roweven" valign="top" width="2000">- Refactored the contextual completion and default discovery support.
<br> - Context completion now supports plugable functions to determine which
<br> completion type to use.
<br> - Default discovery is now a part of context completion.
<br>- NOTE: Several non-backwards compatible configuration changes where made.
<br> - g:SuperTabRetainCompletionType is now g:SuperTabRetainCompletionDuration
<br> and accepts one of 'none', 'insert', or 'session'.
<br> - new setting g:SuperTabCompletionContexts defines which context completion
<br> functions are consulted.
<br> - g:SuperTabDefaultCompletionTypeDiscovery is now
<br> g:SuperTabContextDiscoverDiscovery and requires that
<br> g:SuperTabContextDefaultCompletionType is set to 'context' and that
<br> 's:ContextDiscover' is in your g:SuperTabCompletionContexts list.
<br>Please see the updated "Global Variables" fold in supertab.vim for additional
<br>details and examples.</td>
</tr>
<tr>
- <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=9510">supertab.vim</a></td>
- <td class="rowodd" valign="top" nowrap><b>0.46</b></td>
- <td class="rowodd" valign="top" nowrap><i>2008-11-15</i></td>
+ <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=10998">supertab.vim</a></td>
+ <td class="rowodd" valign="top" nowrap><b>0.51</b></td>
+ <td class="rowodd" valign="top" nowrap><i>2009-07-11</i></td>
<td class="rowodd" valign="top" nowrap>7.0</td>
<td class="rowodd" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
- <td class="rowodd" valign="top" width="2000">Added support for default completion type 'context', which will result in super tab attempting to determine which completion type to use (file, user/omni, keyword) based on the text preceding the cursor (Based on suggestion by François Beaubert).
<br></td>
+ <td class="rowodd" valign="top" width="2000">Replaced internal function s:IsWordChar with vim's keyword character class (Thanks to Ingo Karkat for the patch).</td>
</tr>
<tr>
- <td class="roweven" valign="top" nowrap><a href="download_script.php?src_id=8070">supertab.vim</a></td>
- <td class="roweven" valign="top" nowrap><b>0.45</b></td>
- <td class="roweven" valign="top" nowrap><i>2007-12-18</i></td>
- <td class="roweven" valign="top" nowrap>6.0</td>
+ <td class="roweven" valign="top" nowrap><a href="download_script.php?src_id=10900">supertab.vim</a></td>
+ <td class="roweven" valign="top" nowrap><b>0.50</b></td>
+ <td class="roweven" valign="top" nowrap><i>2009-06-26</i></td>
+ <td class="roweven" valign="top" nowrap>7.0</td>
+ <td class="roweven" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
+ <td class="roweven" valign="top" width="2000">Added check for vim 7 or greater, otherwise disable supertab support (suggested by Vincent Lee). Also, removed any remaining pre vim 7 logic that is no longer applicable.</td>
+</tr>
+<tr>
+ <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=9918">supertab.vim</a></td>
+ <td class="rowodd" valign="top" nowrap><b>0.49</b></td>
+ <td class="rowodd" valign="top" nowrap><i>2009-02-05</i></td>
+ <td class="rowodd" valign="top" nowrap>7.0</td>
+ <td class="rowodd" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
+ <td class="rowodd" valign="top" width="2000">fixed case where new buffer may not be initialized by super tab (thanks to Tammer Saleh for reporting the issue).</td>
+</tr>
+<tr>
+ <td class="roweven" valign="top" nowrap><a href="download_script.php?src_id=9837">supertab.vim</a></td>
+ <td class="roweven" valign="top" nowrap><b>0.48</b></td>
+ <td class="roweven" valign="top" nowrap><i>2009-01-18</i></td>
+ <td class="roweven" valign="top" nowrap>7.0</td>
<td class="roweven" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
- <td class="roweven" valign="top" width="2000">- fixed possible completion error on first buffer as supertab may not have been properly initialized (thanks to bill emmons for discovering the error).</td>
+ <td class="roweven" valign="top" width="2000">Fixed command line completion (ctrl-x ctrl-v) when invoked from supertab. Thanks to Frank Chang for the patch.</td>
</tr>
<tr>
- <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=7904">supertab.vim</a></td>
- <td class="rowodd" valign="top" nowrap><b>0.44</b></td>
- <td class="rowodd" valign="top" nowrap><i>2007-11-08</i></td>
+ <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=9795">supertab.vim</a></td>
+ <td class="rowodd" valign="top" nowrap><b>0.47</b></td>
+ <td class="rowodd" valign="top" nowrap><i>2009-01-11</i></td>
+ <td class="rowodd" valign="top" nowrap>7.0</td>
+ <td class="rowodd" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
+ <td class="rowodd" valign="top" width="2000">fixed issue with default completion discovery option if desired type is dependent on file type plugins. Thanks to Andreas Schneider for reporting the issue.</td>
+</tr>
+<tr>
+ <td class="roweven" valign="top" nowrap><a href="download_script.php?src_id=9510">supertab.vim</a></td>
+ <td class="roweven" valign="top" nowrap><b>0.46</b></td>
+ <td class="roweven" valign="top" nowrap><i>2008-11-15</i></td>
+ <td class="roweven" valign="top" nowrap>7.0</td>
+ <td class="roweven" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
+ <td class="roweven" valign="top" width="2000">Added support for default completion type 'context', which will result in super tab attempting to determine which completion type to use (file, user/omni, keyword) based on the text preceding the cursor (Based on suggestion by François Beaubert).
<br></td>
+</tr>
+<tr>
+ <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=8070">supertab.vim</a></td>
+ <td class="rowodd" valign="top" nowrap><b>0.45</b></td>
+ <td class="rowodd" valign="top" nowrap><i>2007-12-18</i></td>
<td class="rowodd" valign="top" nowrap>6.0</td>
<td class="rowodd" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
- <td class="rowodd" valign="top" width="2000">- added config variable to specify discovery list used to determine the default completion type to use for the current buffer. (based on request by Den Yao)
<br>- added config variables to changed the default mappings for forward backwards completion. (based on request by Li Chaoqun)
<br>- added config variable to preselect the first entry when completeopt has 'menu' and 'longest'. (based on suggestion and patch by Mike Lundy)</td>
+ <td class="rowodd" valign="top" width="2000">- fixed possible completion error on first buffer as supertab may not have been properly initialized (thanks to bill emmons for discovering the error).</td>
</tr>
<tr>
- <td class="roweven" valign="top" nowrap><a href="download_script.php?src_id=7344">supertab.vim</a></td>
- <td class="roweven" valign="top" nowrap><b>0.43</b></td>
- <td class="roweven" valign="top" nowrap><i>2007-07-12</i></td>
+ <td class="roweven" valign="top" nowrap><a href="download_script.php?src_id=7904">supertab.vim</a></td>
+ <td class="roweven" valign="top" nowrap><b>0.44</b></td>
+ <td class="roweven" valign="top" nowrap><i>2007-11-08</i></td>
<td class="roweven" valign="top" nowrap>6.0</td>
<td class="roweven" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
- <td class="roweven" valign="top" width="2000">With the permission of the original author, this script is now released under the BSD license.</td>
+ <td class="roweven" valign="top" width="2000">- added config variable to specify discovery list used to determine the default completion type to use for the current buffer. (based on request by Den Yao)
<br>- added config variables to changed the default mappings for forward backwards completion. (based on request by Li Chaoqun)
<br>- added config variable to preselect the first entry when completeopt has 'menu' and 'longest'. (based on suggestion and patch by Mike Lundy)</td>
</tr>
<tr>
- <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=7228">supertab.vim</a></td>
- <td class="rowodd" valign="top" nowrap><b>0.42</b></td>
- <td class="rowodd" valign="top" nowrap><i>2007-06-11</i></td>
+ <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=7344">supertab.vim</a></td>
+ <td class="rowodd" valign="top" nowrap><b>0.43</b></td>
+ <td class="rowodd" valign="top" nowrap><i>2007-07-12</i></td>
<td class="rowodd" valign="top" nowrap>6.0</td>
<td class="rowodd" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
- <td class="rowodd" valign="top" width="2000">- Added g:SuperTabMidWordCompletion variable to determine if completion should be done within a word (enabled by default). (based on request by Charles Gruenwald)
<br>- Applied patch to fix <s-tab> cycling through completion results. (submitted by Lukasz Krotowski)
<br></td>
+ <td class="rowodd" valign="top" width="2000">With the permission of the original author, this script is now released under the BSD license.</td>
</tr>
<tr>
- <td class="roweven" valign="top" nowrap><a href="download_script.php?src_id=6114">supertab.vim</a></td>
- <td class="roweven" valign="top" nowrap><b>0.41</b></td>
- <td class="roweven" valign="top" nowrap><i>2006-08-30</i></td>
+ <td class="roweven" valign="top" nowrap><a href="download_script.php?src_id=7228">supertab.vim</a></td>
+ <td class="roweven" valign="top" nowrap><b>0.42</b></td>
+ <td class="roweven" valign="top" nowrap><i>2007-06-11</i></td>
<td class="roweven" valign="top" nowrap>6.0</td>
<td class="roweven" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
- <td class="roweven" valign="top" width="2000">Initial upload</td>
+ <td class="roweven" valign="top" width="2000">- Added g:SuperTabMidWordCompletion variable to determine if completion should be done within a word (enabled by default). (based on request by Charles Gruenwald)
<br>- Applied patch to fix <s-tab> cycling through completion results. (submitted by Lukasz Krotowski)
<br></td>
+</tr>
+<tr>
+ <td class="rowodd" valign="top" nowrap><a href="download_script.php?src_id=6114">supertab.vim</a></td>
+ <td class="rowodd" valign="top" nowrap><b>0.41</b></td>
+ <td class="rowodd" valign="top" nowrap><i>2006-08-30</i></td>
+ <td class="rowodd" valign="top" nowrap>6.0</td>
+ <td class="rowodd" valign="top"><i><a href="/account/profile.php?user_id=6016">Eric Van Dewoestine</a></i></td>
+ <td class="rowodd" valign="top" width="2000">Initial upload</td>
</tr>
</table>
<!-- finish off the framework -->
diff --git a/plugin/supertab.vim b/plugin/supertab.vim
index 48efda8..8b7d7bb 100644
--- a/plugin/supertab.vim
+++ b/plugin/supertab.vim
@@ -2,7 +2,7 @@
" Original: Gergely Kontra <kgergely at mcl.hu>
" Current: Eric Van Dewoestine <ervandew at gmail.com> (as of version 0.4)
" Please direct all correspondence to Eric.
-" Version: 1.0
+" Version: 1.5
" GetLatestVimScripts: 1643 1 :AutoInstall: supertab.vim
"
" Description: {{{
@@ -14,9 +14,7 @@
" }}}
"
" License: {{{
-" Software License Agreement (BSD License)
-"
-" Copyright (c) 2002 - 2009
+" Copyright (c) 2002 - 2011
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
@@ -84,8 +82,22 @@ set cpo&vim
let g:SuperTabRetainCompletionDuration = 'insert'
endif
- if !exists("g:SuperTabMidWordCompletion")
- let g:SuperTabMidWordCompletion = 1
+ if !exists("g:SuperTabNoCompleteBefore")
+ " retain backwards compatability
+ if exists("g:SuperTabMidWordCompletion") && !g:SuperTabMidWordCompletion
+ let g:SuperTabNoCompleteBefore = ['\k']
+ else
+ let g:SuperTabNoCompleteBefore = []
+ endif
+ endif
+
+ if !exists("g:SuperTabNoCompleteAfter")
+ " retain backwards compatability
+ if exists("g:SuperTabLeadingSpaceCompletion") && g:SuperTabLeadingSpaceCompletion
+ let g:SuperTabNoCompleteAfter = []
+ else
+ let g:SuperTabNoCompleteAfter = ['\s']
+ endif
endif
if !exists("g:SuperTabMappingForward")
@@ -99,10 +111,18 @@ set cpo&vim
let g:SuperTabMappingTabLiteral = '<c-tab>'
endif
+ if !exists("g:SuperTabLongestEnhanced")
+ let g:SuperTabLongestEnhanced = 0
+ endif
+
if !exists("g:SuperTabLongestHighlight")
let g:SuperTabLongestHighlight = 0
endif
+ if !exists("g:SuperTabCrMapping")
+ let g:SuperTabCrMapping = 1
+ endif
+
" }}}
" Script Variables {{{
@@ -162,6 +182,7 @@ endfunction " }}}
" restore SuperTab default:
" nmap <F6> :call SetSuperTabCompletionType("<c-p>")<cr>
function! SuperTabSetCompletionType(type)
+ call s:InitBuffer()
exec "let b:complType = \"" . escape(a:type, '<') . "\""
endfunction " }}}
@@ -187,26 +208,14 @@ function! SuperTabAlternateCompletion(type)
" vim into keyword completion mode and end that mode to prevent the regular
" insert behavior of <c-e> from occurring.
call feedkeys("\<c-x>\<c-p>\<c-e>", 'n')
- call feedkeys(b:complType)
+ call feedkeys(b:complType, 'n')
return ''
endfunction " }}}
" s:Init {{{
" Global initilization when supertab is loaded.
function! s:Init()
- augroup supertab_init
- autocmd!
- autocmd BufEnter * call <SID>InitBuffer()
- augroup END
-
- " ensure InitBuffer gets called for the first buffer, after the ftplugins
- " have been called.
- augroup supertab_init_first
- autocmd!
- autocmd FileType <buffer> call <SID>InitBuffer()
- augroup END
-
- " Setup mechanism to restore orignial completion type upon leaving insert
+ " Setup mechanism to restore original completion type upon leaving insert
" mode if configured to do so
if g:SuperTabRetainCompletionDuration == 'insert'
augroup supertab_retain
@@ -219,13 +228,24 @@ endfunction " }}}
" s:InitBuffer {{{
" Per buffer initilization.
function! s:InitBuffer()
- if exists("b:complType")
+ if exists('b:SuperTabNoCompleteBefore')
return
endif
+ let b:complReset = 0
+ let b:complTypeManual = !exists('b:complTypeManual') ? '' : b:complTypeManual
+ let b:complTypeContext = ''
+
" init hack for <c-x><c-v> workaround.
let b:complCommandLine = 0
+ if !exists('b:SuperTabNoCompleteBefore')
+ let b:SuperTabNoCompleteBefore = g:SuperTabNoCompleteBefore
+ endif
+ if !exists('b:SuperTabNoCompleteAfter')
+ let b:SuperTabNoCompleteAfter = g:SuperTabNoCompleteAfter
+ endif
+
let b:SuperTabDefaultCompletionType = g:SuperTabDefaultCompletionType
" set the current completion type to the default
@@ -248,6 +268,8 @@ function! s:ManualCompletionEnter()
let complType = "\<c-x>" . complType
endif
+ let b:complTypeManual = complType
+
if index(['insert', 'session'], g:SuperTabRetainCompletionDuration) != -1
let b:complType = complType
endif
@@ -257,6 +279,11 @@ function! s:ManualCompletionEnter()
return s:CommandLineCompletion()
endif
+ " optionally enable enhanced longest completion
+ if g:SuperTabLongestEnhanced && &completeopt =~ 'longest'
+ call s:EnableLongestEnhancement()
+ endif
+
return complType
endif
@@ -290,29 +317,57 @@ endfunction " }}}
" previous entry in a completion list, and determines whether or not to simply
" retain the normal usage of <tab> based on the cursor position.
function! s:SuperTab(command)
+ call s:InitBuffer()
+
if s:WillComplete()
- " rare case where no autocmds have fired for this buffer to initialize the
- " supertab vars.
- call s:InitBuffer()
+ " optionally enable enhanced longest completion
+ if g:SuperTabLongestEnhanced && &completeopt =~ 'longest'
+ call s:EnableLongestEnhancement()
+ endif
- let key = ''
" highlight first result if longest enabled
if g:SuperTabLongestHighlight && !pumvisible() && &completeopt =~ 'longest'
- let key = (b:complType == "\<c-p>") ? "\<c-p>" : "\<c-n>"
+ let key = (b:complType == "\<c-p>") ? b:complType : "\<c-n>"
+ call feedkeys(key)
+ endif
+
+ if !pumvisible()
+ let b:complTypeManual = ''
endif
" exception: if in <c-p> mode, then <c-n> should move up the list, and
" <c-p> down the list.
- if a:command == 'p' &&
+ if a:command == 'p' && !b:complReset &&
\ (b:complType == "\<c-p>" ||
\ (b:complType == 'context' &&
- \ tolower(g:SuperTabContextDefaultCompletionType) == '<c-p>'))
+ \ b:complTypeManual == '' &&
+ \ b:complTypeContext == "\<c-p>"))
return "\<c-n>"
- elseif a:command == 'p' &&
+
+ elseif a:command == 'p' && !b:complReset &&
\ (b:complType == "\<c-n>" ||
\ (b:complType == 'context' &&
- \ tolower(g:SuperTabContextDefaultCompletionType) == '<c-n>'))
+ \ b:complTypeManual == '' &&
+ \ b:complTypeContext == "\<c-n>"))
return "\<c-p>"
+
+ " this used to handle call from captured keys with the longest enhancement
+ " enabled, but also must work when the enhancement is disabled.
+ elseif pumvisible() && !b:complReset
+ if b:complType == 'context'
+ exec "let contextDefault = \"" .
+ \ escape(g:SuperTabContextDefaultCompletionType, '<') . "\""
+ " if we are in another completion mode, just scroll to the next
+ " completion
+ if b:complTypeContext != contextDefault
+ return a:command == 'n' ? "\<c-n>" : "\<c-p>"
+ endif
+ return contextDefault
+ endif
+ if a:command == 'n'
+ return b:complType == "\<c-p>" ? "\<c-p>" : "\<c-n>"
+ endif
+ return b:complType == "\<c-p>" ? "\<c-n>" : "\<c-p>"
endif
" handle 'context' completion.
@@ -322,14 +377,25 @@ function! s:SuperTab(command)
exec "let complType = \"" .
\ escape(g:SuperTabContextDefaultCompletionType, '<') . "\""
endif
- return complType . key
- endif
+ let b:complTypeContext = complType
" Hack to workaround bug when invoking command line completion via <c-r>=
- if b:complType == "\<c-x>\<c-v>"
- return s:CommandLineCompletion()
+ elseif b:complType == "\<c-x>\<c-v>"
+ let complType = s:CommandLineCompletion()
+ else
+ let complType = b:complType
endif
- return b:complType . key
+
+ if b:complReset
+ let b:complReset = 0
+ " not an accurate condition for everyone, but better than sending <c-e>
+ " at the wrong time.
+ if pumvisible()
+ return "\<c-e>" . complType
+ endif
+ endif
+
+ return complType
endif
return "\<tab>"
@@ -371,27 +437,106 @@ endfunction " }}}
" s:WillComplete() {{{
" Determines if completion should be kicked off at the current location.
function! s:WillComplete()
+ if pumvisible()
+ return 1
+ endif
+
let line = getline('.')
let cnum = col('.')
" Start of line.
- let prev_char = strpart(line, cnum - 2, 1)
- if prev_char =~ '^\s*$'
+ if line =~ '^\s*\%' . cnum . 'c'
return 0
endif
+ " honor SuperTabNoCompleteAfter
+ let pre = line[:cnum - 2]
+ for pattern in b:SuperTabNoCompleteAfter
+ if pre =~ pattern . '$'
+ return 0
+ endif
+ endfor
+
+ " honor SuperTabNoCompleteBefore
" Within a word, but user does not have mid word completion enabled.
- let next_char = strpart(line, cnum - 1, 1)
- if !g:SuperTabMidWordCompletion && next_char =~ '\k'
- return 0
+ let post = line[cnum - 1:]
+ for pattern in b:SuperTabNoCompleteBefore
+ if post =~ '^' . pattern
+ return 0
+ endif
+ endfor
+
+ return 1
+endfunction " }}}
+
+" s:EnableLongestEnhancement() {{{
+function! s:EnableLongestEnhancement()
+ augroup supertab_reset
+ autocmd!
+ autocmd InsertLeave,CursorMovedI <buffer>
+ \ call s:ReleaseKeyPresses() | autocmd! supertab_reset
+ call s:CaptureKeyPresses()
+ augroup END
+endfunction " }}}
+
+" s:CompletionReset(char) {{{
+function! s:CompletionReset(char)
+ let b:complReset = 1
+ return a:char
+endfunction " }}}
+
+" s:CaptureKeyPresses() {{{
+function! s:CaptureKeyPresses()
+ if !exists('b:capturing') || !b:capturing
+ let b:capturing = 1
+ " save any previous mappings
+ " TODO: capture additional info provided by vim 7.3.032 and up.
+ let b:captured = {
+ \ '<bs>': maparg('<bs>', 'i'),
+ \ '<c-h>': maparg('<c-h>', 'i'),
+ \ }
+ " TODO: use &keyword to get an accurate list of chars to map
+ for c in split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_', '.\zs')
+ exec 'imap <buffer> ' . c . ' <c-r>=<SID>CompletionReset("' . c . '")<cr>'
+ endfor
+ imap <buffer> <bs> <c-r>=<SID>CompletionReset("\<lt>bs>")<cr>
+ imap <buffer> <c-h> <c-r>=<SID>CompletionReset("\<lt>c-h>")<cr>
+ exec 'imap <buffer> ' . g:SuperTabMappingForward . ' <c-r>=<SID>SuperTab("n")<cr>'
endif
+endfunction " }}}
- " In keyword completion mode and no preceding word characters.
- "if (b:complType == "\<c-n>" || b:complType == "\<c-p>") && prev_char !~ '\k'
- " return 0
- "endif
+" s:ReleaseKeyPresses() {{{
+function! s:ReleaseKeyPresses()
+ if exists('b:capturing') && b:capturing
+ let b:capturing = 0
+ for c in split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_', '.\zs')
+ exec 'iunmap <buffer> ' . c
+ endfor
- return 1
+ iunmap <buffer> <bs>
+ iunmap <buffer> <c-h>
+ exec 'iunmap <buffer> ' . g:SuperTabMappingForward
+
+ " restore any previous mappings
+ for [key, rhs] in items(b:captured)
+ if rhs != ''
+ let args = substitute(rhs, '.*\(".\{-}"\).*', '\1', '')
+ if args != rhs
+ let args = substitute(args, '<', '<lt>', 'g')
+ let expr = substitute(rhs, '\(.*\)".\{-}"\(.*\)', '\1%s\2', '')
+ let rhs = printf(expr, args)
+ endif
+ exec printf("imap <silent> %s %s", key, rhs)
+ endif
+ endfor
+ unlet b:captured
+
+ if mode() == 'i'
+ " force full exit from completion mode (don't exit insert mode since
+ " that will break repeating with '.')
+ call feedkeys("\<space>\<bs>", 'n')
+ endif
+ endif
endfunction " }}}
" s:CommandLineCompletion() {{{
@@ -478,23 +623,89 @@ function! s:ContextText()
endif
endfunction " }}}
+" s:ExpandMap(map) {{{
+function! s:ExpandMap(map)
+ let map = a:map
+ if map =~ '<Plug>'
+ let plug = substitute(map, '.\{-}\(<Plug>\w\+\).*', '\1', '')
+ let plug_map = maparg(plug, 'i')
+ let map = substitute(map, '.\{-}\(<Plug>\w\+\).*', plug_map, '')
+ endif
+ return map
+endfunction " }}}
+
" Key Mappings {{{
" map a regular tab to ctrl-tab (note: doesn't work in console vim)
exec 'inoremap ' . g:SuperTabMappingTabLiteral . ' <tab>'
imap <c-x> <c-r>=<SID>ManualCompletionEnter()<cr>
- " From the doc |insert.txt| improved
- exec 'imap ' . g:SuperTabMappingForward . ' <c-n>'
- exec 'imap ' . g:SuperTabMappingBackward . ' <c-p>'
+ imap <script> <Plug>SuperTabForward <c-r>=<SID>SuperTab('n')<cr>
+ imap <script> <Plug>SuperTabBackward <c-r>=<SID>SuperTab('p')<cr>
+
+ exec 'imap ' . g:SuperTabMappingForward . ' <Plug>SuperTabForward'
+ exec 'imap ' . g:SuperTabMappingBackward . ' <Plug>SuperTabBackward'
" After hitting <Tab>, hitting it once more will go to next match
" (because in XIM mode <c-n> and <c-p> mappings are ignored)
" and wont start a brand new completion
" The side effect, that in the beginning of line <c-n> and <c-p> inserts a
" <Tab>, but I hope it may not be a problem...
- inoremap <c-n> <c-r>=<SID>SuperTab('n')<cr>
- inoremap <c-p> <c-r>=<SID>SuperTab('p')<cr>
+ let ctrl_n = maparg('<c-n>', 'i')
+ if ctrl_n != ''
+ let ctrl_n = substitute(ctrl_n, '<', '<lt>', 'g')
+ exec 'imap <c-n> <c-r>=<SID>ForwardBack("n", "' . ctrl_n . '")<cr>'
+ else
+ imap <c-n> <Plug>SuperTabForward
+ endif
+ let ctrl_p = maparg('<c-p>', 'i')
+ if ctrl_p != ''
+ let ctrl_p = substitute(ctrl_p, '<', '<lt>', 'g')
+ exec 'imap <c-p> <c-r>=<SID>ForwardBack("p", "' . ctrl_p . '")<cr>'
+ else
+ imap <c-p> <Plug>SuperTabBackward
+ endif
+ function! s:ForwardBack(command, map)
+ exec "let map = \"" . escape(a:map, '<') . "\""
+ return pumvisible() ? s:SuperTab(a:command) : map
+ endfunction
+
+ if g:SuperTabCrMapping
+ if maparg('<CR>','i') =~ '<CR>'
+ let map = maparg('<cr>', 'i')
+ let cr = (map =~? '\(^\|[^)]\)<cr>')
+ let map = s:ExpandMap(map)
+ exec "inoremap <script> <cr> <c-r>=<SID>SelectCompletion(" . cr . ")<cr>" . map
+ else
+ inoremap <cr> <c-r>=<SID>SelectCompletion(1)<cr>
+ endif
+ function! s:SelectCompletion(cr)
+ " selecting a completion
+ if pumvisible()
+ " ugly hack to let other <cr> mappings for other plugins cooperate
+ " with supertab
+ let b:supertab_pumwasvisible = 1
+ return "\<c-y>"
+ endif
+
+ if exists('b:supertab_pumwasvisible')
+ unlet b:supertab_pumwasvisible
+ return ''
+ endif
+
+ " not so pleasant hack to keep <cr> working for abbreviations
+ let word = substitute(getline('.'), '^.*\s\+\(.*\%' . col('.') . 'c\).*', '\1', '')
+ if maparg(word, 'i', 1) != ''
+ call feedkeys("\<c-]>", 't')
+ call feedkeys("\<cr>", 'n')
+ return ''
+ endif
+
+ " only return a cr if nothing else is mapped to it since we don't want
+ " to duplicate a cr returned by another mapping.
+ return a:cr ? "\<cr>" : ""
+ endfunction
+ endif
" }}}
" Command Mappings {{{
--
vim-scripts packaging
More information about the pkg-vim-maintainers
mailing list