joeheyming / requirejs-emacs

Uses js2-mode to make Emacs interact with your RequireJS project
GNU General Public License v3.0
11 stars 2 forks source link

Working together? #4

Open NicolasPetton opened 9 years ago

NicolasPetton commented 9 years ago

Hi,

I've been working on a similar project for a while: https://github.com/NicolasPetton/amd-mode.el Would you like us to work together?

joeheyming commented 9 years ago

I would love to work together, but I'm not sure the best way to combine the projects.

I looked at your project and here are my notes: I think you prompt for the full file path, which I wanted to avoid. You are using projectile, which I am not very familiar with. Looks like you use it to traverse a project contents.

I like your amd-auto insert. I actually wrote that as a snippet. I was thinking of adding that to requirejs-emacs. Also the auto insert needs to take into account if there is a copyright for a project.

I was on the fence with creating an emacs mode for requirejs, and I wanted importing to be as easy as typing the module name and running a key combo. The real zen would be something like hooking into auto completion of a variable name and also importing the module.

Also, my team at work has some strict ordering rules, so I had to build the module sorting and hooks for customization into it.

I found that some projects have ambiguous imports, so I added a popup prompt when that is the case: e.g. you have two paths viewModels/Foo.js, and components/Foo.js

I always had the idea of somehow reading in the requirejs-config file and creating variable lookups with that.

joeheyming commented 9 years ago

Oh, I also want to investigate caching paths that are commonly used.

NicolasPetton commented 9 years ago

Joe Heyming notifications@github.com writes:

I would love to work together, but I'm not sure the best way to combine the projects.

I looked at your project and here are my notes: I think you prompt for the full file path, which I wanted to avoid.

You mean when prompting the user for a file to import? Why do you want to avoid it?

You are using projectile, which I am not very familiar with. Looks like you use it to traverse a project contents.

That's right, but can change.

I like your amd-auto insert. I actually wrote that as a snippet. I was thinking of adding that to requirejs-emacs. Also the auto insert needs to take into account if there is a copyright for a project.

We can improve auto-insert.

Also, my team at work has some strict ordering rules, so I had to build the module sorting and hooks for customization into it.

It could be integrated also.

I found that some projects have ambiguous imports, so I added a popup prompt when that is the case: e.g. you have two paths viewModels/Foo.js, and components/Foo.js

I always had the idea of somehow reading in the requirejs-config file and creating variable lookups with that.

Yes, that would be really useful.

domtronn commented 9 years ago

Hey guys, I also tried to solve this problem with a package I was developing called js-dependency-injector.el and found this a month ago and meant to comment then!

The one I've written ended up spawning my own project organisation package which allows you to basically define your requirejs config in json and it builds associative lists used for the injection using this python script. But to remove the dependency on the project management system I was wanting to define these requirejs configs in the root of the projects as a dot file for example. But it lets you define essentially libraries that you can import from.

The projects I work on also use a pre alpha version of require... So I tried to design to support both. Also, recently I've been working in node projects, so I added some support for Node.js' require which lets you include files with relative paths and as a node_module. And quite a few developers I work with use Emacs because of this ability over alternatives like WebStorm/IntelliJ/Atom/[Your Editor Here]...

I also wrote this as a Sublime Plugin which has a nice gif example... Sorry for the brain dump, but that's where I am with this! But yes, it'd be great if we could create a definitive solution to this and I'd be keen on working with this project if you think I could add value?

joeheyming commented 9 years ago

@domtronn Thanks for sharing your work on this. I really like the idea of also supporting nodejs. I also had the same idea of writing a script to parse the requirejs config. It may be better to just parse the json in a requirejs config via lisp.

I think that going forward, we need to look into converting requirejs-emacs into a minor mode for js2-mode. This way we can get the minor mode to detect if we are using define, or require for imports and then we can manage both styles.

joeheyming commented 9 years ago

@all I opened a couple generic issues, feel free to add more

joeheyming commented 8 years ago

But seriously

image