-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Add a GDScript code formatter in the script editor #1200
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This is a very good idea. |
@shinspiegel Adding a code formatter is not a simple undertaking, so I'd recommend discussing this with @vnen if you have C++ programming experience. Code formatters generally work by taking the script's abstract syntax tree (AST) and re-emitting it as text under a predetermined set of rules (spacing, line breaks, etc). |
@Calinou, I've almost no experience with C++, but I'm willing to learn to improve the project. |
If you are looking at issues that are easy to fix for new C++ programmers, I would recommend looking at issues labeled Writing a code formatter in a high-level programming language like Python is hard enough as it is, and it'll be even harder in C++. Not to mention you'd also need to integrate it within the Godot editor, and that requires deep understanding of how the editor works. |
If this gets implemented it may be worthwhile to draw inspiration from black. It's magic semantic trailing comma feature is a super powerful feature, and in general its style defaults produce very readable code, and would be sensible for GDScript as well. |
We're working on this! My teammate @Razoric480 started coding the formatter for Godot 4. The goal is to follow the official GDScript style guide and offer minimal options to customize the output (maybe line length and perhaps 1 vs 2 lines between functions, as Godot users have entire codebases using one or the other). |
After talking with the developers, we're gonna make a new proposal that explains the implementation details we're going for to make it easy for the GDScript maintainers to review and suggest a different approach. |
Superseded by #3630 which proposes a specific implementation. |
Describe the project you are working on:
N/A.
Describe the problem or limitation you are having in your project:
Maintaining a uniform code style between files is time-consuming, and when working with multiple people, it becomes nearly impossible.
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Original Issue
I'm just ressurrecting that issue because I have been watching it and didn't find any tracker for it anymore.
The desired functionality is to automatically reformat code in GDscript editor to some standard code style (like the one in the docs, for instance). Be it everytime the user saves the script or via a specific command, or maybe even both.
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
A toggle in the editor menu would activate and deactivate this feature. You could configure it to reformat the file every time you save or you could configure a command that reformats the file to a hotkey.
This would greatly help with cleaning trailing whitespaces, enforcing line column limits, and generally keeping your code clean and uniform between developers.
If this enhancement will not be used often, can it be worked around with a few lines of script?:
It should be used fairly often by any coders with some experience. There is a third-party solution, however: Godot GDScript toolkit.
Is there a reason why this should be core and not an add-on in the asset library?:
GDScript is under constant changes and improvements. This kind of tool would work best if updated accordingly to the latest updates. Thus, being part of the core would be desirable.
The text was updated successfully, but these errors were encountered: