JuliaFormatter.jl
JuliaFormatter.jl copied to clipboard
Option to add or at least not remove trailing semi-colons?
When running code in the REPL, I prefer not to have it flooded with text. Especially every time a function returns a long vector.
Yet JuliaFormatter strips semicolons, meaning that is exactly what happens.
Note that code inside various blocks will often be run in the REPL whilst debugging.
can you give an example ?
julia> s = """
a = 10;
b = 20;
"""
"a = 10;\n\nb = 20;\n"
julia> format_text(s) |> print
a = 10;
b = 20;
the semicolons are preserved
julia> format_text("""
begin
a = rand(100);
sum(a)
end
""") |> println
begin
a = rand(100)
sum(a)
end
When debugging, I often run the contents of blocks in my REPL line by line.
ok ic
CSTParser doesn't support semicolons really at all but I think we could do something similar to what we do for inline comments to catch these
Could we also get have an option we can set in our .JuliaFormatter.toml
to end all lines with a semicolon?
The removal of trailing semicolons can actually break code. Minimal example:
julia> code = raw":($([]...);)"
":(\$([]...);)"
julia> code |> Meta.parse |> eval
quote
end
julia> format_text(code) |> Meta.parse |> eval
ERROR: syntax: "..." expression outside call