julia-vscode / DocumentFormat.jl

Auto-formatter for Julia
Other
62 stars 18 forks source link

Don't move things across lines #53

Closed davidanthoff closed 2 years ago

davidanthoff commented 4 years ago

For example, it changes

makedocs(
    modules = [StringBuilders],
    sitename = "StringBuilders.jl",
    pages = [
        "Home" => "index.md"
    ]
)

to

makedocs(modules = [StringBuilders],
    sitename = "StringBuilders.jl",
    pages = [
        "Home" => "index.md"
    ])

I kind of feel the removal of the line break after makedocs( in this case is not really necessary?

I'm less sure about the final parenthesis. Should that really not stay on its own line at the same indent as makedocs? Not sure...

waldyrious commented 4 years ago

FWIW, a rule of thumb I find useful to reason about these things is to apply the same logic:

That makes it a single rule that is never ambiguous nor context-dependent; it's easy for machines and humans alike to apply and verify; and it's visually helpful to represent the structure of the code in a consistent manner.

So in this case the result would be exactly as the top code block, or

makedocs(
    modules = [StringBuilders],
    sitename = "StringBuilders.jl",
    pages = ["Home" => "index.md"]
)
davidanthoff commented 4 years ago

I kind of feel that DocumentFormat should leave line breaks alone in general? And just fix indenting and white spaces?

norru commented 4 years ago

I was about to post a bug report saying DocumentFormat.jl doesn't tidy up across lines :) which is causing me to jump between VSC and Atom just to get that done.

EDIT: as Atom uses https://github.com/domluna/JuliaFormatter.jl, I can invoke it directly from VSC and skip a round trip :)

I generally expect a "prettyfier" to make my code pretty and tidy and that often requires moving code across lines, by breaking them down or merging them, which is fine.

I do agree that for @davidanthoff cases there must be an option to disable line break changes.

davidanthoff commented 4 years ago

Clearly something that needs to be an option :)