Nathan (GDQuest)
@gdquest.bsky.social
4K followers 72 following 87 posts
Become a game developer with the Godot game engine! Hundreds of free tutorials and open-source demos: http://gdquest.com
Posts Media Videos Starter Packs
gdquest.bsky.social
Currently the Godot addon can update the formatter to the latest version, but there is nothing built into the formatter itself for that.
gdquest.bsky.social
GDScript Formatter can reorder your GDScript code for you!

Signals and variables first, then built-in Godot functions, then public and private custom functions, etc.

It's open source, written in Rust, and runs fast.

Give it a try: www.gdquest.com/library/gdsc...
gdquest.bsky.social
By making an external program with this rust technology, we already have a more reliable, fast formatter for the community right now that we can use in production with less work and maintenance though (much more accessible to contributors to collab on too).
gdquest.bsky.social
No, this is an add-on which unfortunately has no access to the language server. But it's compatible with all code editors and we have configuration info for multiple code editors here: www.gdquest.com/library/gdsc...

VSCode setup guide coming soon.
GDScript Formatter: The fast formatter for Godot 4 | GDQuest Library
Learn how to install and use GDScript Formatter, a fast-running formatter for GDScript in Godot 4. Format and reorder your code according to the official style guide.
www.gdquest.com
gdquest.bsky.social
Yes, it's bound to a predefined shortcut by default, or can run automatically on save. Now a limitation of Godot is that you cannot integrate an add-on with the editor shortcuts yet. So we'd have to code something custom to allow you to change the shortcut.
gdquest.bsky.social
Note that this could certainly be addressed in GDFormat. In part I didn't want to weigh on the open source project of a busy dev. with our unique use cases. Then initially this was just a quick test but well it ends up helping with speed + helps improve GDScript support in 3rd parties so here we are
gdquest.bsky.social
We use them in our curriculum to always pull in up-to-date code and use the source code files as a source of truth. They go through a custom parser that picks up the regions + main code definitions and hides the gdquest markup from the output.
gdquest.bsky.social
The main thing is lots of custom code regions, typically delineated with comments, at all kinds of indent levels, sometimes dedented compared to the function, sometimes indented with the code, that get hit by vertical spacing rules.
gdquest.bsky.social
Then I asked the team about having an option in Godot to use an external formatter. For auto-install, they recommended building an add-on.

An option to give a path to the external formatter could be added but not all other features, so now I think we might as well just have the addon.
gdquest.bsky.social
At the same time, there is this rust technology that makes building and maintaining a code formatter much easier. So I went with that, initially just to try, and within maybe 15-20h of work we had a formatter that handled almost all our code. We could also have features like code reordering.
gdquest.bsky.social
As far as formatting goes, it aims to follow the official style guide in both cases.

At GDQuest, we have special markup in our code that wouldn't work well with GDFormat in ways that are not super easy to address.
gdquest.bsky.social
The most noticeable difference is speed: it's around 10x faster on a modern computer (with room to make it faster in the future).

Yes, there is a VSCode extension already by a contributor: marketplace.visualstudio.com/items?itemNa...
godot-format - Visual Studio Marketplace
Extension for Visual Studio Code - A formatter for Godot/GDScript using GDQuest's gdscript formatter
marketplace.visualstudio.com
gdquest.bsky.social
GDScript code formatting in an instant coming soon in a Godot editor near you.

Works automatically on save too.
gdquest.bsky.social
Right now the config is through the command line - it's mainly tabs vs spaces for indentation. If there's more configuration you rely on in your work or the editorconfig format, don't hesitate to open an issue.

Note the formatter doesn't support line length and auto-wrapping at the moment.
gdquest.bsky.social
There are multiple people interested in contributing, so if we document potential refactors and improvements, these can be picked up by fellow devs if I can't get to it personally.
gdquest.bsky.social
The top priority is making sure the formatter itself is reliable but anything we can easily change or improve along the way or even just note down for later is really welcome.
gdquest.bsky.social
Thanks! I have nearly no prior experience in Rust so any feedback an experience rust dev has on the code is most welcome.
gdquest.bsky.social
The major plus is that instead of requiring hundreds of hours of work it took dozens, for a program that is reliable enough and runs fast enough for production use.

Precompiling and serializing these queries is a planned item on the technology's roadmap, but they still haven't gotten to it.
gdquest.bsky.social
The formatter uses a parser technology called tree-sitter as the backbone, which allows us to run queries on the syntax tree and easily apply formatting rules. The bulk of the runtime in the program is actually that these queries are compiled at runtime and cannot be cached.
gdquest.bsky.social
Still, there's room for making it 2 to 4 times faster down the line (some dependent on the libraries we use, some on us).
gdquest.bsky.social
It's because while it's fast, it's far from being as fast as a formatter could be - we're trading some speed for the ability to build and maintain a solid formatter for the community without it eating other work.