-
-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Formatter #258
Comments
Do you mean formatting cells after you submit them, or formatting the whole file and reopening the notebook? I appreciate your worries about breaking the minimalism, but isn’t that what adding this feature will do? |
I would like pressing "Ctrl+Alt+F" to run the contents of the cell I'm editing through |
The formatter can error? |
Yes, mainly on syntax errors. julia> JuliaFormatter.format_text("2+2")
"2 + 2"
julia> JuliaFormatter.format_text("2+")
ERROR: Parsing error for input:
2+
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] format_text(::String, ::JuliaFormatter.DefaultStyle, ::JuliaFormatter.Options) at /home/ilyagr/.julia/packages/JuliaFormatter/7belo/src/JuliaFormatter.jl:269
[3] #format_text#124 at /home/ilyagr/.julia/packages/JuliaFormatter/7belo/src/JuliaFormatter.jl:264 [inlined]
[4] format_text(::String) at /home/ilyagr/.julia/packages/JuliaFormatter/7belo/src/JuliaFormatter.jl:248
[5] top-level scope at REPL[188]:1
[6] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1088 I looked at JuliaFormatter source, and it seems that currently the error doesn't come with any details (such as which line it occurred on, or what is wrong). I guess that would be blocked on julia-vscode/CSTParser.jl#87. |
That's fine, you can get the error with |
Re-upping this if that's OK! In Jupyter I use https://github.com/dnanhkhoa/nb_black — it's a really simple extension that formats the code after running the cell. It means I don't have to worry about formatting at all — just type away and it'll look good when it's run. Having code well-formatted makes it easier to see its structure, including loops. I have the same thing when working in VSCode with Julia, but not with Julia in Pluto. Pluto takes care of so much mental overhead around state, but it adds back some of that with having to think about formatting. IIUC there was a concern about whether the formatter can error above. I don't think that should be a blocking concern — the formatter errors when the code is invalid Julia — so I would imagine Pluto could just ignore those errors, and we'd see the error picked up by the current Julia parser, just as it does now. Or am I missing something? Thank you for the superb app! |
Experiments in #1531 |
any news |
Okay so heads up, I am not sure if this is possible but just a thought.
I came across this package JuliaFormatter and it seems to support string as well as file formatting.
Since Pluto works so well in terms of presentation, maybe code formatting could also be something really cool? Without actually breaking the minimalism because I feel this is the only code editor which isn’t bogged down by a million things.
Just a thought.
I will test it out and see if it works without messing up Pluto files and let you know just in case.
The text was updated successfully, but these errors were encountered: