├── README ├── autoload └── acp.vim ├── doc ├── acp.jax └── acp.txt └── plugin └── acp.vim /README: -------------------------------------------------------------------------------- 1 | This is a mirror of http://www.vim.org/scripts/script.php?script_id=1879 2 | 3 | Repository: 4 | https://bitbucket.org/ns9tks/vim-autocomplpop/ 5 | 6 | Issues: 7 | http://bitbucket.org/ns9tks/vim-autocomplpop/issues/ 8 | 9 | Download latest(development) version 10 | https://bitbucket.org/ns9tks/vim-autocomplpop/get/tip.zip 11 | 12 | ============================================================================== 13 | INTRODUCTION *acp-introduction* 14 | 15 | With this plugin, your vim comes to automatically opens popup menu for 16 | completions when you enter characters or move the cursor in Insert mode. It 17 | won't prevent you continuing entering characters. 18 | 19 | 20 | ============================================================================== 21 | INSTALLATION *acp-installation* 22 | 23 | Put all files into your runtime directory. If you have the zip file, extract 24 | it to your runtime directory. 25 | 26 | You should place the files as follows: 27 | > 28 | /plugin/acp.vim 29 | /doc/acp.txt 30 | ... 31 | < 32 | If you disgust to jumble up this plugin and other plugins in your runtime 33 | directory, put the files into new directory and just add the directory path to 34 | 'runtimepath'. It's easy to uninstall the plugin. 35 | 36 | And then update your help tags files to enable fuzzyfinder help. See 37 | |add-local-help| for details. 38 | 39 | 40 | ============================================================================== 41 | USAGE *acp-usage* 42 | 43 | Once this plugin is installed, auto-popup is enabled at startup by default. 44 | 45 | Which completion method is used depends on the text before the cursor. The 46 | default behavior is as follows: 47 | 48 | kind filetype text before the cursor ~ 49 | Keyword * two keyword characters 50 | Filename * a filename character + a path separator 51 | + 0 or more filename character 52 | Omni ruby ".", "::" or non-word character + ":" 53 | (|+ruby| required.) 54 | Omni python "." (|+python| required.) 55 | Omni xml "<", "" characters + " ") 56 | Omni html/xhtml "<", "" characters + " ") 57 | Omni css (":", ";", "{", "^", "@", or "!") 58 | + 0 or 1 space 59 | 60 | Also, you can make user-defined completion and snipMate's trigger completion 61 | (|acp-snipMate|) auto-popup if the options are set. 62 | 63 | These behavior are customizable. 64 | 65 | *acp-snipMate* 66 | snipMate's Trigger Completion ~ 67 | 68 | snipMate's trigger completion enables you to complete a snippet trigger 69 | provided by snipMate plugin 70 | (http://www.vim.org/scripts/script.php?script_id=2540) and expand it. 71 | 72 | 73 | To enable auto-popup for this completion, add following function to 74 | plugin/snipMate.vim: 75 | > 76 | fun! GetSnipsInCurrentScope() 77 | let snips = {} 78 | for scope in [bufnr('%')] + split(&ft, '\.') + ['_'] 79 | call extend(snips, get(s:snippets, scope, {}), 'keep') 80 | call extend(snips, get(s:multi_snips, scope, {}), 'keep') 81 | endfor 82 | return snips 83 | endf 84 | < 85 | And set |g:acp_behaviorSnipmateLength| option to 1. 86 | 87 | There is the restriction on this auto-popup, that the word before cursor must 88 | consist only of uppercase characters. 89 | 90 | *acp-perl-omni* 91 | Perl Omni-Completion ~ 92 | 93 | AutoComplPop supports perl-completion.vim 94 | (http://www.vim.org/scripts/script.php?script_id=2852). 95 | 96 | To enable auto-popup for this completion, set |g:acp_behaviorPerlOmniLength| 97 | option to 0 or more. 98 | 99 | 100 | ============================================================================== 101 | 102 | -------------------------------------------------------------------------------- /autoload/acp.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " Copyright (c) 2007-2009 Takeshi NISHIDA 3 | " 4 | "============================================================================= 5 | " LOAD GUARD {{{1 6 | 7 | if exists('g:loaded_autoload_acp') || v:version < 702 8 | finish 9 | endif 10 | let g:loaded_autoload_acp = 1 11 | 12 | " }}}1 13 | "============================================================================= 14 | " GLOBAL FUNCTIONS: {{{1 15 | 16 | " 17 | function acp#enable() 18 | call acp#disable() 19 | 20 | augroup AcpGlobalAutoCommand 21 | autocmd! 22 | autocmd InsertEnter * unlet! s:posLast s:lastUncompletable 23 | autocmd InsertLeave * call s:finishPopup(1) 24 | augroup END 25 | 26 | if g:acp_mappingDriven 27 | call s:mapForMappingDriven() 28 | else 29 | autocmd AcpGlobalAutoCommand CursorMovedI * call s:feedPopup() 30 | endif 31 | 32 | nnoremap i i=feedPopup() 33 | nnoremap a a=feedPopup() 34 | nnoremap R R=feedPopup() 35 | endfunction 36 | 37 | " 38 | function acp#disable() 39 | call s:unmapForMappingDriven() 40 | augroup AcpGlobalAutoCommand 41 | autocmd! 42 | augroup END 43 | nnoremap i | nunmap i 44 | nnoremap a | nunmap a 45 | nnoremap R | nunmap R 46 | endfunction 47 | 48 | " 49 | function acp#lock() 50 | let s:lockCount += 1 51 | endfunction 52 | 53 | " 54 | function acp#unlock() 55 | let s:lockCount -= 1 56 | if s:lockCount < 0 57 | let s:lockCount = 0 58 | throw "AutoComplPop: not locked" 59 | endif 60 | endfunction 61 | 62 | " 63 | function acp#meetsForSnipmate(context) 64 | if g:acp_behaviorSnipmateLength < 0 65 | return 0 66 | endif 67 | let matches = matchlist(a:context, '\(^\|\s\|\<\)\(\u\{' . 68 | \ g:acp_behaviorSnipmateLength . ',}\)$') 69 | return !empty(matches) && !empty(s:getMatchingSnipItems(matches[2])) 70 | endfunction 71 | 72 | " 73 | function acp#meetsForKeyword(context) 74 | if g:acp_behaviorKeywordLength < 0 75 | return 0 76 | endif 77 | let matches = matchlist(a:context, '\(\k\{' . g:acp_behaviorKeywordLength . ',}\)$') 78 | if empty(matches) 79 | return 0 80 | endif 81 | for ignore in g:acp_behaviorKeywordIgnores 82 | if stridx(ignore, matches[1]) == 0 83 | return 0 84 | endif 85 | endfor 86 | return 1 87 | endfunction 88 | 89 | " 90 | function acp#meetsForFile(context) 91 | if g:acp_behaviorFileLength < 0 92 | return 0 93 | endif 94 | if has('win32') || has('win64') 95 | let separator = '[/\\]' 96 | else 97 | let separator = '\/' 98 | endif 99 | if a:context !~ '\f' . separator . '\f\{' . g:acp_behaviorFileLength . ',}$' 100 | return 0 101 | endif 102 | return a:context !~ '[*/\\][/\\]\f*$\|[^[:print:]]\f*$' 103 | endfunction 104 | 105 | " 106 | function acp#meetsForRubyOmni(context) 107 | if !has('ruby') 108 | return 0 109 | endif 110 | if g:acp_behaviorRubyOmniMethodLength >= 0 && 111 | \ a:context =~ '[^. \t]\(\.\|::\)\k\{' . 112 | \ g:acp_behaviorRubyOmniMethodLength . ',}$' 113 | return 1 114 | endif 115 | if g:acp_behaviorRubyOmniSymbolLength >= 0 && 116 | \ a:context =~ '\(^\|[^:]\):\k\{' . 117 | \ g:acp_behaviorRubyOmniSymbolLength . ',}$' 118 | return 1 119 | endif 120 | return 0 121 | endfunction 122 | 123 | " 124 | function acp#meetsForPythonOmni(context) 125 | return has('python') && g:acp_behaviorPythonOmniLength >= 0 && 126 | \ a:context =~ '\k\.\k\{' . g:acp_behaviorPythonOmniLength . ',}$' 127 | endfunction 128 | 129 | " 130 | function acp#meetsForPerlOmni(context) 131 | return g:acp_behaviorPerlOmniLength >= 0 && 132 | \ a:context =~ '\w->\k\{' . g:acp_behaviorPerlOmniLength . ',}$' 133 | endfunction 134 | 135 | " 136 | function acp#meetsForXmlOmni(context) 137 | return g:acp_behaviorXmlOmniLength >= 0 && 138 | \ a:context =~ '\(<\|<\/\|<[^>]\+ \|<[^>]\+=\"\)\k\{' . 139 | \ g:acp_behaviorXmlOmniLength . ',}$' 140 | endfunction 141 | 142 | " 143 | function acp#meetsForHtmlOmni(context) 144 | return g:acp_behaviorHtmlOmniLength >= 0 && 145 | \ a:context =~ '\(<\|<\/\|<[^>]\+ \|<[^>]\+=\"\)\k\{' . 146 | \ g:acp_behaviorHtmlOmniLength . ',}$' 147 | endfunction 148 | 149 | " 150 | function acp#meetsForCssOmni(context) 151 | if g:acp_behaviorCssOmniPropertyLength >= 0 && 152 | \ a:context =~ '\(^\s\|[;{]\)\s*\k\{' . 153 | \ g:acp_behaviorCssOmniPropertyLength . ',}$' 154 | return 1 155 | endif 156 | if g:acp_behaviorCssOmniValueLength >= 0 && 157 | \ a:context =~ '[:@!]\s*\k\{' . 158 | \ g:acp_behaviorCssOmniValueLength . ',}$' 159 | return 1 160 | endif 161 | return 0 162 | endfunction 163 | 164 | " 165 | function acp#completeSnipmate(findstart, base) 166 | if a:findstart 167 | let s:posSnipmateCompletion = len(matchstr(s:getCurrentText(), '.*\U')) 168 | return s:posSnipmateCompletion 169 | endif 170 | let lenBase = len(a:base) 171 | let items = filter(GetSnipsInCurrentScope(), 172 | \ 'strpart(v:key, 0, lenBase) ==? a:base') 173 | return map(sort(items(items)), 's:makeSnipmateItem(v:val[0], v:val[1])') 174 | endfunction 175 | 176 | " 177 | function acp#onPopupCloseSnipmate() 178 | let word = s:getCurrentText()[s:posSnipmateCompletion :] 179 | for trigger in keys(GetSnipsInCurrentScope()) 180 | if word ==# trigger 181 | call feedkeys("\=TriggerSnippet()\", "n") 182 | return 0 183 | endif 184 | endfor 185 | return 1 186 | endfunction 187 | 188 | " 189 | function acp#onPopupPost() 190 | " to clear = expression on command-line 191 | echo '' 192 | if pumvisible() 193 | inoremap acp#onBs() 194 | inoremap acp#onBs() 195 | " a command to restore to original text and select the first match 196 | return (s:behavsCurrent[s:iBehavs].command =~# "\" ? "\\" 197 | \ : "\\") 198 | endif 199 | let s:iBehavs += 1 200 | if len(s:behavsCurrent) > s:iBehavs 201 | call s:setCompletefunc() 202 | return printf("\%s\=acp#onPopupPost()\", 203 | \ s:behavsCurrent[s:iBehavs].command) 204 | else 205 | let s:lastUncompletable = { 206 | \ 'word': s:getCurrentWord(), 207 | \ 'commands': map(copy(s:behavsCurrent), 'v:val.command')[1:], 208 | \ } 209 | call s:finishPopup(0) 210 | return "\" 211 | endif 212 | endfunction 213 | 214 | " 215 | function acp#onBs() 216 | " using "matchstr" and not "strpart" in order to handle multi-byte 217 | " characters 218 | if call(s:behavsCurrent[s:iBehavs].meets, 219 | \ [matchstr(s:getCurrentText(), '.*\ze.')]) 220 | return "\" 221 | endif 222 | return "\\" 223 | endfunction 224 | 225 | " }}}1 226 | "============================================================================= 227 | " LOCAL FUNCTIONS: {{{1 228 | 229 | " 230 | function s:mapForMappingDriven() 231 | call s:unmapForMappingDriven() 232 | let s:keysMappingDriven = [ 233 | \ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 234 | \ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 235 | \ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 236 | \ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 237 | \ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 238 | \ '-', '_', '~', '^', '.', ',', ':', '!', '#', '=', '%', '$', '@', '<', '>', '/', '\', 239 | \ '', '', '', ] 240 | for key in s:keysMappingDriven 241 | execute printf('inoremap %s %s=feedPopup()', 242 | \ key, key) 243 | endfor 244 | endfunction 245 | 246 | " 247 | function s:unmapForMappingDriven() 248 | if !exists('s:keysMappingDriven') 249 | return 250 | endif 251 | for key in s:keysMappingDriven 252 | execute 'iunmap ' . key 253 | endfor 254 | let s:keysMappingDriven = [] 255 | endfunction 256 | 257 | " 258 | function s:setTempOption(group, name, value) 259 | call extend(s:tempOptionSet[a:group], { a:name : eval('&' . a:name) }, 'keep') 260 | execute printf('let &%s = a:value', a:name) 261 | endfunction 262 | 263 | " 264 | function s:restoreTempOptions(group) 265 | for [name, value] in items(s:tempOptionSet[a:group]) 266 | execute printf('let &%s = value', name) 267 | endfor 268 | let s:tempOptionSet[a:group] = {} 269 | endfunction 270 | 271 | " 272 | function s:getCurrentWord() 273 | return matchstr(s:getCurrentText(), '\k*$') 274 | endfunction 275 | 276 | " 277 | function s:getCurrentText() 278 | return strpart(getline('.'), 0, col('.') - 1) 279 | endfunction 280 | 281 | " 282 | function s:getPostText() 283 | return strpart(getline('.'), col('.') - 1) 284 | endfunction 285 | 286 | " 287 | function s:isModifiedSinceLastCall() 288 | if exists('s:posLast') 289 | let posPrev = s:posLast 290 | let nLinesPrev = s:nLinesLast 291 | let textPrev = s:textLast 292 | endif 293 | let s:posLast = getpos('.') 294 | let s:nLinesLast = line('$') 295 | let s:textLast = getline('.') 296 | if !exists('posPrev') 297 | return 1 298 | elseif posPrev[1] != s:posLast[1] || nLinesPrev != s:nLinesLast 299 | return (posPrev[1] - s:posLast[1] == nLinesPrev - s:nLinesLast) 300 | elseif textPrev ==# s:textLast 301 | return 0 302 | elseif posPrev[2] > s:posLast[2] 303 | return 1 304 | elseif has('gui_running') && has('multi_byte') 305 | " NOTE: auto-popup causes a strange behavior when IME/XIM is working 306 | return posPrev[2] + 1 == s:posLast[2] 307 | endif 308 | return posPrev[2] != s:posLast[2] 309 | endfunction 310 | 311 | " 312 | function s:makeCurrentBehaviorSet() 313 | let modified = s:isModifiedSinceLastCall() 314 | if exists('s:behavsCurrent[s:iBehavs].repeat') && s:behavsCurrent[s:iBehavs].repeat 315 | let behavs = [ s:behavsCurrent[s:iBehavs] ] 316 | elseif exists('s:behavsCurrent[s:iBehavs]') 317 | return [] 318 | elseif modified 319 | let behavs = copy(exists('g:acp_behavior[&filetype]') 320 | \ ? g:acp_behavior[&filetype] 321 | \ : g:acp_behavior['*']) 322 | else 323 | return [] 324 | endif 325 | let text = s:getCurrentText() 326 | call filter(behavs, 'call(v:val.meets, [text])') 327 | let s:iBehavs = 0 328 | if exists('s:lastUncompletable') && 329 | \ stridx(s:getCurrentWord(), s:lastUncompletable.word) == 0 && 330 | \ map(copy(behavs), 'v:val.command') ==# s:lastUncompletable.commands 331 | let behavs = [] 332 | else 333 | unlet! s:lastUncompletable 334 | endif 335 | return behavs 336 | endfunction 337 | 338 | " 339 | function s:feedPopup() 340 | " NOTE: CursorMovedI is not triggered while the popup menu is visible. And 341 | " it will be triggered when popup menu is disappeared. 342 | if s:lockCount > 0 || pumvisible() || &paste 343 | return '' 344 | endif 345 | if exists('s:behavsCurrent[s:iBehavs].onPopupClose') 346 | if !call(s:behavsCurrent[s:iBehavs].onPopupClose, []) 347 | call s:finishPopup(1) 348 | return '' 349 | endif 350 | endif 351 | let s:behavsCurrent = s:makeCurrentBehaviorSet() 352 | if empty(s:behavsCurrent) 353 | call s:finishPopup(1) 354 | return '' 355 | endif 356 | " In case of dividing words by symbols (e.g. "for(int", "ab==cd") while a 357 | " popup menu is visible, another popup is not available unless input 358 | " or try popup once. So first completion is duplicated. 359 | call insert(s:behavsCurrent, s:behavsCurrent[s:iBehavs]) 360 | call s:setTempOption(s:GROUP0, 'spell', 0) 361 | call s:setTempOption(s:GROUP0, 'completeopt', 'menuone' . (g:acp_completeoptPreview ? ',preview' : '')) 362 | call s:setTempOption(s:GROUP0, 'complete', g:acp_completeOption) 363 | call s:setTempOption(s:GROUP0, 'ignorecase', g:acp_ignorecaseOption) 364 | " NOTE: With CursorMovedI driven, Set 'lazyredraw' to avoid flickering. 365 | " With Mapping driven, set 'nolazyredraw' to make a popup menu visible. 366 | call s:setTempOption(s:GROUP0, 'lazyredraw', !g:acp_mappingDriven) 367 | " NOTE: 'textwidth' must be restored after . 368 | call s:setTempOption(s:GROUP1, 'textwidth', 0) 369 | call s:setCompletefunc() 370 | call feedkeys(s:behavsCurrent[s:iBehavs].command . "\=acp#onPopupPost()\", 'n') 371 | return '' " this function is called by = 372 | endfunction 373 | 374 | " 375 | function s:finishPopup(fGroup1) 376 | inoremap | iunmap 377 | inoremap | iunmap 378 | let s:behavsCurrent = [] 379 | call s:restoreTempOptions(s:GROUP0) 380 | if a:fGroup1 381 | call s:restoreTempOptions(s:GROUP1) 382 | endif 383 | endfunction 384 | 385 | " 386 | function s:setCompletefunc() 387 | if exists('s:behavsCurrent[s:iBehavs].completefunc') 388 | call s:setTempOption(0, 'completefunc', s:behavsCurrent[s:iBehavs].completefunc) 389 | endif 390 | endfunction 391 | 392 | " 393 | function s:makeSnipmateItem(key, snip) 394 | if type(a:snip) == type([]) 395 | let descriptions = map(copy(a:snip), 'v:val[0]') 396 | let snipFormatted = '[MULTI] ' . join(descriptions, ', ') 397 | else 398 | let snipFormatted = substitute(a:snip, '\(\n\|\s\)\+', ' ', 'g') 399 | endif 400 | return { 401 | \ 'word': a:key, 402 | \ 'menu': strpart(snipFormatted, 0, 80), 403 | \ } 404 | endfunction 405 | 406 | " 407 | function s:getMatchingSnipItems(base) 408 | let key = a:base . "\n" 409 | if !exists('s:snipItems[key]') 410 | let s:snipItems[key] = items(GetSnipsInCurrentScope()) 411 | call filter(s:snipItems[key], 'strpart(v:val[0], 0, len(a:base)) ==? a:base') 412 | call map(s:snipItems[key], 's:makeSnipmateItem(v:val[0], v:val[1])') 413 | endif 414 | return s:snipItems[key] 415 | endfunction 416 | 417 | " }}}1 418 | "============================================================================= 419 | " INITIALIZATION {{{1 420 | 421 | let s:GROUP0 = 0 422 | let s:GROUP1 = 1 423 | let s:lockCount = 0 424 | let s:behavsCurrent = [] 425 | let s:iBehavs = 0 426 | let s:tempOptionSet = [{}, {}] 427 | let s:snipItems = {} 428 | 429 | " }}}1 430 | "============================================================================= 431 | " vim: set fdm=marker: 432 | -------------------------------------------------------------------------------- /doc/acp.jax: -------------------------------------------------------------------------------- 1 | *acp.txt* 補完メニューの自動ポップアップ 2 | 3 | Copyright (c) 2007-2009 Takeshi NISHIDA 4 | 5 | AutoComplPop *autocomplpop* *acp* 6 | 7 | 概要 |acp-introduction| 8 | インストール |acp-installation| 9 | 使い方 |acp-usage| 10 | コマンド |acp-commands| 11 | オプション |acp-options| 12 | SPECIAL THANKS |acp-thanks| 13 | CHANGELOG |acp-changelog| 14 | あばうと |acp-about| 15 | 16 | 17 | ============================================================================== 18 | 概要 *acp-introduction* 19 | 20 | このプラグインは、インサートモードで文字を入力したりカーソルを動かしたときに補 21 | 完メニューを自動的に開くようにします。しかし、続けて文字を入力するのを妨げたり 22 | はしません。 23 | 24 | 25 | ============================================================================== 26 | インストール *acp-installation* 27 | 28 | ZIPファイルをランタイムディレクトリに展開します。 29 | 30 | 以下のようにファイルが配置されるはずです。 31 | > 32 | /plugin/acp.vim 33 | /doc/acp.txt 34 | ... 35 | < 36 | もしランタイムディレクトリが他のプラグインとごた混ぜになるのが嫌なら、ファイル 37 | を新規ディレクトリに配置し、そのディレクトリのパスを 'runtimepath' に追加して 38 | ください。アンインストールも楽になります。 39 | 40 | その後 FuzzyFinder のヘルプを有効にするためにタグファイルを更新してください。 41 | 詳しくは|add-local-help|を参照してください。 42 | 43 | 44 | ============================================================================== 45 | 使い方 *acp-usage* 46 | 47 | このプラグインがインストールされていれば、自動ポップアップは vim の開始時から 48 | 有効になります。 49 | 50 | カーソル直前のテキストに応じて、利用する補完の種類を切り替えます。デフォルトの 51 | 補完動作は次の通りです: 52 | 53 | 補完モード filetype カーソル直前のテキスト ~ 54 | キーワード補完 * 2文字のキーワード文字 55 | ファイル名補完 * ファイル名文字 + パスセパレータ 56 | + 0文字以上のファイル名文字 57 | オムニ補完 ruby ".", "::" or 単語を構成する文字以外 + ":" 58 | オムニ補完 python "." 59 | オムニ補完 xml "<", ""以外の文字列 + " ") 60 | オムニ補完 html/xhtml "<", ""以外の文字列 + " ") 61 | オムニ補完 css (":", ";", "{", "^", "@", or "!") 62 | + 0個または1個のスペース 63 | 64 | さらに、設定を行うことで、ユーザー定義補完と snipMate トリガー補完 65 | (|acp-snipMate|) を自動ポップアップさせることができます。 66 | 67 | これらの補完動作はカスタマイズ可能です。 68 | 69 | *acp-snipMate* 70 | snipMate トリガー補完 ~ 71 | 72 | snipMate トリガー補完では、snipMate プラグイン 73 | (http://www.vim.org/scripts/script.php?script_id=2540) が提供するスニペットの 74 | トリガーを補完してそれを展開することができます。 75 | 76 | この自動ポップアップを有効にするには、次の関数を plugin/snipMate.vim に追加す 77 | る必要があります: 78 | > 79 | fun! GetSnipsInCurrentScope() 80 | let snips = {} 81 | for scope in [bufnr('%')] + split(&ft, '\.') + ['_'] 82 | call extend(snips, get(s:snippets, scope, {}), 'keep') 83 | call extend(snips, get(s:multi_snips, scope, {}), 'keep') 84 | endfor 85 | return snips 86 | endf 87 | < 88 | そして|g:acp_behaviorSnipmateLength|オプションを 1 にしてください。 89 | 90 | この自動ポップアップには制限があり、カーソル直前の単語は大文字英字だけで構成さ 91 | れていなければなりません。 92 | 93 | *acp-perl-omni* 94 | Perl オムニ補完 ~ 95 | 96 | AutoComplPop は perl-completion.vim 97 | (http://www.vim.org/scripts/script.php?script_id=2852) をサポートしています。 98 | 99 | この自動ポップアップを有効にするには、|g:acp_behaviorPerlOmniLength|オプション 100 | を 0 以上にしてください。 101 | 102 | 103 | ============================================================================== 104 | コマンド *acp-commands* 105 | 106 | *:AcpEnable* 107 | :AcpEnable 108 | 自動ポップアップを有効にします。 109 | 110 | *:AcpDisable* 111 | :AcpDisable 112 | 自動ポップアップを無効にします。 113 | 114 | *:AcpLock* 115 | :AcpLock 116 | 自動ポップアップを一時的に停止します。 117 | 118 | 別のスクリプトへの干渉を回避する目的なら、このコマンドと|:AcpUnlock| 119 | を利用することを、|:AcpDisable|と|:AcpEnable| を利用するよりも推奨しま 120 | す。 121 | 122 | *:AcpUnlock* 123 | :AcpUnlock 124 | |:AcpLock| で停止された自動ポップアップを再開します。 125 | 126 | 127 | ============================================================================== 128 | オプション *acp-options* 129 | 130 | *g:acp_enableAtStartup* > 131 | let g:acp_enableAtStartup = 1 132 | < 133 | 真なら vim 開始時から自動ポップアップが有効になります。 134 | 135 | *g:acp_mappingDriven* > 136 | let g:acp_mappingDriven = 0 137 | < 138 | 真なら|CursorMovedI|イベントではなくキーマッピングで自動ポップアップを 139 | 行うようにします。カーソルを移動するたびに補完が行われることで重いなど 140 | の不都合がある場合に利用してください。ただし他のプラグインとの相性問題 141 | や日本語入力での不具合が発生する可能性があります。(逆も然り。) 142 | 143 | *g:acp_ignorecaseOption* > 144 | let g:acp_ignorecaseOption = 1 145 | < 146 | 自動ポップアップ時に、'ignorecase' に一時的に設定する値 147 | 148 | *g:acp_completeOption* > 149 | let g:acp_completeOption = '.,w,b,k' 150 | < 151 | 自動ポップアップ時に、'complete' に一時的に設定する値 152 | 153 | *g:acp_completeoptPreview* > 154 | let g:acp_completeoptPreview = 0 155 | < 156 | 真なら自動ポップアップ時に、 'completeopt' へ "preview" を追加します。 157 | 158 | *g:acp_behaviorUserDefinedFunction* > 159 | let g:acp_behaviorUserDefinedFunction = '' 160 | < 161 | ユーザー定義補完の|g:acp_behavior-completefunc|。空ならこの補完は行わ 162 | れません。。 163 | 164 | *g:acp_behaviorUserDefinedMeets* > 165 | let g:acp_behaviorUserDefinedMeets = '' 166 | < 167 | ユーザー定義補完の|g:acp_behavior-meets|。空ならこの補完は行われません 168 | 。 169 | 170 | *g:acp_behaviorSnipmateLength* > 171 | let g:acp_behaviorSnipmateLength = -1 172 | < 173 | snipMate トリガー補完の自動ポップアップを行うのに必要なカーソルの直前 174 | のパターン。 175 | 176 | *g:acp_behaviorKeywordCommand* > 177 | let g:acp_behaviorKeywordCommand = "\" 178 | < 179 | キーワード補完のコマンド。このオプションには普通 "\" か "\" 180 | を設定します。 181 | 182 | *g:acp_behaviorKeywordLength* > 183 | let g:acp_behaviorKeywordLength = 2 184 | < 185 | キーワード補完の自動ポップアップを行うのに必要なカーソルの直前のキーワ 186 | ード文字数。負数ならこの補完は行われません。 187 | 188 | *g:acp_behaviorKeywordIgnores* > 189 | let g:acp_behaviorKeywordIgnores = [] 190 | < 191 | 文字列のリスト。カーソル直前の単語がこれらの内いずれかの先頭部分にマッ 192 | チする場合、この補完は行われません。 193 | 194 | 例えば、 "get" で始まる補完キーワードが多過ぎて、"g", "ge", "get" を入 195 | 力したときの自動ポップアップがレスポンスの低下を引き起こしている場合、 196 | このオプションに ["get"] を設定することでそれを回避することができます。 197 | 198 | *g:acp_behaviorFileLength* > 199 | let g:acp_behaviorFileLength = 0 200 | < 201 | ファイル名補完の自動ポップアップを行うのに必要なカーソルの直前のキーワ 202 | ード文字数。負数ならこの補完は行われません。 203 | 204 | *g:acp_behaviorRubyOmniMethodLength* > 205 | let g:acp_behaviorRubyOmniMethodLength = 0 206 | < 207 | メソッド補完のための、Ruby オムニ補完の自動ポップアップを行うのに必要 208 | なカーソルの直前のキーワード文字数。負数ならこの補完は行われません。 209 | 210 | *g:acp_behaviorRubyOmniSymbolLength* > 211 | let g:acp_behaviorRubyOmniSymbolLength = 1 212 | < 213 | シンボル補完のための、Ruby オムニ補完の自動ポップアップを行うのに必要 214 | なカーソルの直前のキーワード文字数。負数ならこの補完は行われません。 215 | 216 | *g:acp_behaviorPythonOmniLength* > 217 | let g:acp_behaviorPythonOmniLength = 0 218 | < 219 | Python オムニ補完の自動ポップアップを行うのに必要なカーソルの直前のキ 220 | ーワード文字数。負数ならこの補完は行われません。 221 | 222 | *g:acp_behaviorPerlOmniLength* > 223 | let g:acp_behaviorPerlOmniLength = -1 224 | < 225 | Perl オムニ補完の自動ポップアップを行うのに必要なカーソルの直前のキー 226 | ワード文字数。負数ならこの補完は行われません。 227 | 228 | See also: |acp-perl-omni| 229 | 230 | *g:acp_behaviorXmlOmniLength* > 231 | let g:acp_behaviorXmlOmniLength = 0 232 | < 233 | XML オムニ補完の自動ポップアップを行うのに必要なカーソルの直前のキーワ 234 | ード文字数。負数ならこの補完は行われません。 235 | 236 | *g:acp_behaviorHtmlOmniLength* > 237 | let g:acp_behaviorHtmlOmniLength = 0 238 | < 239 | HTML オムニ補完の自動ポップアップを行うのに必要なカーソルの直前のキー 240 | ワード文字数。負数ならこの補完は行われません。 241 | 242 | *g:acp_behaviorCssOmniPropertyLength* > 243 | let g:acp_behaviorCssOmniPropertyLength = 1 244 | < 245 | プロパティ補完のための、CSS オムニ補完の自動ポップアップを行うのに必要 246 | なカーソルの直前のキーワード文字数。負数ならこの補完は行われません。 247 | 248 | *g:acp_behaviorCssOmniValueLength* > 249 | let g:acp_behaviorCssOmniValueLength = 0 250 | < 251 | 値補完のための、CSS オムニ補完の自動ポップアップを行うのに必要なカーソ 252 | ルの直前のキーワード文字数。負数ならこの補完は行われません。 253 | 254 | *g:acp_behavior* > 255 | let g:acp_behavior = {} 256 | < 257 | 258 | これは内部仕様がわかっている人向けのオプションで、他のオプションでの設 259 | 定より優先されます。 260 | 261 | |Dictionary|型で、キーはファイルタイプに対応します。 '*' はデフォルト 262 | を表します。値はリスト型です。補完候補が得られるまでリストの先頭アイテ 263 | ムから順に評価します。各要素は|Dictionary|で詳細は次の通り: 264 | 265 | "command": *g:acp_behavior-command* 266 | 補完メニューをポップアップするためのコマンド。 267 | 268 | "completefunc": *g:acp_behavior-completefunc* 269 | 'completefunc' に設定する関数。 "command" が "" のときだけ 270 | 意味があります。 271 | 272 | "meets": *g:acp_behavior-meets* 273 | この補完を行うかどうかを判断する関数の名前。この関数はカーソル直前の 274 | テキストを引数に取り、補完を行うなら非 0 の値を返します。 275 | 276 | "onPopupClose": *g:acp_behavior-onPopupClose* 277 | この補完のポップアップメニューが閉じられたときに呼ばれる関数の名前。 278 | この関数が 0 を返した場合、続いて行われる予定の補完は抑制されます。 279 | 280 | "repeat": *g:acp_behavior-repeat* 281 | 真なら最後の補完が自動的に繰り返されます。 282 | 283 | 284 | ============================================================================== 285 | あばうと *acp-about* *acp-contact* *acp-author* 286 | 287 | 作者: Takeshi NISHIDA 288 | ライセンス: MIT Licence 289 | URL: http://www.vim.org/scripts/script.php?script_id=1879 290 | http://bitbucket.org/ns9tks/vim-autocomplpop/ 291 | 292 | バグや要望など ~ 293 | 294 | こちらへどうぞ: http://bitbucket.org/ns9tks/vim-autocomplpop/issues/ 295 | 296 | ============================================================================== 297 | vim:tw=78:ts=8:ft=help:norl: 298 | 299 | -------------------------------------------------------------------------------- /doc/acp.txt: -------------------------------------------------------------------------------- 1 | *acp.txt* Automatically opens popup menu for completions. 2 | 3 | Copyright (c) 2007-2009 Takeshi NISHIDA 4 | 5 | AutoComplPop *autocomplpop* *acp* 6 | 7 | INTRODUCTION |acp-introduction| 8 | INSTALLATION |acp-installation| 9 | USAGE |acp-usage| 10 | COMMANDS |acp-commands| 11 | OPTIONS |acp-options| 12 | SPECIAL THANKS |acp-thanks| 13 | CHANGELOG |acp-changelog| 14 | ABOUT |acp-about| 15 | 16 | 17 | ============================================================================== 18 | INTRODUCTION *acp-introduction* 19 | 20 | With this plugin, your vim comes to automatically opens popup menu for 21 | completions when you enter characters or move the cursor in Insert mode. It 22 | won't prevent you continuing entering characters. 23 | 24 | 25 | ============================================================================== 26 | INSTALLATION *acp-installation* 27 | 28 | Put all files into your runtime directory. If you have the zip file, extract 29 | it to your runtime directory. 30 | 31 | You should place the files as follows: 32 | > 33 | /plugin/acp.vim 34 | /doc/acp.txt 35 | ... 36 | < 37 | If you disgust to jumble up this plugin and other plugins in your runtime 38 | directory, put the files into new directory and just add the directory path to 39 | 'runtimepath'. It's easy to uninstall the plugin. 40 | 41 | And then update your help tags files to enable fuzzyfinder help. See 42 | |add-local-help| for details. 43 | 44 | 45 | ============================================================================== 46 | USAGE *acp-usage* 47 | 48 | Once this plugin is installed, auto-popup is enabled at startup by default. 49 | 50 | Which completion method is used depends on the text before the cursor. The 51 | default behavior is as follows: 52 | 53 | kind filetype text before the cursor ~ 54 | Keyword * two keyword characters 55 | Filename * a filename character + a path separator 56 | + 0 or more filename character 57 | Omni ruby ".", "::" or non-word character + ":" 58 | (|+ruby| required.) 59 | Omni python "." (|+python| required.) 60 | Omni xml "<", "" characters + " ") 61 | Omni html/xhtml "<", "" characters + " ") 62 | Omni css (":", ";", "{", "^", "@", or "!") 63 | + 0 or 1 space 64 | 65 | Also, you can make user-defined completion and snipMate's trigger completion 66 | (|acp-snipMate|) auto-popup if the options are set. 67 | 68 | These behavior are customizable. 69 | 70 | *acp-snipMate* 71 | snipMate's Trigger Completion ~ 72 | 73 | snipMate's trigger completion enables you to complete a snippet trigger 74 | provided by snipMate plugin 75 | (http://www.vim.org/scripts/script.php?script_id=2540) and expand it. 76 | 77 | 78 | To enable auto-popup for this completion, add following function to 79 | plugin/snipMate.vim: 80 | > 81 | fun! GetSnipsInCurrentScope() 82 | let snips = {} 83 | for scope in [bufnr('%')] + split(&ft, '\.') + ['_'] 84 | call extend(snips, get(s:snippets, scope, {}), 'keep') 85 | call extend(snips, get(s:multi_snips, scope, {}), 'keep') 86 | endfor 87 | return snips 88 | endf 89 | < 90 | And set |g:acp_behaviorSnipmateLength| option to 1. 91 | 92 | There is the restriction on this auto-popup, that the word before cursor must 93 | consist only of uppercase characters. 94 | 95 | *acp-perl-omni* 96 | Perl Omni-Completion ~ 97 | 98 | AutoComplPop supports perl-completion.vim 99 | (http://www.vim.org/scripts/script.php?script_id=2852). 100 | 101 | To enable auto-popup for this completion, set |g:acp_behaviorPerlOmniLength| 102 | option to 0 or more. 103 | 104 | 105 | ============================================================================== 106 | COMMANDS *acp-commands* 107 | 108 | *:AcpEnable* 109 | :AcpEnable 110 | enables auto-popup. 111 | 112 | *:AcpDisable* 113 | :AcpDisable 114 | disables auto-popup. 115 | 116 | *:AcpLock* 117 | :AcpLock 118 | suspends auto-popup temporarily. 119 | 120 | For the purpose of avoiding interruption to another script, it is 121 | recommended to insert this command and |:AcpUnlock| than |:AcpDisable| 122 | and |:AcpEnable| . 123 | 124 | *:AcpUnlock* 125 | :AcpUnlock 126 | resumes auto-popup suspended by |:AcpLock| . 127 | 128 | 129 | ============================================================================== 130 | OPTIONS *acp-options* 131 | 132 | *g:acp_enableAtStartup* > 133 | let g:acp_enableAtStartup = 1 134 | < 135 | If non-zero, auto-popup is enabled at startup. 136 | 137 | *g:acp_mappingDriven* > 138 | let g:acp_mappingDriven = 0 139 | < 140 | If non-zero, auto-popup is triggered by key mappings instead of 141 | |CursorMovedI| event. This is useful to avoid auto-popup by moving 142 | cursor in Insert mode. 143 | 144 | *g:acp_ignorecaseOption* > 145 | let g:acp_ignorecaseOption = 1 146 | < 147 | Value set to 'ignorecase' temporarily when auto-popup. 148 | 149 | *g:acp_completeOption* > 150 | let g:acp_completeOption = '.,w,b,k' 151 | < 152 | Value set to 'complete' temporarily when auto-popup. 153 | 154 | *g:acp_completeoptPreview* > 155 | let g:acp_completeoptPreview = 0 156 | < 157 | If non-zero, "preview" is added to 'completeopt' when auto-popup. 158 | 159 | *g:acp_behaviorUserDefinedFunction* > 160 | let g:acp_behaviorUserDefinedFunction = '' 161 | < 162 | |g:acp_behavior-completefunc| for user-defined completion. If empty, 163 | this completion will be never attempted. 164 | 165 | *g:acp_behaviorUserDefinedMeets* > 166 | let g:acp_behaviorUserDefinedMeets = '' 167 | < 168 | |g:acp_behavior-meets| for user-defined completion. If empty, this 169 | completion will be never attempted. 170 | 171 | *g:acp_behaviorSnipmateLength* > 172 | let g:acp_behaviorSnipmateLength = -1 173 | < 174 | Pattern before the cursor, which are needed to attempt 175 | snipMate-trigger completion. 176 | 177 | *g:acp_behaviorKeywordCommand* > 178 | let g:acp_behaviorKeywordCommand = "\" 179 | < 180 | Command for keyword completion. This option is usually set "\" or 181 | "\". 182 | 183 | *g:acp_behaviorKeywordLength* > 184 | let g:acp_behaviorKeywordLength = 2 185 | < 186 | Length of keyword characters before the cursor, which are needed to 187 | attempt keyword completion. If negative value, this completion will be 188 | never attempted. 189 | 190 | *g:acp_behaviorKeywordIgnores* > 191 | let g:acp_behaviorKeywordIgnores = [] 192 | < 193 | List of string. If a word before the cursor matches to the front part 194 | of one of them, keyword completion won't be attempted. 195 | 196 | E.g., when there are too many keywords beginning with "get" for the 197 | completion and auto-popup by entering "g", "ge", or "get" causes 198 | response degradation, set ["get"] to this option and avoid it. 199 | 200 | *g:acp_behaviorFileLength* > 201 | let g:acp_behaviorFileLength = 0 202 | < 203 | Length of filename characters before the cursor, which are needed to 204 | attempt filename completion. If negative value, this completion will 205 | be never attempted. 206 | 207 | *g:acp_behaviorRubyOmniMethodLength* > 208 | let g:acp_behaviorRubyOmniMethodLength = 0 209 | < 210 | Length of keyword characters before the cursor, which are needed to 211 | attempt ruby omni-completion for methods. If negative value, this 212 | completion will be never attempted. 213 | 214 | *g:acp_behaviorRubyOmniSymbolLength* > 215 | let g:acp_behaviorRubyOmniSymbolLength = 1 216 | < 217 | Length of keyword characters before the cursor, which are needed to 218 | attempt ruby omni-completion for symbols. If negative value, this 219 | completion will be never attempted. 220 | 221 | *g:acp_behaviorPythonOmniLength* > 222 | let g:acp_behaviorPythonOmniLength = 0 223 | < 224 | Length of keyword characters before the cursor, which are needed to 225 | attempt python omni-completion. If negative value, this completion 226 | will be never attempted. 227 | 228 | *g:acp_behaviorPerlOmniLength* > 229 | let g:acp_behaviorPerlOmniLength = -1 230 | < 231 | Length of keyword characters before the cursor, which are needed to 232 | attempt perl omni-completion. If negative value, this completion will 233 | be never attempted. 234 | 235 | See also: |acp-perl-omni| 236 | 237 | *g:acp_behaviorXmlOmniLength* > 238 | let g:acp_behaviorXmlOmniLength = 0 239 | < 240 | Length of keyword characters before the cursor, which are needed to 241 | attempt XML omni-completion. If negative value, this completion will 242 | be never attempted. 243 | 244 | *g:acp_behaviorHtmlOmniLength* > 245 | let g:acp_behaviorHtmlOmniLength = 0 246 | < 247 | Length of keyword characters before the cursor, which are needed to 248 | attempt HTML omni-completion. If negative value, this completion will 249 | be never attempted. 250 | 251 | *g:acp_behaviorCssOmniPropertyLength* > 252 | let g:acp_behaviorCssOmniPropertyLength = 1 253 | < 254 | Length of keyword characters before the cursor, which are needed to 255 | attempt CSS omni-completion for properties. If negative value, this 256 | completion will be never attempted. 257 | 258 | *g:acp_behaviorCssOmniValueLength* > 259 | let g:acp_behaviorCssOmniValueLength = 0 260 | < 261 | Length of keyword characters before the cursor, which are needed to 262 | attempt CSS omni-completion for values. If negative value, this 263 | completion will be never attempted. 264 | 265 | *g:acp_behavior* > 266 | let g:acp_behavior = {} 267 | < 268 | This option is for advanced users. This setting overrides other 269 | behavior options. This is a |Dictionary|. Each key corresponds to a 270 | filetype. '*' is default. Each value is a list. These are attempted in 271 | sequence until completion item is found. Each element is a 272 | |Dictionary| which has following items: 273 | 274 | "command": *g:acp_behavior-command* 275 | Command to be fed to open popup menu for completions. 276 | 277 | "completefunc": *g:acp_behavior-completefunc* 278 | 'completefunc' will be set to this user-provided function during the 279 | completion. Only makes sense when "command" is "". 280 | 281 | "meets": *g:acp_behavior-meets* 282 | Name of the function which dicides whether or not to attempt this 283 | completion. It will be attempted if this function returns non-zero. 284 | This function takes a text before the cursor. 285 | 286 | "onPopupClose": *g:acp_behavior-onPopupClose* 287 | Name of the function which is called when popup menu for this 288 | completion is closed. Following completions will be suppressed if 289 | this function returns zero. 290 | 291 | "repeat": *g:acp_behavior-repeat* 292 | If non-zero, the last completion is automatically repeated. 293 | 294 | 295 | ============================================================================== 296 | SPECIAL THANKS *acp-thanks* 297 | 298 | - Daniel Schierbeck 299 | - Ingo Karkat 300 | 301 | 302 | ============================================================================== 303 | CHANGELOG *acp-changelog* 304 | 305 | 2.14.1 306 | - Changed the way of auto-popup for avoiding an issue about filename 307 | completion. 308 | - Fixed a bug that popup menu was opened twice when auto-popup was done. 309 | 310 | 2.14 311 | - Added the support for perl-completion.vim. 312 | 313 | 2.13 314 | - Changed to sort snipMate's triggers. 315 | - Fixed a bug that a wasted character was inserted after snipMate's trigger 316 | completion. 317 | 318 | 2.12.1 319 | - Changed to avoid a strange behavior with Microsoft IME. 320 | 321 | 2.12 322 | - Added g:acp_behaviorKeywordIgnores option. 323 | - Added g:acp_behaviorUserDefinedMeets option and removed 324 | g:acp_behaviorUserDefinedPattern. 325 | - Changed to do auto-popup only when a buffer is modified. 326 | - Changed the structure of g:acp_behavior option. 327 | - Changed to reflect a change of behavior options (named g:acp_behavior*) 328 | any time it is done. 329 | - Fixed a bug that completions after omni completions or snipMate's trigger 330 | completion were never attempted when no candidate for the former 331 | completions was found. 332 | 333 | 2.11.1 334 | - Fixed a bug that a snipMate's trigger could not be expanded when it was 335 | completed. 336 | 337 | 2.11 338 | - Implemented experimental feature which is snipMate's trigger completion. 339 | 340 | 2.10 341 | - Improved the response by changing not to attempt any completion when 342 | keyword characters are entered after a word which has been found that it 343 | has no completion candidate at the last attempt of completions. 344 | - Improved the response by changing to close popup menu when was 345 | pressed and the text before the cursor would not match with the pattern of 346 | current behavior. 347 | 348 | 2.9 349 | - Changed default behavior to support XML omni completion. 350 | - Changed default value of g:acp_behaviorKeywordCommand option. 351 | The option with "\" cause a problem which inserts a match without 352 | when 'dictionary' has been set and keyword completion is done. 353 | - Changed to show error message when incompatible with a installed vim. 354 | 355 | 2.8.1 356 | - Fixed a bug which inserted a selected match to the next line when 357 | auto-wrapping (enabled with 'formatoptions') was performed. 358 | 359 | 2.8 360 | - Added g:acp_behaviorUserDefinedFunction option and 361 | g:acp_behaviorUserDefinedPattern option for users who want to make custom 362 | completion auto-popup. 363 | - Fixed a bug that setting 'spell' on a new buffer made typing go crazy. 364 | 365 | 2.7 366 | - Changed naming conventions for filenames, functions, commands, and options 367 | and thus renamed them. 368 | - Added g:acp_behaviorKeywordCommand option. If you prefer the previous 369 | behavior for keyword completion, set this option "\". 370 | - Changed default value of g:acp_ignorecaseOption option. 371 | 372 | The following were done by Ingo Karkat: 373 | 374 | - ENH: Added support for setting a user-provided 'completefunc' during the 375 | completion, configurable via g:acp_behavior. 376 | - BUG: When the configured completion is or , the command to 377 | restore the original text (in on_popup_post()) must be reverted, too. 378 | - BUG: When using a custom completion function () that also uses 379 | an s:...() function name, the s:GetSidPrefix() function dynamically 380 | determines the wrong SID. Now calling s:DetermineSidPrefix() once during 381 | sourcing and caching the value in s:SID. 382 | - BUG: Should not use custom defined completion mappings. Now 383 | consistently using unmapped completion commands everywhere. (Beforehand, 384 | s:PopupFeeder.feed() used mappings via feedkeys(..., 'm'), but 385 | s:PopupFeeder.on_popup_post() did not due to its invocation via 386 | :map-expr.) 387 | 388 | 2.6: 389 | - Improved the behavior of omni completion for HTML/XHTML. 390 | 391 | 2.5: 392 | - Added some options to customize behavior easily: 393 | g:AutoComplPop_BehaviorKeywordLength 394 | g:AutoComplPop_BehaviorFileLength 395 | g:AutoComplPop_BehaviorRubyOmniMethodLength 396 | g:AutoComplPop_BehaviorRubyOmniSymbolLength 397 | g:AutoComplPop_BehaviorPythonOmniLength 398 | g:AutoComplPop_BehaviorHtmlOmniLength 399 | g:AutoComplPop_BehaviorCssOmniPropertyLength 400 | g:AutoComplPop_BehaviorCssOmniValueLength 401 | 402 | 2.4: 403 | - Added g:AutoComplPop_MappingDriven option. 404 | 405 | 2.3.1: 406 | - Changed to set 'lazyredraw' while a popup menu is visible to avoid 407 | flickering. 408 | - Changed a behavior for CSS. 409 | - Added support for GetLatestVimScripts. 410 | 411 | 2.3: 412 | - Added a behavior for Python to support omni completion. 413 | - Added a behavior for CSS to support omni completion. 414 | 415 | 2.2: 416 | - Changed not to work when 'paste' option is set. 417 | - Fixed AutoComplPopEnable command and AutoComplPopDisable command to 418 | map/unmap "i" and "R". 419 | 420 | 2.1: 421 | - Fixed the problem caused by "." command in Normal mode. 422 | - Changed to map "i" and "R" to feed completion command after starting 423 | Insert mode. 424 | - Avoided the problem caused by Windows IME. 425 | 426 | 2.0: 427 | - Changed to use CursorMovedI event to feed a completion command instead of 428 | key mapping. Now the auto-popup is triggered by moving the cursor. 429 | - Changed to feed completion command after starting Insert mode. 430 | - Removed g:AutoComplPop_MapList option. 431 | 432 | 1.7: 433 | - Added behaviors for HTML/XHTML. Now supports the omni completion for 434 | HTML/XHTML. 435 | - Changed not to show expressions for CTRL-R =. 436 | - Changed not to set 'nolazyredraw' while a popup menu is visible. 437 | 438 | 1.6.1: 439 | - Changed not to trigger the filename completion by a text which has 440 | multi-byte characters. 441 | 442 | 1.6: 443 | - Redesigned g:AutoComplPop_Behavior option. 444 | - Changed default value of g:AutoComplPop_CompleteOption option. 445 | - Changed default value of g:AutoComplPop_MapList option. 446 | 447 | 1.5: 448 | - Implemented continuous-completion for the filename completion. And added 449 | new option to g:AutoComplPop_Behavior. 450 | 451 | 1.4: 452 | - Fixed the bug that the auto-popup was not suspended in fuzzyfinder. 453 | - Fixed the bug that an error has occurred with Ruby-omni-completion unless 454 | Ruby interface. 455 | 456 | 1.3: 457 | - Supported Ruby-omni-completion by default. 458 | - Supported filename completion by default. 459 | - Added g:AutoComplPop_Behavior option. 460 | - Added g:AutoComplPop_CompleteoptPreview option. 461 | - Removed g:AutoComplPop_MinLength option. 462 | - Removed g:AutoComplPop_MaxLength option. 463 | - Removed g:AutoComplPop_PopupCmd option. 464 | 465 | 1.2: 466 | - Fixed bugs related to 'completeopt'. 467 | 468 | 1.1: 469 | - Added g:AutoComplPop_IgnoreCaseOption option. 470 | - Added g:AutoComplPop_NotEnableAtStartup option. 471 | - Removed g:AutoComplPop_LoadAndEnable option. 472 | 1.0: 473 | - g:AutoComplPop_LoadAndEnable option for a startup activation is added. 474 | - AutoComplPopLock command and AutoComplPopUnlock command are added to 475 | suspend and resume. 476 | - 'completeopt' and 'complete' options are changed temporarily while 477 | completing by this script. 478 | 479 | 0.4: 480 | - The first match are selected when the popup menu is Opened. You can insert 481 | the first match with CTRL-Y. 482 | 483 | 0.3: 484 | - Fixed the problem that the original text is not restored if 'longest' is 485 | not set in 'completeopt'. Now the plugin works whether or not 'longest' is 486 | set in 'completeopt', and also 'menuone'. 487 | 488 | 0.2: 489 | - When completion matches are not found, insert CTRL-E to stop completion. 490 | - Clear the echo area. 491 | - Fixed the problem in case of dividing words by symbols, popup menu is 492 | not opened. 493 | 494 | 0.1: 495 | - First release. 496 | 497 | 498 | ============================================================================== 499 | ABOUT *acp-about* *acp-contact* *acp-author* 500 | 501 | Author: Takeshi NISHIDA 502 | Licence: MIT Licence 503 | URL: http://www.vim.org/scripts/script.php?script_id=1879 504 | http://bitbucket.org/ns9tks/vim-autocomplpop/ 505 | 506 | Bugs/Issues/Suggestions/Improvements ~ 507 | 508 | Please submit to http://bitbucket.org/ns9tks/vim-autocomplpop/issues/ . 509 | 510 | ============================================================================== 511 | vim:tw=78:ts=8:ft=help:norl: 512 | 513 | -------------------------------------------------------------------------------- /plugin/acp.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " Copyright (c) 2007-2009 Takeshi NISHIDA 3 | " 4 | " GetLatestVimScripts: 1879 1 :AutoInstall: AutoComplPop 5 | "============================================================================= 6 | " LOAD GUARD {{{1 7 | 8 | if exists('g:loaded_acp') 9 | finish 10 | elseif v:version < 702 11 | echoerr 'AutoComplPop does not support this version of vim (' . v:version . ').' 12 | finish 13 | endif 14 | let g:loaded_acp = 1 15 | 16 | " }}}1 17 | "============================================================================= 18 | " FUNCTION: {{{1 19 | 20 | " 21 | function s:defineOption(name, default) 22 | if !exists(a:name) 23 | let {a:name} = a:default 24 | endif 25 | endfunction 26 | 27 | " 28 | function s:makeDefaultBehavior() 29 | let behavs = { 30 | \ '*' : [], 31 | \ 'ruby' : [], 32 | \ 'python' : [], 33 | \ 'perl' : [], 34 | \ 'xml' : [], 35 | \ 'html' : [], 36 | \ 'xhtml' : [], 37 | \ 'css' : [], 38 | \ } 39 | "--------------------------------------------------------------------------- 40 | if !empty(g:acp_behaviorUserDefinedFunction) && 41 | \ !empty(g:acp_behaviorUserDefinedMeets) 42 | for key in keys(behavs) 43 | call add(behavs[key], { 44 | \ 'command' : "\\", 45 | \ 'completefunc' : g:acp_behaviorUserDefinedFunction, 46 | \ 'meets' : g:acp_behaviorUserDefinedMeets, 47 | \ 'repeat' : 0, 48 | \ }) 49 | endfor 50 | endif 51 | "--------------------------------------------------------------------------- 52 | for key in keys(behavs) 53 | call add(behavs[key], { 54 | \ 'command' : "\\", 55 | \ 'completefunc' : 'acp#completeSnipmate', 56 | \ 'meets' : 'acp#meetsForSnipmate', 57 | \ 'onPopupClose' : 'acp#onPopupCloseSnipmate', 58 | \ 'repeat' : 0, 59 | \ }) 60 | endfor 61 | "--------------------------------------------------------------------------- 62 | for key in keys(behavs) 63 | call add(behavs[key], { 64 | \ 'command' : g:acp_behaviorKeywordCommand, 65 | \ 'meets' : 'acp#meetsForKeyword', 66 | \ 'repeat' : 0, 67 | \ }) 68 | endfor 69 | "--------------------------------------------------------------------------- 70 | for key in keys(behavs) 71 | call add(behavs[key], { 72 | \ 'command' : "\\", 73 | \ 'meets' : 'acp#meetsForFile', 74 | \ 'repeat' : 1, 75 | \ }) 76 | endfor 77 | "--------------------------------------------------------------------------- 78 | call add(behavs.ruby, { 79 | \ 'command' : "\\", 80 | \ 'meets' : 'acp#meetsForRubyOmni', 81 | \ 'repeat' : 0, 82 | \ }) 83 | "--------------------------------------------------------------------------- 84 | call add(behavs.python, { 85 | \ 'command' : "\\", 86 | \ 'meets' : 'acp#meetsForPythonOmni', 87 | \ 'repeat' : 0, 88 | \ }) 89 | "--------------------------------------------------------------------------- 90 | call add(behavs.perl, { 91 | \ 'command' : "\\", 92 | \ 'meets' : 'acp#meetsForPerlOmni', 93 | \ 'repeat' : 0, 94 | \ }) 95 | "--------------------------------------------------------------------------- 96 | call add(behavs.xml, { 97 | \ 'command' : "\\", 98 | \ 'meets' : 'acp#meetsForXmlOmni', 99 | \ 'repeat' : 1, 100 | \ }) 101 | "--------------------------------------------------------------------------- 102 | call add(behavs.html, { 103 | \ 'command' : "\\", 104 | \ 'meets' : 'acp#meetsForHtmlOmni', 105 | \ 'repeat' : 1, 106 | \ }) 107 | "--------------------------------------------------------------------------- 108 | call add(behavs.xhtml, { 109 | \ 'command' : "\\", 110 | \ 'meets' : 'acp#meetsForHtmlOmni', 111 | \ 'repeat' : 1, 112 | \ }) 113 | "--------------------------------------------------------------------------- 114 | call add(behavs.css, { 115 | \ 'command' : "\\", 116 | \ 'meets' : 'acp#meetsForCssOmni', 117 | \ 'repeat' : 0, 118 | \ }) 119 | "--------------------------------------------------------------------------- 120 | return behavs 121 | endfunction 122 | 123 | " }}}1 124 | "============================================================================= 125 | " INITIALIZATION {{{1 126 | 127 | "----------------------------------------------------------------------------- 128 | call s:defineOption('g:acp_enableAtStartup', 1) 129 | call s:defineOption('g:acp_mappingDriven', 0) 130 | call s:defineOption('g:acp_ignorecaseOption', 1) 131 | call s:defineOption('g:acp_completeOption', '.,w,b,k') 132 | call s:defineOption('g:acp_completeoptPreview', 0) 133 | call s:defineOption('g:acp_behaviorUserDefinedFunction', '') 134 | call s:defineOption('g:acp_behaviorUserDefinedMeets', '') 135 | call s:defineOption('g:acp_behaviorSnipmateLength', -1) 136 | call s:defineOption('g:acp_behaviorKeywordCommand', "\") 137 | call s:defineOption('g:acp_behaviorKeywordLength', 2) 138 | call s:defineOption('g:acp_behaviorKeywordIgnores', []) 139 | call s:defineOption('g:acp_behaviorFileLength', 0) 140 | call s:defineOption('g:acp_behaviorRubyOmniMethodLength', 0) 141 | call s:defineOption('g:acp_behaviorRubyOmniSymbolLength', 1) 142 | call s:defineOption('g:acp_behaviorPythonOmniLength', 0) 143 | call s:defineOption('g:acp_behaviorPerlOmniLength', -1) 144 | call s:defineOption('g:acp_behaviorXmlOmniLength', 0) 145 | call s:defineOption('g:acp_behaviorHtmlOmniLength', 0) 146 | call s:defineOption('g:acp_behaviorCssOmniPropertyLength', 1) 147 | call s:defineOption('g:acp_behaviorCssOmniValueLength', 0) 148 | call s:defineOption('g:acp_behavior', {}) 149 | "----------------------------------------------------------------------------- 150 | call extend(g:acp_behavior, s:makeDefaultBehavior(), 'keep') 151 | "----------------------------------------------------------------------------- 152 | command! -bar -narg=0 AcpEnable call acp#enable() 153 | command! -bar -narg=0 AcpDisable call acp#disable() 154 | command! -bar -narg=0 AcpLock call acp#lock() 155 | command! -bar -narg=0 AcpUnlock call acp#unlock() 156 | "----------------------------------------------------------------------------- 157 | " legacy commands 158 | command! -bar -narg=0 AutoComplPopEnable AcpEnable 159 | command! -bar -narg=0 AutoComplPopDisable AcpDisable 160 | command! -bar -narg=0 AutoComplPopLock AcpLock 161 | command! -bar -narg=0 AutoComplPopUnlock AcpUnlock 162 | "----------------------------------------------------------------------------- 163 | if g:acp_enableAtStartup 164 | AcpEnable 165 | endif 166 | "----------------------------------------------------------------------------- 167 | 168 | " }}}1 169 | "============================================================================= 170 | " vim: set fdm=marker: 171 | --------------------------------------------------------------------------------