Question

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!

Was it helpful?

Solution 2

These answers being very outdated, and since I've struggle a little bit with it, here is an update:

Javascript semantic support in Vim with YouCompleteMe is now supported via TSServer engine as explained in Ycm's HUGE readme

I've got the information thanks to : https://medium.com/parallel-thinking/actually-great-vim-javascript-completion-eaefa1cb443d

OTHER TIPS

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.

At the moment there is no semantic completer for javascript available in YouCompleteMe. However, people are working on that. Here is the pending pull request for integrating JS Tern.

Without semantic completer available you are indeed limited to language agnostic completers, such as the identifier completer, filepath completer and snippet completer.

UPDATE: Tern has been integrated into YCM

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top