Does a code formatter exist?

Not anything crazy - i.e. traversing the tree - but something in the vein of black or clang-format ?
Would be great to have all my code look the same, I find it much easier to understand thing when they’re consistently formatted.



I’d also like to have a code-formatting feature in the SuperCollider-IDE, but that wouldn’t be possible because SuperCollider supports a wide range of code styles:

SuperCollider lends itself to MANY different coding styles - that’s one of it’s biggest benefits, and biggest hazards.
(Some notes on writing SuperCollider code for non-programmers)

Yeah, I saw that, and I figured there’d be at least something for an opinionated format.
I futzed with clang-format and it seems that i’ll be able to make it work with a few rule tweaks.

The SuperCollider ide already auto-formats all code? In fact, it’s not possible to turn it off, and there are some non-standard style things it does, so it’s a little annoying :slight_smile:

oh haha I’ve never used the SCIde! I’ve always just used vim bc I’m so used to it.
Does anyone know what snippet is called when the file is saved ? I likely can use that instead of clang-format.

I’d be really interested in using something like that with vim but I haven’t been able to figure out yet how to adapt clang-format to do that for me - would clang-format be able to add ; at the end of lines?

Afaik, clang-formatter is only going to move your code around, not add additional sigils (except for when it creates a comment block).

@madskjeldgaard has added TreeSitter support for sclang - I think this could be used to do formatting in neovim…