IssueRaiser

Implement a code formatter for GDScript in the script editor

### Describe the project you are working on I've been sponsored by GDQuest to make improvements to the godot engine. ### Describe the problem or limitation you are having in your project See original proposal: This supersedes #1200. Maintaining a uniform code style between files is time-consuming, and when working with multiple people, it becomes nearly impossible. There is one third party option, https://github.com/Scony/godot-gdscript-toolkit by Scony, but it has to create a syntax tree before every parse - which takes time at boot-up, cannot be run from within Godot, and runs on Python and has to manually text-parse scripts. If Godot offered the ability to format code, it could be done in-editor and fast (using the built-in parser with C++), and could be out-sourced to the Language Server with the [DocumentFormatting request](https://microsoft.github.io/language-server-protocol/specification#textDocument_formatting) for outside editors. ### Describe the feature / enhancement and how it helps to overcome the problem or limitation The new GDScript parser for GDScript 2 does (almost) everything we need it to in order to make a formatter, except for comments and blank lines. Fulfilling this proposal involves: - A new virtual public function to ScriptLanguage, `format_code(String &p_code)`, in the same vein as `auto_indent_code()` and a new entry in the Edit menu, "Format Code", that calls it. This allows the possibility of maturing Godot's C# editing and any other lang

Posted by Razoric480 on Dec 3, 2021, 3:54 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,000 issues0 comments

github (E-commerce)

Implement a code formatter for GDScript in the script editor

Razoric480Dec 3, 2021, 3:54 PM

### Describe the project you are working on I've been sponsored by GDQuest to make improvements to the godot engine. ### Describe the problem or limitation you are having in your project See original proposal: This supersedes #1200. Maintaining a uniform code style between files is time-consuming, and when working with multiple people, it becomes nearly impossible. There is one third party option, https://github.com/Scony/godot-gdscript-toolkit by Scony, but it has to create a syntax tree before every parse - which takes time at boot-up, cannot be run from within Godot, and runs on Python and has to manually text-parse scripts. If Godot offered the ability to format code, it could be done in-editor and fast (using the built-in parser with C++), and could be out-sourced to the Language Server with the [DocumentFormatting request](https://microsoft.github.io/language-server-protocol/specification#textDocument_formatting) for outside editors. ### Describe the feature / enhancement and how it helps to overcome the problem or limitation The new GDScript parser for GDScript 2 does (almost) everything we need it to in order to make a formatter, except for comments and blank lines. Fulfilling this proposal involves: - A new virtual public function to ScriptLanguage, `format_code(String &p_code)`, in the same vein as `auto_indent_code()` and a new entry in the Edit menu, "Format Code", that calls it. This allows the possibility of maturing Godot's C# editing and any other lang

Comments (0)

No comments yet. Start the discussion.

Comment on this issue