AndrewRadev/splitjoin.vim

javascript and others: split at dot

plexigras opened this issue · 1 comments

foo.bar(x => x.y).baz
foo
  .bar(x => x.y)
  .baz

Sorry for taking so long to get around to this.

I think I've managed to implement splitting and joining at dot, although I'm worried about priorities.

Basically, this code right now, when split on the "bar", would split the function's arguments:

foo.bar(x => x.y).baz

But with the dot splitter, it would split the dot instead. It'd still be possible to split arguments when inside the function call, which feels quite sensible to me, and consistent with the rest of the plugin, so I guess maybe that's fine. Although when splitting on "foo" instead, it splits the method, which is maybe a bit weird. Still, not terrible.

The rule would be: you have to be on the property/method after the dot to split it. Finding a following dot would be way too complicated with any arbitrary expression being there.

I've created a branch with this new functionality: split-js-at-dot. I'd really appreciate it if you could switch to that branch and use it for a while, and let me know if the splitter is "too powerful", stopping you from using other splitters. But if it turns out okay, I can definitely see this being applied to a lot of other languages.