All of this work is based on CSTParser.jl, which is actively maintained and also used by stuff that Julia Computing is putting out (e.g. femtocleaner).
VSCode is interesting. I am a big fan of Atom, and there is a really nice style checker for Python. Little warning trianges appear on the lines. This uses ‘pycodestyle’
Somethign similar for Julia woudl be most excellent. Happy to offer to test!
VSCode is mostly similar to Atom anyways, but with better performance and more active development etc. (also now that MS has bought Github). The VSCode extension is great and you can try it out to see if you can switch from Atom to VSCode.
@davidanthoff (and @ZacLN) thanks for those pointers! Those are great packages! I love it!
Has anyone put together integration with git, so that we can run format on just the lines that have changed between some commits? Basically the equivalent of how this is set up:
Haha okay, so… Ever impatient, i’ve gone ahead and hacked at it myself! >.< Oops!
It’s definitely work-in-progress, but this was enough to get the git-side of the glue hooked up! It’s currently just diffing HEAD against the previous commit here, but it won’t be hard to change that to read the commit range from the command line arguments.
The next problem is that (as far as I can tell) DocumentFormat.format() expects valid expressions in the input string, and not the partial-expressions that result from just reading whatever lines i happen to have modified.
So either that git configuration repository needs to be able to intelligently read above and below the modified section to find the start and end of a valid Expression chunk, or perhaps we could consider adding some awareness to DocumentFormat of context for formatting chunks of files?
------ EDIT: -------
Oh wait, that can’t be right! @davidanthoff was just saying above that you can format a “selection” in VSCode:
I’ll have to look at how you do that, and then Maybe this little git-configuration project will be just about finished!! Can you send me a pointer? I can’t seem to find where that’s implemented. thanks!
Hi, you’re correct we currently only format entire files, not snippets, as we need the full context to work out the correct indentation level.
We could apply a subset of the formatting edits produced by the current code only to the line marked as dirty by git (i.e. filter the edits by location) but this may put the indentation of said line out of whack with the rest of the file if it’s judged to be incorrectly indented by the formatter.
I might well have been wrong, I have a long track record of a) not knowing about features that exist in the VS Code extension and b) think we have other features that don’t exist
I have Julia 1.1.0 and the Julia extension for VS code 0.11.4 (released 24 Jan 2019), on Windows 10. I’m pretty sure that code formatting a document (F1 > Format Document) used to work (with an earlier version of the Julia extension that was compatible with Julia 0.6) but now I get a pop-up message “There is no document formatter for ‘julia’-files installed.” I tried the obvious - reinstalling the extension, rebooting the PC etc. but no dice.
It should work should it not? Can anyone suggest a solution? Thanks!
Ever wish your code automatically beautiful? Tired of spacing out commas, wrangling parenthesis and indenting? Julia’s formatter can do all this and more! Come find out how to use it your everyday workflow.