fredrikekre / Runic.jl

A code formatter for Julia with rules set in stone.
MIT License
98 stars 3 forks source link

Enforce leading and trailing newline in blocklike constructs #46

Closed fredrikekre closed 2 months ago

fredrikekre commented 2 months ago

This patch introduces formatting for all blocklike constructs (if/try/function/begin/for/while/...) such that inner block always start and end with a newline character.

For example,

if x print("x") else print("y") end

will be reformatted as

if x
    print("x")
else
    print("y")
end

An exception is (currently) made for comments, for example

if x # comment
    print("x")
end

will not be formatted as

if x
    # comment
    print("x")
end

even though the comment is technically inside the block.

Closes #35.