import-js icon indicating copy to clipboard operation
import-js copied to clipboard

Add WebStorm plugin

Open lencioni opened this issue 9 years ago • 1 comments

Now that import-js has extracted the core into a standalone gem, it can be integrated more easily with additional editors. We already have emacs and Sublime Text support and we should add WebStorm support. https://plugins.jetbrains.com/webStorm

In a recent JS survey, WebStorm was one of the most popular editors for JS developers: https://ponyfoo.com/articles/javascript-developer-survey-results#what-are-your-preferred-text-editors

lencioni avatar Jan 06 '16 17:01 lencioni

To create a plugin, there are a few options. The best thing is if the editor already supports plugins written in Ruby. Then you can directly instantiate a ImportJS::Importer with a custom editor class (e.g. ImportJS::WebStormEditor). Look at ImportJS::VIMEditor for inspiration.

If the plugin framework doesn't allow Ruby plugins, then you can do what the Sublime plugin does: use the external import-js command-line tool (available after installing the import_js gem, notice differences in dash and underscore between gem and CLI tool - that's unfortunate but intentional). The CLI tool accepts file contents via stdin, and outputs the whole file again (after doing imports) in stdout. In case there are messages to display, or ambiguities to resolve, stderr contains a JSON blob with useful information. See https://github.com/trotzig/import-js/blob/master/import-js.py for how the Sublime plugin is implemented.

The Emacs plugin uses a slightly different approach. It keeps a running Ruby process and passes messages back and forth. See https://github.com/trotzig/import-js/blob/master/plugin/import-js.el .

I'll be happy to provide continued support for whoever makes an attempt at creating a plugin.

trotzig avatar Jan 20 '16 10:01 trotzig

Is this still relevant? @trotzig @lencioni

mikabytes avatar Jan 24 '24 11:01 mikabytes

I think we can close this out.

lencioni avatar Jan 24 '24 14:01 lencioni