Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to setup both omni and keyword completion? #52

Closed
gadamiak opened this issue Oct 15, 2012 · 1 comment
Closed

How to setup both omni and keyword completion? #52

gadamiak opened this issue Oct 15, 2012 · 1 comment

Comments

@gadamiak
Copy link

I can't manage to setup both omni and keyword completion. From my understanding the completion should use the DefaultCompletionType and if that returns no results it should then use ContextDefaultCompletionType.

What I want to achieve is to use Omni first and if that returns no results use standard keyword completion. However I can't get it working. My setup is:

  let g:SuperTabDefaultCompletionType = 'context'
  let g:SuperTabContextDefaultCompletionType = '<c-o>'
  let g:SuperTabContextTextOmniPrecedence = ['&omnifunc', '&completefunc']
  let g:SuperTabLongestEnhanced = 1

When editing a php file, the omni is used as expected and a list of, say, variables is proposed exactly the same as when manually invoking <c-x><c-o>. But when writing a comment keyword completion is not invoked as it does when manually using <c-x><c-n>. The same thing happens in html, ie. tags are completed by omni but text is not completed by keyword.

When I switch g:SuperTabContextDefaultCompletionType to '<c-n>' the effect is opposite. In php only keyword completion is triggered, ie. pushing TAB after $ shows keywords not variables and I need to manually use <c-x><c-o>. In html it's the same and even worse because the built-in omni closing of html tags doesn't work, ie. pushing TAB after </ triggers filename completion instead of omni.

I guess, I don't quite understand the config options. How this should be set up to work as I described?

@ervandew
Copy link
Owner

What I want to achieve is to use Omni first and if that returns no results use standard keyword completion.

Supertab refers to this as 'completion chaining' and you have to enable this on a per buffer basis with a call to SuperTabChain as described in the supertab help (:help supertab-completionchaining).

So in your case, you'll need to first remove these two settings from your config:

Remove these
let g:SuperTabContextDefaultCompletionType = '<c-o>'
let g:SuperTabContextTextOmniPrecedence = ['&omnifunc', '&completefunc']

Then you can either setup supertab's completion chaining globally like so:

autocmd FileType *
  \ if &omnifunc != '' |
  \   call SuperTabChain(&omnifunc, "<c-p>") |
  \ endif

Or if you want to enable it for just php files, you can use:

autocmd FileType *.php
  \ if &omnifunc != '' |
  \   call SuperTabChain(&omnifunc, "<c-p>") |
  \ endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants