VIM Semantic JavaScript completion with YouCompleteMe?

danba picture danba · Mar 11, 2014 · Viewed 8.6k times · Source

is there any way to get semantic javascript code completion in VIM?

I've tried YouCompleteMe (YCM) and it gives me some code completion, however it is purely based upon my current buffer (or buffers?).

When I explicitly call :YcmCompleter, I get

ValueError: No semantic completer exists for filetypes: ['javascript']

I'm mostly working in node:sails.js and angularjs. I'd really appreciate a way of getting library methods suggested while typing (e.g. for angular, protractor / mocha / jasmine).

Thanks!

Answer

romainl picture romainl · Mar 11, 2014

From YCm's huge README:

YCM will use your omnifunc (see :h omnifunc in Vim) as a source for semantic completions if it does not have a native semantic completion engine for your file's filetype. Vim comes with okayish omnifuncs for various languages like Ruby, PHP etc. It depends on the language.

Tern for Vim provides the kind of completion you are looking for via Vim's native omni-completion (<C-x><C-o>). With that plugin installed, YCM should be able to use it transparently for JavaScript completion.