Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM Semantic JavaScript completion with YouCompleteMe?

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!

like image 820
danba Avatar asked Mar 11 '14 18:03

danba


2 Answers

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.

like image 127
romainl Avatar answered Oct 05 '22 10:10

romainl


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

like image 45
Aurélien Cibrario Avatar answered Oct 05 '22 10:10

Aurélien Cibrario