pangloss / vim-javascript

Vastly improved Javascript indentation and syntax support in Vim.
http://www.vim.org/scripts/script.php?script_id=4452
3.8k stars 358 forks source link

indentation using other than what is set for sw, ts #349

Closed bounceme closed 8 years ago

bounceme commented 8 years ago
foo(a(b,
      c))

if( a == b
   && c == d
 && e == f
   || g == h
     || i == j ) {
       a = b
       + c
       - d;
     }

These examples show that there can be situations where a line is indented from some offset based on the preceding characters, rather than depending on the users ts and sw choices. Also the second example is just very broken looking in general

wchargin commented 8 years ago

The first example is definitely the "expected" behavior: the continuation extends to the last opening delimiter in the line above, as in

someVeryLongFunctionCall(arg1,
                         arg2);

(Personally, I don't like it, and always prefer a constant &sw indentation for continuations, but that's what this indenter does.)

The second one is just busted, yeah.

bounceme commented 8 years ago

Well, i think that this is actually recommended for npm style code: https://docs.npmjs.com/misc/coding-style but the returned text,and also the ending delimiter if it is on it's own line, should be aligned to the opening delimiter.Could be different though, depending on comma placement

bounceme commented 8 years ago

this is closable,having the vertical alignment seems like a benefit if it is what npm recommends.I'd like this indent script also vertically align the terminal delimiter however but that is another issue.Thank you!