okay, i have finished it, very sweet~~~

this is code of function s:SuperTab and a function i add to the
script, just use this cover the function in your supertab.vim(version
0.46):

" s:SuperTab(command) {{{
" Used to perform proper cycle navigation as the user requests the
next or
" 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)
  let s:key = 0
  let s:col = col('.')
  if s:WillComplete()
    let key = ''
    " highlight first result if longest enabled
    if g:SuperTabLongestHighlight && !pumvisible() && &completeopt =~
'longest'
      let key = (b:complType == "\<c-p>") ? "\<c-p>" : "\<c-n>"
    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' &&
      \ (b:complType == "\<c-p>" ||
      \   (b:complType == 'context' &&
      \    tolower(g:SuperTabContextDefaultCompletionType) == '<c-
p>'))
      let s:key = 1
      return "\<c-n>"
    endif

    if b:complType == 'context'
      if index(g:SuperTabContextFileTypeExclusions, &ft) == -1
        let curline = getline('.')
        let cnum = col('.')
        let synname = synIDattr(synID(line('.'), cnum - 1, 1), 'name')
        if curline =~ '.*/\w*\%' . cnum . 'c' ||
          \ ((has('win32') || has('win64')) && curline =~ '.*\\\w*\
%' . cnum . 'c')
          return "\<c-x>\<c-f>" . key
        elseif curline =~ '.*\(\w\|[\])]\)\(\.\|::\|->\)\w*\%' .
cnum . 'c' &&
          \ synname !~ '\(String\|Comment\)'
          if &completefunc != ''
            return "\<c-x>\<c-u>" . key
          elseif &omnifunc != ''
            return "\<c-x>\<c-o>" . key
          endif
        endif
      endif
      let s:key = match(g:SuperTabContextDefaultCompletionType, '\c<c-
[np]>') != -1
      exec "let complType = \"" . escape
(g:SuperTabContextDefaultCompletionType, '<') . "\""
      return complType . key
    endif

    let s:key = b:complType =~ "\<c-n>\\|\<c-p>"
    return b:complType . key
  endif

  return "\<tab>"
endfunction " }}}

" s:ResultOfSuperTab() {{{1

function! s:ResultOfSuperTab()

    if s:key && col('.') == s:col && !pumvisible()
        if !empty(&omnifunc)
            return "\<c-x>\<c-o>"
        elseif !empty(&completefunc)
            return "\<c-x>\<c-u>"
        endif
    endif

    return ''

endfunction


" }}}1

then, change the ino maps like:

  ino <c-n> <c-r>=<SID>SuperTab('n')<cr><c-r>=<SID>ResultOfSuperTab()
<cr>
  ino <c-p> <c-r>=<SID>SuperTab('p')<cr><c-r>=<SID>ResultOfSuperTab()
<cr>

ok, more clever supertab:)

On 1月9日, 下午5时10分, StarWing <[email protected]> wrote:
> i want to spread the script supertab.vim, i want if has omnifunc or
> completefunc and the CompleteType is set to <c-x><c-p>, the script
> will first try to complete with <c-x><c-p>, and if it can't find any
> result, it use <c-x><c-o> or <c-x><c-u>, how can i did this?
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to