ternjs/tern_for_vim

Autocomplete for external libs doesn't work

Opened this issue · 9 comments

Using Vim with YCM installed:

  • Create a new directory:
    mkdir cheerio & cd cheerio
  • Install the cheerio package: npm install cheerio (this creates a node_modules directory)
  • Create a .tern-project file and add the node plugin inside:
{
  "plugins": {
    "node": { }
  }
}
  • Edit a new file in vim (index.js for example) and start typing:
    vim tern_for_vim

Only the basic Object functions appear in the autocomplete menu.

  • Node modules seem to work just fine:

vim tern_for_vim http

Am I missing something? Is there anything else that I should do in order for enabling external libraries autocomplete ?

I am seeing this too. With cheerio. But other modules seem fine. I guess this may have something to do with how cheerio defines methods or something.

@artemave Well, I've tried express and koa packages as well:

express = require('express');
app = express();

app.

The above only shows my request and response objects...

just checked with lodash package, seems to work fine...

I guess you're right, probably the way the module defines methods.

@marijnh any chance you can confirm this?

Tern's type inference isn't infallible, it will fail to infer some types, especially when they are created with strange patterns.

same issue with me

Am also facing the same issue with "cheerio" package.

I landed here due to the exact same scenario as @mikeys with express and app.

Same, is it fixable somehow ? The issue has been opened for two years I'm curious is there is a workaround.

I think this issue should belong to tern itself. https://github.com/ternjs/tern/
And for now, I don't plan to do large change to deal with strange patterns.
So the best way is to write a plugin for the library you use.