Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim Javascript Autocompletion + Suggestions?

I'm developing on top of OpenLayers.js. My project folder is structured as follows:

project /
    |-- OpenLayers.js
    |-- map.html
    |-- map.js
    \-- etc

As you can argue, when I start a new map project, I espect suggestions from Vim on how to complete the code, reading JS classes from all the libraries in the project folder (in this case, just OpenLayers.js).

E.g.:

map = new OpenLayers. --> <C-x><C-o>
map = new OpenLayers.Bounds
                    .Control
                    .Map

Selecting one of the suggested classes I should get a kind of autocompletion, like in Aptana. I've installed AutoComplPop and I get a nice automatic menu to select suggestions, but all of them are taken from the current JS file.

Anyway, I've correctly set up Tagbar + node.js + jsctags and I've generated tags file for my project, and added set tags=./tags,./../tags,./*/tags to my .vimrc.

In this case, also, Tagbar maps the current file JS structure but doesn't offer any mapping of the classes coming from other files.

Another probably relevant line in my .vimrc:

autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS

I'm struggling to get class and subclass suggestions and now I'm getting a bit confused with all the plugins/piece of software available.

Any hint? Thank you guys :)

like image 327
fradeve Avatar asked Aug 02 '12 09:08

fradeve


People also ask

How do I get code suggestions in Vim?

to enter the *edit* mode and type any JavaScript keyword in the text editor and press *Ctrl + x* followed by *Ctrl + o*. Vim editor will show the possible auto-complete suggestions.

Does Vim have auto-complete?

Vim text editor supports autocompletion for the standard text files by default. Also, when configured properly, Vim enables an autocomplete feature for files with code in the languages it recognizes. In this tutorial, we'll see how the autocompletion support in Vim works.

Does Vim have intellisense?

The IDE or editor should help in a way to build programs. Vim helps in so many ways, and especially the auto-completion is provided by Vim, by default. But it does not give the intellisense which is beyond auto-completion. I think most of us know what is intellisense, which is provided by Visual Studio.

Does Vim support code completion?

To initiate code completion enter insert mode and type Ctrl-X Ctrl-U . By default Vim will open a popup if there is more than one completion. When using omnifunc you will use Ctrl-X Ctrl-O to start code completion.


1 Answers

Check out YouCompleteMe and tern_for_vim.

Here's an article about using them together.

like image 112
user456584 Avatar answered Oct 09 '22 22:10

user456584