tamzinblake / js3-mode

A chimeric fork of js2-mode and js-mode
GNU General Public License v3.0
181 stars 13 forks source link

Indentation problem with requirejs/AMD #67

Closed partap closed 11 years ago

partap commented 11 years ago

Basic file structure for an AMD module:

define(['dep1', 'dep2'], function (dep1, dep2) {
  // This is what I want 
  dep1.doStuff();
});

This works fine. However, if I have a module with a lots of deps, it looks more like this:

define([
  'dep1', 
  'dep2'
], function (dep1, dep2) {
  // This is what I want
  dep1.doStuff();
});

And js3-mode does the wrong thing...it bases the indent level from the start of "function", rather than the indent level of that line:

define([
  'dep1', 
  'dep2'
], function (dep1, dep2) {
     // Bad indent...this is not what I want!
     dep1.doStuff();
   });
tamzinblake commented 11 years ago

Yeah, for now this looks like a use case for js3-consistent-level-indent-inner-bracket. I'm not sure there's a general algorithmic solution that does what you want and doesn't cause problems with other indentation cases.

In general, js3-consistent-level-indent-inner-bracket seems to do what people want when they're using styles that put commas at the end of lines. Let me know what you think.

partap commented 11 years ago

Yeah, that looks good now. Thanks!

tamzinblake commented 11 years ago

Closing since it doesn't look like anyone needs me to actually solve this further.

partap commented 11 years ago

Kudos on the quick response, btw!