tststs / atom-ternjs

JavaScript code intelligence for atom with tern.js and autocomplete-plus
MIT License
627 stars 76 forks source link

Custom plugin #79

Open nkt opened 9 years ago

nkt commented 9 years ago

Is there any way for using custom plugins such as tern-node-express?

mbabauer commented 9 years ago

I too am having issues with custom plugins. I am trying to use the tern-meteor plugin.

What I found is that you can add the plugin to the /plugin folder where the atom-ternjs plugin is installed. On my Mac its ~/.atom/packages/atom-ternjs/node_modules/tern/plugin.

The issue I face is that updating the auto-ternjs package seems to wipe this folder out, meaning any customizations I add are thus gone.

So, is there a way to preserve the files there? If not, is there a location outside of the folder identified above that can be used to house the Tern plugins permanently?

tststs commented 9 years ago

Tern is at first looking for the plugin in the project-root. e.g.: your-project/meteor.js

If this file doesn't exists, tern is is looking into the fallback dir which is .atom/atom-ternjs/node_modules/tern/plugins. use this as a workaround as @mbabauer mentioned.

Maybe, a good solution would be, if tern searches node_modules for the plugin, so you can specify it in your package.json and store it locally in your project-folder. You may have a look here or open a ticket at marijnh/tern, to ask if this is possible.

@marijnh

mbabauer commented 9 years ago

So, if I am understanding you correctly, there is not permanent place to put the plugins such that they apply to all projects, since updating the atom-ternjs package would wipe out the atom plug-specific directory. The alternative would be to include the file in the root of the project folder, next to the .tern-project file?

tststs commented 9 years ago

I never tried to just copy the plugin into the project-root. Give it a try and tell us, if it works.

Another temporary solution would be to just symlink the meteor-package. So if the package updates, you just have to create the symlink again. For example store your meteor-package to /Users/username/meteor and create a symlink to this path at .atom/atom-ternjs/node_modules/tern/plugins

$ cd .atom/atom-ternjs/node_modules/tern/plugins
$ ln -s /Users/username/meteor

I don't now exactly if this works, so give it a try :)

thinklinux commented 9 years ago

I tried it. For me it does not work when I copy the plugin into the project-root. It works fine in the atom-ternjs/node_modules/tern/plugins There is a little bug in the term node module https://github.com/marijnh/tern/issues/137#issue-14277809 I've posted a temporary solution.

ShaharHD commented 9 years ago

I'm having same the requirement. My solution was to execute the following every time atom-ternjs is updated:

cd ~/.atom/packages/atom-ternjs/node_modules/tern
npm install tern-node-express
npm install tern-node-mongoose

I was looking to see how complex it would be to add to lib/atom-ternjs-config.coffee the ability to fetch url specified plugins using npm.

It seems the entry point for this needs to be implemented in prepareLibs:

If anyone is working on this already - I would be happy to know before I dive into this.