domluna / JuliaFormatter.jl

An opinionated code formatter for Julia. Plot twist - the opinion is your own.
https://domluna.github.io/JuliaFormatter.jl/dev/
MIT License
572 stars 67 forks source link

format for short begin end block #630

Open isaacsas opened 2 years ago

isaacsas commented 2 years ago

In Catalyst.jl with SciMLStyle we are seeing that

rn = @reaction_network begin
     k/$V, A + B --> C
end k

gets formatted as

rn = @reaction_network begin k / $V, A + B --> C end k

Is there anything in SciMLStyle that could be changed / set to prevent this?

CC: https://github.com/SciML/SciMLStyle/issues/25

domluna commented 2 years ago

so by default the first block is how it would be formatted. SciML overrides p_begin https://github.com/domluna/JuliaFormatter.jl/blob/master/src/styles/sciml/pretty.jl#L91-L118 which is it's being formatted the way it is.

@YingboMa wrote that bit afaik https://github.com/domluna/JuliaFormatter.jl/blame/598a2485bbd36a118c66b3774e73684c4a4e9697/src/styles/sciml/pretty.jl#L91-L118

isaacsas commented 2 years ago

Thanks for the info! @YingboMa would you consider changing that to preserve the first form?

3f6a commented 1 year ago

I am also running into this. Was there a decision made?

YingboMa commented 1 year ago

I think so