supertab
supertab copied to clipboard
Completion with CoffeeTags
I've got CoffeeTags installed, to use with Tagbar. It populates the tags
with items relevant to a CoffeeScript file.
I'm now trying to setup tab-completion as well, but I'm having a lot of trouble getting sensible results: I've configured my vimrc
as suggested …
set omnifunc=syntaxcomplete#Complete
let g:SuperTabDefaultCompletionType = "context"
… and when I hit <Tab>
on an undecorated identifier, I get the expected results:
Op
+ <Tab>
However, in other contexts, I suddenly get wildly inaccurate suggestions (with the simple ones not present at all):
o
+ <Tab>
What have I configured wrong here? How can I get the relevant tags
from CoffeeTags completed as expected?
I've never used coffeetags before, but it looks like it simply generates tags from a file. I'm not sure I've seen any vim plugin that can perform contextual code completion from just a tags file. The tag files are typically used for displaying an outline of a file or locating the definition of classes, method, etc. within the code base.
You may be able to use vim's tag completion (<c-x><c-]>
), but that will just let you complete over the entire tags file (assuming you have vim pointed at a tags file that coffeetags generated), not filtered by the context of the code you want to complete.
set omnifunc=syntaxcomplete#Complete
By setting that you are simply using the generic vim supplied syntax based code completion. I've never dug into the code for it, but as the docs states, it simply uses the current file types syntax highlight groups to generate proposals. It's not specific to coffeescript or any other language, so the usefulness of its results could vary widely. You can read more about it by running the following in vim: :help ft-syntax-omni
So ultimately I think the issue you are running into is that you don't have a coffeescript completion plugin to provide you with the kind of results you want. It looks like kchmck/vim-coffee-script provides a lot of coffescript features, and they use the following for code completion:
setlocal omnifunc=javascriptcomplete#CompleteJS