Replies: 3 comments 2 replies
-
Thanks for your question. No, there isn't currently a capture like this to preserve manual alignment. My immediate thought is that something like this would need to be too tightly coupled to the code for it to be of any use. For example, if such a capture existed, the only rule I can come up with that might be general enough to be useful would be something like: (
(_) . (comment) @prepend_input_spaces
) That may overgeneralise and it may do weird things across line boundaries. Moreover, of course, if that preceding node's indentation is changed by Topiary, then the input spaces will no longer make sense. For example, using
|
Beta Was this translation helpful? Give feedback.
-
Yeah, personally I don't think it's a particularly useful feature. Just receiving some complaints about the gnarled look of formatted comments here and there.
I've thought about that too. IMHO, users who are obsessed with aligned code are usually equipped with some sort of editor plugins that help to do the alignment automatically. So, an extra call of the plugin function after topiary suffices to output an idempotent and aligned format, which is not too bad. And maybe a capture that behaves like "pad spaces to input column number" helps with that, but I don't know if it's feasible to estimate node positions during the formatting procedure. With that being said, will you guys accept a PR of such feature if it's straightforward to implement? |
Beta Was this translation helpful? Give feedback.
-
One of the reasons why #170 is still open is because it goes against one of Topiary's core design principles; that is, of minimising diffs. However it's implemented, alignment will necessarily create noisy diffs. Having said that, it is one of the most requested features...so there comes a point where pragmatism wins out over design purity! We are always happy and appreciative to receive PRs, but my gut feeling on this one is that this is a bit of a "hacky" solution to the problem. In the best case scenario, pro-alignment users would need to do Topiary+aligner+Topiary, which seems pretty messy! Let me convert this issue to a discussion and we'll see where it goes... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When the input doc has already aligned comments like this:
I hope there's something like
@append_input_spaces
to keep the alignment.Take this as a workaround for #170
Beta Was this translation helpful? Give feedback.
All reactions