ganemone / NodeRequirer

A Sublime Text 3 plugin for requiring modules.
106 stars 21 forks source link

Allow user to define the require templates in config #17

Open megawac opened 9 years ago

megawac commented 9 years ago

It'd be cool if we could define these 2 templates in the configuration

yckart commented 9 years ago

@megawac

Just to be future save, I added commit hashes to the links. This is important, since the files could be changed, and the line-numbers don't persist the same "position":

Note: The hash is normally longer, I've just shortened a bit. Here's the full commit-hash: 91c3254299cf653095acf539724389b3ec13b2a4

megawac commented 9 years ago

By the way the advantage of this is users can define it to use let instead of var for example

garthk commented 9 years ago

+1 because I don't want the var statement and semicolon if I'm in the middle of a block of requires. I'm usually trying to maintain this:

var fs = require('fs'),
    path = require('path'),
    async = require('async'),
    _ = require('lodash');

I'd applaud madly if you could detect that situation, add the new assignment, and keep them sorted.

dantman commented 9 years ago

I actually think this idea should get a -1, as far as implementing it by letting custom templates be made.

@megawac's use case would be best supported by a preference that lets you choose the type of var declaration.

@garthk's use case (which is mine as well) has been mostly taken care of as the presence of any var, let, comma, opening bracket, or colon is detected. And the semicolon is gone. (Though I'm not sure what's wrong with the version in Package Control)

megawac commented 9 years ago

Another use case is this could add support for System.js and maybe even AMD

dantman commented 9 years ago

Another use case is this could add support for System.js and maybe even AMD

What would System.js imports look for NodeRequire?

AMD also doesn't look like snippets could help. It would need something more complex (detecting the define, modifying the array, and modifying the arguments of the function.

The current use of insert_snippet actually probably impedes implementation of that.

dantman commented 9 years ago

I submitted #24 for @megawac's let use case.