Skip to content
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 ability to "format code" option for File System "On Save" actions #9952

Open
ewrogers opened this issue Jun 12, 2024 · 1 comment
Open

Comments

@ewrogers
Copy link

ewrogers commented Jun 12, 2024

Describe the project you are working on

Any Godot 3.x or 4.x project would benefit from this.

Describe the problem or limitation you are having in your project

We are currently using gdformat and gdlint via Git pre-commit and CI/CD actions respectively but it requires additional steps and is not always something develops want to set up.

It would be nice to have this feature that most modern IDE (VS Code / JetBrains) have where the code can be automatically formatted on save.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add settings either at the Editor or per-project level that would allow automatic reformatting of GDScript files on save, using gdformat (or another user-defined tool).

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

This section of the Editor Settings has FileSystem->OnSave options. Logically, it would belong here for external format tools like gdformat (assuming it is installed).

Screenshot 2024-06-12 at 4 33 56 PM

Alternatively, the Text Editor could have a new On Save section if it should be more obvious.

It would be a combination of two additional settings:

  • Automatically format script files (default = off)
  • External formatter tool (default: gdformat)

When enabled, a command would be issued (ex: gdformat just_saved_script.gd) and the script file would be automatically reloaded in the editor. It should be transparent to the user and not prompt "file changed, reload?" confirmation modals.

If this enhancement will not be used often, can it be worked around with a few lines of script?

It can be worked around with various Git actions but that also hinges on Git being the VCS of choice (however popular it may be).

Is there a reason why this should be core and not an add-on in the asset library?

Most IDEs offer things like this so it seems logical that Godot could to make it feel more cohesive as an "all-in-one" environment.

@Calinou
Copy link
Member

Calinou commented Jun 12, 2024

I don't think we should add bespoke integrations for third-party tools in the script editor. If this is to be implemented, this should be done in a generic way so that a specific Godot version isn't bound to specific tools only. Remember that third-party tools evolve over time (and so do their command line interfaces).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants