Vim Javascript Autocompletion + Suggestions?
Asked Answered
M

2

6

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 :)

Marlinemarlinespike answered 2/8, 2012 at 9:35 Comment(0)
A
-4

Your expectations are a bit too high. Vim is not an IDE like Aptana and the mechanisms used to provide completion are crude.

Did you check that your tags file has OpenLayers.Bounds, OpenLayers.Control or OpenLayer.Map? I can't find OpenLayer.Map and, going through the OpenLayer.debug.js I can't find this function either.

TagBar only works with the current buffer. If you want to show tags for other windows/buffers you'll need another older plugin: TagList.

AutoComplPop doesn't support JS out of the box. How did you set it up? Here is how I did but it still uses <C-x><C-o> while completion from tags is done with <C-x><C-]>.

Antisana answered 2/8, 2012 at 11:50 Comment(5)
Yeah, I've set up AutoComplPop as you suggested in the other post and now it works loading classes from tags file. The only embarrassing issue I'm getting now is related to Openlayers.js: jsctags OpenLayers.js gives me an embarassing Error: fixStm: 44, line 261, so I'm unable to create a tags file from it. But that's another story.Marlinemarlinespike
this answer might suggest giving up on setting the advanced autocomplete and definitions for Vim. There are plugins like youcompleteme and tern which seem to accomplish what the OP is asking for.Oder
@MaciejJankowski, there was no YCM or Tern in 2012.Antisana
@Antisana - could you please edit the answer so I can take the downvote off?Oder
Hahaha… are you kidding?Antisana
V
5

Check out YouCompleteMe and tern_for_vim.

Here's an article about using them together.

Verdin answered 1/3, 2014 at 20:28 Comment(1)
this is the best autocomplete package I found. Thanks!Oder
A
-4

Your expectations are a bit too high. Vim is not an IDE like Aptana and the mechanisms used to provide completion are crude.

Did you check that your tags file has OpenLayers.Bounds, OpenLayers.Control or OpenLayer.Map? I can't find OpenLayer.Map and, going through the OpenLayer.debug.js I can't find this function either.

TagBar only works with the current buffer. If you want to show tags for other windows/buffers you'll need another older plugin: TagList.

AutoComplPop doesn't support JS out of the box. How did you set it up? Here is how I did but it still uses <C-x><C-o> while completion from tags is done with <C-x><C-]>.

Antisana answered 2/8, 2012 at 11:50 Comment(5)
Yeah, I've set up AutoComplPop as you suggested in the other post and now it works loading classes from tags file. The only embarrassing issue I'm getting now is related to Openlayers.js: jsctags OpenLayers.js gives me an embarassing Error: fixStm: 44, line 261, so I'm unable to create a tags file from it. But that's another story.Marlinemarlinespike
this answer might suggest giving up on setting the advanced autocomplete and definitions for Vim. There are plugins like youcompleteme and tern which seem to accomplish what the OP is asking for.Oder
@MaciejJankowski, there was no YCM or Tern in 2012.Antisana
@Antisana - could you please edit the answer so I can take the downvote off?Oder
Hahaha… are you kidding?Antisana

© 2022 - 2024 — McMap. All rights reserved.