You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the past few weeks, I've been considering to make a formatter for ArkScript code, how it should format code, what rules we would need to implement, and the potential complexity of writing such a tool.
And so I started writing one to see how it works out, see #443.
The rules implemented for now are
functions definitions on the same line as the variable (unless the first line of the definition exceeds 32 characters):
(let foo (fun () ())
(fun (a b) (+ a b))
(fun (a) {
a })
comments inside the argument list splits the arguments on multiple lines
(fun (
# a
a
b
# capture
&c)
# body
{})
begin blocks are always spliting on multiple lines, and the last node before the closing } has a space to differentiate it and make it easier to read
function calls with at least one argument that spans on multiple lines will get all their arguments on a separate line:
(list:forEach
_listeners
(fun (element)
(if (= typ (@ element 0))
{
((@ element 1) val)
(set found true) })))
conditions are spliting then/else on multiple lines
More tests need to be added to ensure that it conforms to what we expect, and more rules might be introduced. Feel free to drop a code sample to see how it is formatted, and/or rules suggestions!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
For the past few weeks, I've been considering to make a formatter for ArkScript code, how it should format code, what rules we would need to implement, and the potential complexity of writing such a tool.
And so I started writing one to see how it works out, see #443.
The rules implemented for now are
(fun ( # a a b # capture &c) # body {})
}
has a space to differentiate it and make it easier to readthen
/else
on multiple linesMore tests need to be added to ensure that it conforms to what we expect, and more rules might be introduced. Feel free to drop a code sample to see how it is formatted, and/or rules suggestions!
Beta Was this translation helpful? Give feedback.
All reactions