What constitutes a continuation line exactly? The official style guide does not specify it very granularly. It only has this rule:
Use 2 indent levels to distinguish continuation lines from regular code blocks.
effect.interpolate_property(sprite, "transform/scale",
sprite.get_scale(), Vector2(2.0, 2.0), 0.3,
Tween.TRANS_QUAD, Tween.EASE_OUT)
Does it apply if we lay all the arguments vertically? When defining enums, dictionaries, etc. we use a single indentation by default. For now, the formatter considers most line wraps to be continuations. But perhaps the only case where this should truly apply is the case written above or when a line ends with a backslash.
If someone has experience developing/contributing to formatters or has ideas about this, feedback's most welcome.
The formatter would ideally never format like the above to me, but rather more like this:
effect.interpolate_property(
sprite, "transform/scale", sprite.get_scale(), Vector2(2.0, 2.0),
0.3, Tween.TRANS_QUAD, Tween.EASE_OUT
)
Or a variant of this, all I mean with this example is that I would always have the arguments separated from the function identifier, on separate lines.
Side notes on hinting line packing from the user
One feature that was interesting with the library we previouysly used for this formatter is it allowed you to hint whether to keep something on one line or wrap it over multiple lines. By inserting line returns.
When it comes to packing and wrapping lines, we could do something automatic by default, and also have a system like Zig's formatter, where you can yourself insert a line return to indicate how many arguments you want per line. For example, something like this could tell the formatter "I want two arguments per line"
effect.interpolate_property(
sprite, "transform/scale",
sprite.get_scale(), Vector2(2.0, 2.0), 0.3, Tween.TRANS_QUAD, Tween.EASE_OUT)
And format into this:
effect.interpolate_property(
sprite, "transform/scale",
sprite.get_scale(), Vector2(2.0, 2.0),
0.3, Tween.TRANS_QUAD,
Tween.EASE_OUT
)
This is just one example, the idea is this gives you optional control on top of a "just works" default behavior. It's particularly useful for some data structures like an array representing a grid or matrix:
var grid_3_by_3 = [0, 0, 1, 0, 0, 0, 1, 1, 0]
You could insert a line return like this, after 3 items:
var grid_3_by_3 = [0, 0, 1,
0, 0, 0, 1, 1, 0]
And get this:
var grid_3_by_3 = [
0, 0, 1,
0, 0, 0,
1, 1, 0
]
Right now I've implemented an automatic rule for a few cases where, when a line is too long, the system tries to balance out the lines with an equal number of expression parts or elements per line.
To be defined. I'm just dumping some notes as my teammate pointed out this possibility
What constitutes a continuation line exactly? The official style guide does not specify it very granularly. It only has this rule:
Does it apply if we lay all the arguments vertically? When defining enums, dictionaries, etc. we use a single indentation by default. For now, the formatter considers most line wraps to be continuations. But perhaps the only case where this should truly apply is the case written above or when a line ends with a backslash.
If someone has experience developing/contributing to formatters or has ideas about this, feedback's most welcome.
The formatter would ideally never format like the above to me, but rather more like this:
Or a variant of this, all I mean with this example is that I would always have the arguments separated from the function identifier, on separate lines.
Side notes on hinting line packing from the user
One feature that was interesting with the library we previouysly used for this formatter is it allowed you to hint whether to keep something on one line or wrap it over multiple lines. By inserting line returns.
When it comes to packing and wrapping lines, we could do something automatic by default, and also have a system like Zig's formatter, where you can yourself insert a line return to indicate how many arguments you want per line. For example, something like this could tell the formatter "I want two arguments per line"
And format into this:
This is just one example, the idea is this gives you optional control on top of a "just works" default behavior. It's particularly useful for some data structures like an array representing a grid or matrix:
You could insert a line return like this, after 3 items:
And get this:
Right now I've implemented an automatic rule for a few cases where, when a line is too long, the system tries to balance out the lines with an equal number of expression parts or elements per line.
To be defined. I'm just dumping some notes as my teammate pointed out this possibility