tomkersten-vixploder 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/Manifest.txt +105 -0
- data/PostInstall.txt +21 -0
- data/README.rdoc +131 -0
- data/Rakefile +21 -0
- data/bin/256colors2.pl +63 -0
- data/bin/colortest +365 -0
- data/bin/vixplode +10 -0
- data/lib/dotfiles/aliases +30 -0
- data/lib/dotfiles/gvimrc +20 -0
- data/lib/dotfiles/vim/.VimballRecord +2 -0
- data/lib/dotfiles/vim/after/ftplugin/actionscript_snippets.vim +9 -0
- data/lib/dotfiles/vim/after/ftplugin/aspvbs_snippets.vim +17 -0
- data/lib/dotfiles/vim/after/ftplugin/c_snippets.vim +58 -0
- data/lib/dotfiles/vim/after/ftplugin/css_snippets.vim +30 -0
- data/lib/dotfiles/vim/after/ftplugin/django_model_snippets.vim +61 -0
- data/lib/dotfiles/vim/after/ftplugin/django_template_snippets.vim +32 -0
- data/lib/dotfiles/vim/after/ftplugin/f-script_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/haskell_snippets.vim +9 -0
- data/lib/dotfiles/vim/after/ftplugin/html_snippets.vim +57 -0
- data/lib/dotfiles/vim/after/ftplugin/java_snippets.vim +52 -0
- data/lib/dotfiles/vim/after/ftplugin/javascript_snippets.vim +10 -0
- data/lib/dotfiles/vim/after/ftplugin/latex_snippets.vim +13 -0
- data/lib/dotfiles/vim/after/ftplugin/logo_snippets.vim +9 -0
- data/lib/dotfiles/vim/after/ftplugin/markdown_snippets.vim +10 -0
- data/lib/dotfiles/vim/after/ftplugin/movable_type_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/objc_snippets.vim +53 -0
- data/lib/dotfiles/vim/after/ftplugin/ocaml_snippets.vim +26 -0
- data/lib/dotfiles/vim/after/ftplugin/perl_snippets.vim +23 -0
- data/lib/dotfiles/vim/after/ftplugin/php_snippets.vim +30 -0
- data/lib/dotfiles/vim/after/ftplugin/phpdoc_snippets.vim +19 -0
- data/lib/dotfiles/vim/after/ftplugin/propel_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/python_snippets.vim +202 -0
- data/lib/dotfiles/vim/after/ftplugin/rails_snippets.vim +54 -0
- data/lib/dotfiles/vim/after/ftplugin/ruby_snippets.vim +32 -0
- data/lib/dotfiles/vim/after/ftplugin/sh_snippets.vim +12 -0
- data/lib/dotfiles/vim/after/ftplugin/slate_snippets.vim +19 -0
- data/lib/dotfiles/vim/after/ftplugin/smarty_snippets.vim +35 -0
- data/lib/dotfiles/vim/after/ftplugin/symfony_snippets.vim +21 -0
- data/lib/dotfiles/vim/after/ftplugin/tcl_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/template_toolkit_snippets.vim +13 -0
- data/lib/dotfiles/vim/after/ftplugin/tex_snippets.vim +13 -0
- data/lib/dotfiles/vim/after/ftplugin/xhtml_snippets.vim +48 -0
- data/lib/dotfiles/vim/autoload/fakeclip.vim +253 -0
- data/lib/dotfiles/vim/autoload/rails.vim +4377 -0
- data/lib/dotfiles/vim/autoload/rubycomplete.vim +802 -0
- data/lib/dotfiles/vim/colors/inkpot.vim +212 -0
- data/lib/dotfiles/vim/colors/ir_black.vim +212 -0
- data/lib/dotfiles/vim/colors/ir_black_mod.vim +213 -0
- data/lib/dotfiles/vim/colors/railscasts.vim +100 -0
- data/lib/dotfiles/vim/colors/rubyblue.vim +74 -0
- data/lib/dotfiles/vim/colors/twilight.vim +75 -0
- data/lib/dotfiles/vim/colors/twilight2.vim +74 -0
- data/lib/dotfiles/vim/colors/wombat256.vim +302 -0
- data/lib/dotfiles/vim/compiler/eruby.vim +41 -0
- data/lib/dotfiles/vim/compiler/ruby.vim +68 -0
- data/lib/dotfiles/vim/compiler/rubyunit.vim +35 -0
- data/lib/dotfiles/vim/doc/NERD_tree.txt +1235 -0
- data/lib/dotfiles/vim/doc/fakeclip.txt +190 -0
- data/lib/dotfiles/vim/doc/matchit.txt +406 -0
- data/lib/dotfiles/vim/doc/project.txt +710 -0
- data/lib/dotfiles/vim/doc/rails.txt +1123 -0
- data/lib/dotfiles/vim/doc/snippets_emu.txt +354 -0
- data/lib/dotfiles/vim/doc/surround.txt +218 -0
- data/lib/dotfiles/vim/doc/tags +433 -0
- data/lib/dotfiles/vim/filetype.vim +13 -0
- data/lib/dotfiles/vim/ftdetect/gist.vim +3 -0
- data/lib/dotfiles/vim/ftdetect/ruby.vim +14 -0
- data/lib/dotfiles/vim/ftplugin/eruby.vim +101 -0
- data/lib/dotfiles/vim/ftplugin/ruby.vim +230 -0
- data/lib/dotfiles/vim/indent/eruby.vim +73 -0
- data/lib/dotfiles/vim/indent/ruby.vim +373 -0
- data/lib/dotfiles/vim/plugin/NERD_tree.vim +3536 -0
- data/lib/dotfiles/vim/plugin/comments.vim +321 -0
- data/lib/dotfiles/vim/plugin/fakeclip.vim +174 -0
- data/lib/dotfiles/vim/plugin/fuzzyfinder.vim +1676 -0
- data/lib/dotfiles/vim/plugin/fuzzyfinder_textmate.vim +150 -0
- data/lib/dotfiles/vim/plugin/gist.vim +241 -0
- data/lib/dotfiles/vim/plugin/gitdiff.vim +141 -0
- data/lib/dotfiles/vim/plugin/matchit.vim +812 -0
- data/lib/dotfiles/vim/plugin/mru.vim +787 -0
- data/lib/dotfiles/vim/plugin/rails.vim +310 -0
- data/lib/dotfiles/vim/plugin/rspec.vim +12 -0
- data/lib/dotfiles/vim/plugin/snippets.vim +17 -0
- data/lib/dotfiles/vim/plugin/snippetsEmu.vim +973 -0
- data/lib/dotfiles/vim/plugin/supertab.vim +531 -0
- data/lib/dotfiles/vim/plugin/surround.vim +632 -0
- data/lib/dotfiles/vim/ref_vimrc +80 -0
- data/lib/dotfiles/vim/ruby/fuzzy_file_finder.rb +353 -0
- data/lib/dotfiles/vim/syntax/eruby.vim +85 -0
- data/lib/dotfiles/vim/syntax/haml.vim +113 -0
- data/lib/dotfiles/vim/syntax/mkd.vim +86 -0
- data/lib/dotfiles/vim/syntax/ruby.vim +324 -0
- data/lib/dotfiles/vim/syntax/sass.vim +93 -0
- data/lib/dotfiles/vimrc +269 -0
- data/lib/vixplode/cli.rb +73 -0
- data/lib/vixploder.rb +6 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/vixplode_cli_spec.rb +15 -0
- data/spec/vixploder_spec.rb +7 -0
- data/tasks/rspec.rake +21 -0
- metadata +202 -8
@@ -0,0 +1,531 @@
|
|
1
|
+
" Author:
|
2
|
+
" Original: Gergely Kontra <kgergely@mcl.hu>
|
3
|
+
" Current: Eric Van Dewoestine <ervandew@gmail.com> (as of version 0.4)
|
4
|
+
" Please direct all correspondence to Eric.
|
5
|
+
" Version: 0.46
|
6
|
+
"
|
7
|
+
" Description: {{{
|
8
|
+
" Use your tab key to do all your completion in insert mode!
|
9
|
+
" You can cycle forward and backward with the <Tab> and <S-Tab> keys
|
10
|
+
" Note: you must press <Tab> once to be able to cycle back
|
11
|
+
"
|
12
|
+
" http://www.vim.org/scripts/script.php?script_id=1643
|
13
|
+
" }}}
|
14
|
+
"
|
15
|
+
" License: {{{
|
16
|
+
" Software License Agreement (BSD License)
|
17
|
+
"
|
18
|
+
" Copyright (c) 2002 - 2007
|
19
|
+
" All rights reserved.
|
20
|
+
"
|
21
|
+
" Redistribution and use of this software in source and binary forms, with
|
22
|
+
" or without modification, are permitted provided that the following
|
23
|
+
" conditions are met:
|
24
|
+
"
|
25
|
+
" * Redistributions of source code must retain the above
|
26
|
+
" copyright notice, this list of conditions and the
|
27
|
+
" following disclaimer.
|
28
|
+
"
|
29
|
+
" * Redistributions in binary form must reproduce the above
|
30
|
+
" copyright notice, this list of conditions and the
|
31
|
+
" following disclaimer in the documentation and/or other
|
32
|
+
" materials provided with the distribution.
|
33
|
+
"
|
34
|
+
" * Neither the name of Gergely Kontra or Eric Van Dewoestine nor the names
|
35
|
+
" of its contributors may be used to endorse or promote products derived
|
36
|
+
" from this software without specific prior written permission of Gergely
|
37
|
+
" Kontra or Eric Van Dewoestine.
|
38
|
+
"
|
39
|
+
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
40
|
+
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
41
|
+
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
42
|
+
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
43
|
+
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
44
|
+
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
45
|
+
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
46
|
+
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
47
|
+
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
48
|
+
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
49
|
+
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
50
|
+
" }}}
|
51
|
+
|
52
|
+
if exists('complType') " Integration with other completion functions.
|
53
|
+
finish
|
54
|
+
endif
|
55
|
+
|
56
|
+
" Global Variables {{{
|
57
|
+
|
58
|
+
" Used to set the default completion type.
|
59
|
+
" There is no need to escape this value as that will be done for you when
|
60
|
+
" the type is set.
|
61
|
+
" Ex. let g:SuperTabDefaultCompletionType = "<c-x><c-u>"
|
62
|
+
"
|
63
|
+
" Note that a special value of 'context' is supported which will result in
|
64
|
+
" super tab attempting to use the text preceding the cursor to decide which
|
65
|
+
" type of completion to attempt. Currently super tab can recognize method
|
66
|
+
" calls or attribute references via '.', '::' or '->', and file path
|
67
|
+
" references containing '/'.
|
68
|
+
" Ex. let g:SuperTabDefaultCompletionType = 'context'
|
69
|
+
" /usr/l<tab> # will use filename completion
|
70
|
+
" myvar.t # will use user completion if completefunc set, or omni
|
71
|
+
" # completion if omnifunc set.
|
72
|
+
" myvar-> # same as above
|
73
|
+
"
|
74
|
+
" When using context completion, super tab will fall back to a secondary
|
75
|
+
" default completion type set by g:SuperTabContextDefaultCompletionType.
|
76
|
+
if !exists("g:SuperTabDefaultCompletionType")
|
77
|
+
let g:SuperTabDefaultCompletionType = "<c-p>"
|
78
|
+
endif
|
79
|
+
|
80
|
+
" Sets the default completion type used when g:SuperTabDefaultCompletionType
|
81
|
+
" is set to 'context' and the text preceding the cursor does not match any
|
82
|
+
" patterns mapped to other specific completion types.
|
83
|
+
if !exists("g:SuperTabContextDefaultCompletionType")
|
84
|
+
let g:SuperTabContextDefaultCompletionType = "<c-p>"
|
85
|
+
endif
|
86
|
+
|
87
|
+
" When 'context' completion is enabled, this setting can be used to fallback
|
88
|
+
" to g:SuperTabContextDefaultCompletionType as the default for files whose
|
89
|
+
" file type occurs in this configured list. This allows you to provide an
|
90
|
+
" exclusion for which 'context' completion is not activated.
|
91
|
+
if !exists("g:SuperTabContextFileTypeExclusions")
|
92
|
+
let g:SuperTabContextFileTypeExclusions = []
|
93
|
+
endif
|
94
|
+
|
95
|
+
" Used to set a list of variable, completion type pairs used to determine
|
96
|
+
" the default completion type to use for the current buffer. If the
|
97
|
+
" variable is non-zero and non-empty then the associated completion type
|
98
|
+
" will be used.
|
99
|
+
" Ex. To use omni or user completion when available, but fall back to the
|
100
|
+
" global default otherwise:
|
101
|
+
" let g:SuperTabDefaultCompletionTypeDiscovery = [
|
102
|
+
" \ "&completefunc:<c-x><c-u>",
|
103
|
+
" \ "&omnifunc:<c-x><c-o>",
|
104
|
+
" \ ]
|
105
|
+
if !exists("g:SuperTabDefaultCompletionTypeDiscovery")
|
106
|
+
let g:SuperTabDefaultCompletionTypeDiscovery = []
|
107
|
+
endif
|
108
|
+
|
109
|
+
" Determines if, and for how long, the current completion type is retained.
|
110
|
+
" The possible values include:
|
111
|
+
" 0 - The current completion type is only retained for the current completion.
|
112
|
+
" Once you have chosen a completion result or exited the completion
|
113
|
+
" mode, the default completion type is restored.
|
114
|
+
" 1 - The current completion type is saved for the duration of your vim
|
115
|
+
" session or until you enter a different completion mode.
|
116
|
+
" (SuperTab default).
|
117
|
+
" 2 - The current completion type is saved until you exit insert mode (via
|
118
|
+
" ESC). Once you exit insert mode the default completion type is
|
119
|
+
" restored.
|
120
|
+
if !exists("g:SuperTabRetainCompletionType")
|
121
|
+
let g:SuperTabRetainCompletionType = 1
|
122
|
+
endif
|
123
|
+
|
124
|
+
" Sets whether or not mid word completion is enabled.
|
125
|
+
" When enabled, <tab> will kick off completion when ever a word character is
|
126
|
+
" to the left of the cursor. When disabled, completion will only occur if
|
127
|
+
" the char to the left is a word char and the char to the right is not (you
|
128
|
+
" are at the end of the word).
|
129
|
+
if !exists("g:SuperTabMidWordCompletion")
|
130
|
+
let g:SuperTabMidWordCompletion = 1
|
131
|
+
endif
|
132
|
+
|
133
|
+
" The following two variables allow you to set the key mapping used to kick
|
134
|
+
" off the current completion. By default this is <tab> and <s-tab>. To
|
135
|
+
" change to something like <c-space> and <s-c-space>, you can add the
|
136
|
+
" following to your vimrc.
|
137
|
+
"
|
138
|
+
" let g:SuperTabMappingForward = '<c-space>'
|
139
|
+
" let g:SuperTabMappingBackward = '<s-c-space>'
|
140
|
+
"
|
141
|
+
" Note: if the above does not have the desired effect (which may happen in
|
142
|
+
" console version of vim), you can try the following mappings. Although the
|
143
|
+
" backwards mapping still doesn't seem to work in the console for me, your
|
144
|
+
" milage may vary.
|
145
|
+
"
|
146
|
+
" let g:SuperTabMappingForward = '<nul>'
|
147
|
+
" let g:SuperTabMappingBackward = '<s-nul>'
|
148
|
+
"
|
149
|
+
if !exists("g:SuperTabMappingForward")
|
150
|
+
let g:SuperTabMappingForward = '<tab>'
|
151
|
+
endif
|
152
|
+
if !exists("g:SuperTabMappingBackward")
|
153
|
+
let g:SuperTabMappingBackward = '<s-tab>'
|
154
|
+
endif
|
155
|
+
|
156
|
+
" Sets the key mapping used to insert a literal tab where supertab would
|
157
|
+
" otherwise attempt to kick off insert completion.
|
158
|
+
" The default is '<c-tab>' (ctrl-tab) which unfortunately might not work at
|
159
|
+
" the console. So if you are using a console vim and want this
|
160
|
+
" functionality, you'll have to change it to something that is supported.
|
161
|
+
if !exists("g:SuperTabMappingTabLiteral")
|
162
|
+
let g:SuperTabMappingTabLiteral = '<c-tab>'
|
163
|
+
endif
|
164
|
+
|
165
|
+
" Sets whether or not to pre-highlight first match when completeopt has
|
166
|
+
" the popup menu enabled and the 'longest' option as well.
|
167
|
+
" When enabled, <tab> will kick off completion and pre-select the first
|
168
|
+
" entry in the popup menu, allowing you to simply hit <enter> to use it.
|
169
|
+
if !exists("g:SuperTabLongestHighlight")
|
170
|
+
let g:SuperTabLongestHighlight = 0
|
171
|
+
endif
|
172
|
+
|
173
|
+
" }}}
|
174
|
+
|
175
|
+
" Script Variables {{{
|
176
|
+
|
177
|
+
" construct the help text.
|
178
|
+
let s:tabHelp =
|
179
|
+
\ "Hit <CR> or CTRL-] on the completion type you wish to switch to.\n" .
|
180
|
+
\ "Use :help ins-completion for more information.\n" .
|
181
|
+
\ "\n" .
|
182
|
+
\ "|<c-n>| - Keywords in 'complete' searching down.\n" .
|
183
|
+
\ "|<c-p>| - Keywords in 'complete' searching up (SuperTab default).\n" .
|
184
|
+
\ "|<c-x><c-l>| - Whole lines.\n" .
|
185
|
+
\ "|<c-x><c-n>| - Keywords in current file.\n" .
|
186
|
+
\ "|<c-x><c-k>| - Keywords in 'dictionary'.\n" .
|
187
|
+
\ "|<c-x><c-t>| - Keywords in 'thesaurus', thesaurus-style.\n" .
|
188
|
+
\ "|<c-x><c-i>| - Keywords in the current and included files.\n" .
|
189
|
+
\ "|<c-x><c-]>| - Tags.\n" .
|
190
|
+
\ "|<c-x><c-f>| - File names.\n" .
|
191
|
+
\ "|<c-x><c-d>| - Definitions or macros.\n" .
|
192
|
+
\ "|<c-x><c-v>| - Vim command-line."
|
193
|
+
if v:version >= 700
|
194
|
+
let s:tabHelp = s:tabHelp . "\n" .
|
195
|
+
\ "|<c-x><c-u>| - User defined completion.\n" .
|
196
|
+
\ "|<c-x><c-o>| - Omni completion.\n" .
|
197
|
+
\ "|<c-x>s| - Spelling suggestions."
|
198
|
+
endif
|
199
|
+
|
200
|
+
" set the available completion types and modes.
|
201
|
+
let s:types =
|
202
|
+
\ "\<C-E>\<C-Y>\<C-L>\<C-N>\<C-K>\<C-T>\<C-I>\<C-]>\<C-F>\<C-D>\<C-V>\<C-N>\<C-P>"
|
203
|
+
let s:modes = '/^E/^Y/^L/^N/^K/^T/^I/^]/^F/^D/^V/^P'
|
204
|
+
if v:version >= 700
|
205
|
+
let s:types = s:types . "\<C-U>\<C-O>\<C-N>\<C-P>s"
|
206
|
+
let s:modes = s:modes . '/^U/^O/s'
|
207
|
+
endif
|
208
|
+
let s:types = s:types . "np"
|
209
|
+
let s:modes = s:modes . '/n/p'
|
210
|
+
|
211
|
+
" }}}
|
212
|
+
|
213
|
+
" CtrlXPP() {{{
|
214
|
+
" Handles entrance into completion mode.
|
215
|
+
function! CtrlXPP ()
|
216
|
+
if &smd
|
217
|
+
echo '' | echo '-- ^X++ mode (' . s:modes . ')'
|
218
|
+
endif
|
219
|
+
let complType = nr2char(getchar())
|
220
|
+
if stridx(s:types, complType) != -1
|
221
|
+
if stridx("\<C-E>\<C-Y>", complType) != -1 " no memory, just scroll...
|
222
|
+
return "\<C-x>" . complType
|
223
|
+
elseif stridx('np', complType) != -1
|
224
|
+
let complType = nr2char(char2nr(complType) - 96) " char2nr('n')-char2nr("\<C-n")
|
225
|
+
else
|
226
|
+
let complType="\<C-x>" . complType
|
227
|
+
endif
|
228
|
+
|
229
|
+
if g:SuperTabRetainCompletionType
|
230
|
+
let b:complType = complType
|
231
|
+
endif
|
232
|
+
|
233
|
+
return complType
|
234
|
+
else
|
235
|
+
echohl "Unknown mode"
|
236
|
+
return complType
|
237
|
+
endif
|
238
|
+
endfunction " }}}
|
239
|
+
|
240
|
+
" SuperTabSetCompletionType(type) {{{
|
241
|
+
" Globally available function that user's can use to create mappings to
|
242
|
+
" quickly switch completion modes. Useful when a user wants to restore the
|
243
|
+
" default or switch to another mode without having to kick off a completion
|
244
|
+
" of that type or use SuperTabHelp.
|
245
|
+
" Example mapping to restore SuperTab default:
|
246
|
+
" nmap <F6> :call SetSuperTabCompletionType("<C-P>")<cr>
|
247
|
+
function! SuperTabSetCompletionType (type)
|
248
|
+
exec "let b:complType = \"" . escape(a:type, '<') . "\""
|
249
|
+
endfunction " }}}
|
250
|
+
|
251
|
+
" s:Init {{{
|
252
|
+
" Global initilization when supertab is loaded.
|
253
|
+
function! s:Init ()
|
254
|
+
augroup supertab_init
|
255
|
+
autocmd!
|
256
|
+
autocmd BufEnter * call <SID>InitBuffer()
|
257
|
+
augroup END
|
258
|
+
" ensure InitBuffer gets called for the first buffer.
|
259
|
+
call s:InitBuffer()
|
260
|
+
|
261
|
+
" Setup mechanism to restore orignial completion type upon leaving insert
|
262
|
+
" mode if g:SuperTabRetainCompletionType == 2
|
263
|
+
if g:SuperTabRetainCompletionType == 2
|
264
|
+
" pre vim 7, must map <esc>
|
265
|
+
if v:version < 700
|
266
|
+
im <silent> <ESC> <ESC>:call s:SetDefaultCompletionType()<cr>
|
267
|
+
|
268
|
+
" since vim 7, we can use InsertLeave autocmd.
|
269
|
+
else
|
270
|
+
augroup supertab_retain
|
271
|
+
autocmd!
|
272
|
+
autocmd InsertLeave * call s:SetDefaultCompletionType()
|
273
|
+
augroup END
|
274
|
+
endif
|
275
|
+
endif
|
276
|
+
endfunction " }}}
|
277
|
+
|
278
|
+
" s:InitBuffer {{{
|
279
|
+
" Per buffer initilization.
|
280
|
+
function! s:InitBuffer ()
|
281
|
+
if exists("b:complType")
|
282
|
+
return
|
283
|
+
endif
|
284
|
+
|
285
|
+
if !exists("b:SuperTabDefaultCompletionType")
|
286
|
+
" loop through discovery list to find the default
|
287
|
+
if !empty(g:SuperTabDefaultCompletionTypeDiscovery)
|
288
|
+
" backward compatiability with old string value.
|
289
|
+
if type(g:SuperTabDefaultCompletionTypeDiscovery) == 1
|
290
|
+
let dlist = split(g:SuperTabDefaultCompletionTypeDiscovery, ',')
|
291
|
+
else
|
292
|
+
let dlist = g:SuperTabDefaultCompletionTypeDiscovery
|
293
|
+
endif
|
294
|
+
for pair in dlist
|
295
|
+
let var = substitute(pair, '\(.*\):.*', '\1', '')
|
296
|
+
let type = substitute(pair, '.*:\(.*\)', '\1', '')
|
297
|
+
exec 'let value = ' . var
|
298
|
+
if value !~ '^\s*$' && value != '0'
|
299
|
+
let b:SuperTabDefaultCompletionType = type
|
300
|
+
break
|
301
|
+
endif
|
302
|
+
endfor
|
303
|
+
endif
|
304
|
+
|
305
|
+
" fallback to configured default.
|
306
|
+
if !exists("b:SuperTabDefaultCompletionType")
|
307
|
+
let b:SuperTabDefaultCompletionType = g:SuperTabDefaultCompletionType
|
308
|
+
endif
|
309
|
+
endif
|
310
|
+
|
311
|
+
" set the default completion type.
|
312
|
+
call SuperTabSetCompletionType(b:SuperTabDefaultCompletionType)
|
313
|
+
endfunction " }}}
|
314
|
+
|
315
|
+
" s:IsWordChar(char) {{{
|
316
|
+
" Determines if the supplied character is a word character or matches value
|
317
|
+
" defined by 'iskeyword'.
|
318
|
+
function! s:IsWordChar (char)
|
319
|
+
if a:char =~ '\w'
|
320
|
+
return 1
|
321
|
+
endif
|
322
|
+
|
323
|
+
" check against 'iskeyword'
|
324
|
+
let values = &iskeyword
|
325
|
+
let index = stridx(values, ',')
|
326
|
+
while index > 0 || values != ''
|
327
|
+
if index > 0
|
328
|
+
let value = strpart(values, 0, index)
|
329
|
+
let values = strpart(values, index + 1)
|
330
|
+
else
|
331
|
+
let value = values
|
332
|
+
let values = ''
|
333
|
+
endif
|
334
|
+
|
335
|
+
" exception case for '^,'
|
336
|
+
if value == '^'
|
337
|
+
let value = '^,'
|
338
|
+
|
339
|
+
" execption case for ','
|
340
|
+
elseif value =~ '^,,'
|
341
|
+
let values .= strpart(value, 2)
|
342
|
+
let value = ','
|
343
|
+
|
344
|
+
" execption case after a ^,
|
345
|
+
elseif value =~ '^,'
|
346
|
+
let value = strpart(value, 1)
|
347
|
+
endif
|
348
|
+
|
349
|
+
" keyword values in an ascii number range
|
350
|
+
if value =~ '[0-9]\+-[0-9]\+'
|
351
|
+
let charnum = char2nr(a:char)
|
352
|
+
exec 'let start = ' . substitute(value, '\([0-9]\+\)-.*', '\1', '')
|
353
|
+
exec 'let end = ' . substitute(value, '.*-\([0-9]\+\)', '\1', '')
|
354
|
+
|
355
|
+
if charnum >= start && charnum <= end
|
356
|
+
return 1
|
357
|
+
endif
|
358
|
+
|
359
|
+
" keyword value is a set of include or exclude characters
|
360
|
+
else
|
361
|
+
let include = 1
|
362
|
+
if value =~ '^\^'
|
363
|
+
let value = strpart(value, 1)
|
364
|
+
let include = 0
|
365
|
+
endif
|
366
|
+
|
367
|
+
if a:char =~ '[' . escape(value, '[]') . ']'
|
368
|
+
return include
|
369
|
+
endif
|
370
|
+
endif
|
371
|
+
let index = stridx(values, ',')
|
372
|
+
endwhile
|
373
|
+
|
374
|
+
return 0
|
375
|
+
endfunction " }}}
|
376
|
+
|
377
|
+
" s:SetCompletionType() {{{
|
378
|
+
" Sets the completion type based on what the user has chosen from the help
|
379
|
+
" buffer.
|
380
|
+
function! s:SetCompletionType ()
|
381
|
+
let chosen = substitute(getline('.'), '.*|\(.*\)|.*', '\1', '')
|
382
|
+
if chosen != getline('.')
|
383
|
+
let winnr = b:winnr
|
384
|
+
close
|
385
|
+
exec winnr . 'winc w'
|
386
|
+
call SuperTabSetCompletionType(chosen)
|
387
|
+
endif
|
388
|
+
endfunction " }}}
|
389
|
+
|
390
|
+
" s:SetDefaultCompletionType() {{{
|
391
|
+
function! s:SetDefaultCompletionType ()
|
392
|
+
if exists('b:SuperTabDefaultCompletionType')
|
393
|
+
call SuperTabSetCompletionType(b:SuperTabDefaultCompletionType)
|
394
|
+
endif
|
395
|
+
endfunction " }}}
|
396
|
+
|
397
|
+
" s:SuperTab(command) {{{
|
398
|
+
" Used to perform proper cycle navigation as the user requests the next or
|
399
|
+
" previous entry in a completion list, and determines whether or not to simply
|
400
|
+
" retain the normal usage of <tab> based on the cursor position.
|
401
|
+
function! s:SuperTab (command)
|
402
|
+
if s:WillComplete()
|
403
|
+
let key = ''
|
404
|
+
" highlight first result if longest enabled
|
405
|
+
if g:SuperTabLongestHighlight && !pumvisible() && &completeopt =~ 'longest'
|
406
|
+
let key = (b:complType == "\<c-p>") ? "\<c-p>" : "\<c-n>"
|
407
|
+
endif
|
408
|
+
|
409
|
+
" exception: if in <c-p> mode, then <c-n> should move up the list, and
|
410
|
+
" <c-p> down the list.
|
411
|
+
if a:command == 'p' &&
|
412
|
+
\ (b:complType == "\<c-p>" ||
|
413
|
+
\ (b:complType == 'context' &&
|
414
|
+
\ tolower(g:SuperTabContextDefaultCompletionType) == '<c-p>'))
|
415
|
+
return "\<c-n>"
|
416
|
+
endif
|
417
|
+
|
418
|
+
if b:complType == 'context'
|
419
|
+
if index(g:SuperTabContextFileTypeExclusions, &ft) == -1
|
420
|
+
let curline = getline('.')
|
421
|
+
let cnum = col('.')
|
422
|
+
let synname = synIDattr(synID(line('.'), cnum - 1, 1), 'name')
|
423
|
+
if curline =~ '.*/\w*\%' . cnum . 'c' ||
|
424
|
+
\ ((has('win32') || has('win64')) && curline =~ '.*\\\w*\%' . cnum . 'c')
|
425
|
+
return "\<c-x>\<c-f>" . key
|
426
|
+
elseif curline =~ '.*\(\w\|[\])]\)\(\.\|::\|->\)\w*\%' . cnum . 'c' &&
|
427
|
+
\ synname !~ '\(String\|Comment\)'
|
428
|
+
if &completefunc != ''
|
429
|
+
return "\<c-x>\<c-u>" . key
|
430
|
+
elseif &omnifunc != ''
|
431
|
+
return "\<c-x>\<c-o>" . key
|
432
|
+
endif
|
433
|
+
endif
|
434
|
+
endif
|
435
|
+
exec "let complType = \"" . escape(g:SuperTabContextDefaultCompletionType, '<') . "\""
|
436
|
+
return complType . key
|
437
|
+
endif
|
438
|
+
|
439
|
+
return b:complType . key
|
440
|
+
endif
|
441
|
+
|
442
|
+
return "\<tab>"
|
443
|
+
endfunction " }}}
|
444
|
+
|
445
|
+
" s:SuperTabHelp() {{{
|
446
|
+
" Opens a help window where the user can choose a completion type to enter.
|
447
|
+
function! s:SuperTabHelp ()
|
448
|
+
let winnr = winnr()
|
449
|
+
if bufwinnr("SuperTabHelp") == -1
|
450
|
+
botright split SuperTabHelp
|
451
|
+
|
452
|
+
setlocal noswapfile
|
453
|
+
setlocal buftype=nowrite
|
454
|
+
setlocal bufhidden=delete
|
455
|
+
|
456
|
+
let saved = @"
|
457
|
+
let @" = s:tabHelp
|
458
|
+
silent put
|
459
|
+
call cursor(1, 1)
|
460
|
+
silent 1,delete
|
461
|
+
call cursor(4, 1)
|
462
|
+
let @" = saved
|
463
|
+
exec "resize " . line('$')
|
464
|
+
|
465
|
+
syntax match Special "|.\{-}|"
|
466
|
+
|
467
|
+
setlocal readonly
|
468
|
+
setlocal nomodifiable
|
469
|
+
|
470
|
+
nmap <silent> <buffer> <cr> :call <SID>SetCompletionType()<cr>
|
471
|
+
nmap <silent> <buffer> <c-]> :call <SID>SetCompletionType()<cr>
|
472
|
+
else
|
473
|
+
exec bufwinnr("SuperTabHelp") . "winc w"
|
474
|
+
endif
|
475
|
+
let b:winnr = winnr
|
476
|
+
endfunction " }}}
|
477
|
+
|
478
|
+
" s:WillComplete() {{{
|
479
|
+
" Determines if completion should be kicked off at the current location.
|
480
|
+
function! s:WillComplete ()
|
481
|
+
let line = getline('.')
|
482
|
+
let cnum = col('.')
|
483
|
+
|
484
|
+
" Start of line.
|
485
|
+
let prev_char = strpart(line, cnum - 2, 1)
|
486
|
+
if prev_char =~ '^\s*$'
|
487
|
+
return 0
|
488
|
+
endif
|
489
|
+
|
490
|
+
" Within a word, but user does not have mid word completion enabled.
|
491
|
+
let next_char = strpart(line, cnum - 1, 1)
|
492
|
+
if !g:SuperTabMidWordCompletion && s:IsWordChar(next_char)
|
493
|
+
return 0
|
494
|
+
endif
|
495
|
+
|
496
|
+
" In keyword completion mode and no preceding word characters.
|
497
|
+
"if (b:complType == "\<c-n>" || b:complType == "\<c-p>") && !s:IsWordChar(prev_char)
|
498
|
+
" return 0
|
499
|
+
"endif
|
500
|
+
|
501
|
+
return 1
|
502
|
+
endfunction " }}}
|
503
|
+
|
504
|
+
" Key Mappings {{{
|
505
|
+
" map a regular tab to ctrl-tab (note: doesn't work in console vim)
|
506
|
+
exec 'inoremap ' . g:SuperTabMappingTabLiteral . ' <tab>'
|
507
|
+
|
508
|
+
im <c-x> <c-r>=CtrlXPP()<cr>
|
509
|
+
|
510
|
+
" From the doc |insert.txt| improved
|
511
|
+
exec 'im ' . g:SuperTabMappingForward . ' <c-n>'
|
512
|
+
exec 'im ' . g:SuperTabMappingBackward . ' <c-p>'
|
513
|
+
|
514
|
+
" After hitting <Tab>, hitting it once more will go to next match
|
515
|
+
" (because in XIM mode <c-n> and <c-p> mappings are ignored)
|
516
|
+
" and wont start a brand new completion
|
517
|
+
" The side effect, that in the beginning of line <c-n> and <c-p> inserts a
|
518
|
+
" <Tab>, but I hope it may not be a problem...
|
519
|
+
ino <c-n> <c-r>=<SID>SuperTab('n')<cr>
|
520
|
+
ino <c-p> <c-r>=<SID>SuperTab('p')<cr>
|
521
|
+
" }}}
|
522
|
+
|
523
|
+
" Command Mappings {{{
|
524
|
+
if !exists(":SuperTabHelp")
|
525
|
+
command SuperTabHelp :call <SID>SuperTabHelp()
|
526
|
+
endif
|
527
|
+
" }}}
|
528
|
+
|
529
|
+
call <SID>Init()
|
530
|
+
|
531
|
+
" vim:ft=vim:fdm=marker
|