Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sublime plugin async #1

Closed
lencioni opened this issue May 1, 2016 · 5 comments · Fixed by #22
Closed

Make sublime plugin async #1

lencioni opened this issue May 1, 2016 · 5 comments · Fixed by #22

Comments

@lencioni
Copy link
Contributor

lencioni commented May 1, 2016

From @vini175pa on February 11, 2016 2:14

Hey, how are you doing? Some time ago, I've tested this plugin and I ran into some problems. I created an issue and I was encouraged to change some little things on the code, that later on fixed my problem. This inspired me to create my own plugin, since I was having other problems.

I'm using simple-import a lot and I thought that maybe you could incorporate some things of simple-import into import-js. I'm really into React development with ES6 so I was not using import-js because I know nothing about ruby and, until the version I was using, it didn't have an import like ES6.

It`s a 470 lines python file. If you have some time to have a look I appreciate.

https://github.com/vini175pa/simple-import-js

Copied from original issue: Galooshi/import-js#194

@lencioni
Copy link
Contributor Author

lencioni commented May 1, 2016

From @trotzig on February 11, 2016 13:28

That's cool! I like how it doesn't have any external dependencies. That's one bad thing about import-js, it will require you to know a little about Ruby (or at least know how to use Ruby gems). The reason for that is that import-js started out as a vim-only plugin. Vim has built-in support for Ruby, and I myself is most familiar with writing libraries in Ruby.

I don't know if they could be easily merged however. They seem to solve the problem slightly different. But there are probably things we can learn from each other. For once, it looks like your Sublime plugin is asynchronous, is that correct? I never got around to doing that for the Sublime plugin for import-js.

It would be interesting to know what problems you ran into, and also to see if you still run into them today. I understand if that's hard though, often you try something out until you hit too many issues and then just say f it... However, there have been a lot of changes done to import-js lately to support even more project layouts and environments. It would be fun if you would give the latest version a spin!

If you are interested in helping out more over here (yay, do it! 😄), I would be thrilled if you could make any improvements to the import-js Sublime plugin and how it uses the import-js command-line tool (which btw is better documented now). Async is one thing that would be nice. Another would be to make the selection lists better (right now it just pops up a list at the current cursor position, which might be completely off when importing many variables at once).

If you're looking for enhancements to make to your own plugin, here are a few suggestions:

  • Reuse the regexes used to parse current imports: https://github.com/trotzig/import-js/blob/master/lib/import_js/import_statement.rb#L20 . Those are extensively tested and should be fairly easy to port to python.
  • Rename the configuration file so that it's obvious by its name that it should be json: .simple-import.json
  • Look at how import-js parses the package.json file in order to find package dependencies. When your node_modules folder grows, searching in it will quickly become a bottleneck.

Again, thanks for joining forces on this!

@lencioni
Copy link
Contributor Author

lencioni commented May 1, 2016

From @vini175pa on February 11, 2016 15:16

Yes, I want to help! I will give a look at the code again and test the new version. The idea of "merging" these plugins was about getting some ideas, like async and improve both. I will try to implement the async on this.

The main idea of simple-import was just create an import of the word selected. Whatever the word was, it would just put an import <word> from <word>, to accelerate my development. But, when I started implementing search on this, I ran into the same problem of not being async. So I created a Simple Cycle.

The problem was when I had to do something asynchronously in a specific import the whole process was messed up. So I divided it on parts.

Store all selections as "pending" > Store all imports of this selection as pending > Resolve each import > Resolve the selection > Write the parsed imports of the selection on the Region

Then, a selection would be only written if every import of it was resolved. If an async request is made for an import, the Selection Object that stores this import will not be resolved until this request is done. I don't know how its done in import-js I will give it a look and see how I can improve this.

The problems I was having were some Ruby errors while running the plugin, I've never used Ruby so I think i have done something wrong while installing it :p. But I was also using a very young version of import-js, maybe I will not run into these problems again.

Another idea I have is to make it not only for js. It can me reused for other languages, like python. We just have to change how it is written, because the ideia of variable and module is the same.

Thanks to you, may the force by with us!

@lencioni
Copy link
Contributor Author

lencioni commented May 1, 2016

Love this! 👍

@lencioni
Copy link
Contributor Author

lencioni commented May 1, 2016

From @trotzig on March 3, 2016 19:53

I changed the title of this issue so that it's more actionable.

@lencioni
Copy link
Contributor Author

lencioni commented May 1, 2016

From @vini175pa on March 26, 2016 0:46

Sorry for taking so long to reply on this issue, I was working on two projects ( only one now ) and I had no time to give a look on the code. I will give it a look and try to help as much as I can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant