You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-13Lines changed: 36 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ The goal of this project is to provide a simple and fast GDScript code formatter
8
8
9
9
## Status
10
10
11
-
**Ready for testing** - 08/19/2024 - The formatter now has many formatting rules implemented and is ready to test. It includes:
11
+
Ready for daily use for commonly written code - 09/04/2025 - The formatter now has many formatting rules implemented and is ready to test. It includes:
12
12
13
13
-**Spaces**: leaving one space consistently between many operators, most keywords, or after commas in function calls, arrays, and dictionaries
14
14
-**Multi-line structures**: simple arrays and dictionaries can be wrapped on one or multiple lines with indentation
@@ -17,19 +17,42 @@ The goal of this project is to provide a simple and fast GDScript code formatter
17
17
18
18
And more!
19
19
20
-
*In this system, every rule needs to be written explicitly, including putting a space between different keywords, operators, and punctuation. The formatter doesn't automatically add spaces or indentation unless it's explicitly defined in the rules.*
20
+
**Please report any issues you find with code snippets!** GDScript has grown into a complex language with many different syntax patterns. While the formatter covers many common cases, there can always be edge cases or less common syntax that may not be handled correctly yet. You can find known issues in the [GitHub issues section](issues).
21
21
22
-
*So we need you to share any code snippets for things that don't work yet. Also, note that GDScript features in beta/development versions of Godot may not be supported.*
22
+
### Formatting on single or multiple lines
23
23
24
-
**Next steps**:
24
+
The formatter's technology doesn't handle maximum line length automatically. Instead, for wrapping code on a single or multiple lines, it uses cues from you, the developer. For example, if you write an array on a single line, it will remain on a single line. This input:
25
25
26
-
- Gathering feedback from testing and improving the formatter based on real-world needs
26
+
```gdscript
27
+
var numbers: Array[int] = [1,2,3,4,5]
28
+
```
29
+
30
+
Will be formatted like this:
31
+
32
+
```gdscript
33
+
var numbers: Array[int] = [1, 2, 3, 4, 5]
34
+
```
27
35
28
-
**Technology limitations**:
36
+
If you insert a line return, the array will wrap on multiple lines instead. This input:
29
37
30
-
Topiary doesn't handle maximum line length. Instead, for wrapping code on a single or multiple lines, it uses cues from you: if an array is on a single line, it will remain on a single line, and if it is at least on two lines, Topiary will wrap it on multiple lines.
38
+
```gdscript
39
+
var dialogue_items: Array[String] = ["I'm learning about Arrays...",
40
+
"...and it is a little bit complicated.", "Let's see if I got it right: an array is a list of values!", "Did I get it right? Did I?", "Hehe! Bye bye~!"]
41
+
```
42
+
43
+
Will be formatted like this:
44
+
45
+
```gdscript
46
+
var dialogue_items: Array[String] = [
47
+
"I'm learning about Arrays...",
48
+
"...and it is a little bit complicated.",
49
+
"Let's see if I got it right: an array is a list of values!",
50
+
"Did I get it right? Did I?",
51
+
"Hehe! Bye bye~!"
52
+
]
53
+
```
31
54
32
-
It's always possible to implement a maximum line length as a post-processing step by using Topiary as a library and then running a custom function to wrap lines that are too long. This isn't planned yet, but it is technically possible.
55
+
You can insert the line returns anywhere in the array, and the formatter will keep it on multiple lines. The same applies to other structures.
33
56
34
57
## Contributing
35
58
@@ -57,11 +80,11 @@ To add new formatting rules to the GDScript formatter, you can follow these step
57
80
58
81
Here are the most important directories and files in the project:
59
82
60
-
-`src/`: Contains the Rust code to compile and run the formatter using the CLI. It's currently a simple wrapper around the Topiary command line program, but later it could use Topiary as a library instead to pack everything into a simple binary
61
-
-`tests/`: Contains test files for the formatter. It has input files with unformatted GDScript code and expected output files that the formatter should produce when run on the input files
62
-
-`queries/`: Contains the Topiary formatting rules for GDScript. The `gdscript.scm` file is where you define how GDScript code should be formatted based on Tree Sitter queries and Topiary features to mark nodes/patterns for formatting
63
-
-`config/`: Contains configuration files for Topiary - basically a small file that tells Topiary how to run the formatter for GDScript
64
-
-`docs/`: This folder will compile images and recaps or cheat sheets with some tricks to help when working with tree sitter queries and topiary.
83
+
-`src/`: Contains the Rust code to compile and run the formatter using the CLI. It's currently a simple wrapper around the Topiary command line program, but later it could use Topiary as a library instead to pack everything into a simple binary.
84
+
-`tests/`: Contains test files for the formatter. It has input files with unformatted GDScript code and expected output files that the formatter should produce when run on the input files.
85
+
-`queries/`: Contains the Topiary formatting rules for GDScript. The `gdscript.scm` file is where you define how GDScript code should be formatted based on Tree Sitter queries and Topiary features to mark nodes/patterns for formatting.
86
+
-`config/`: Contains configuration files for Topiary - basically a small file that tells Topiary how to run the formatter for GDScript.
87
+
-`docs/`: This folder will compile images and recaps or cheat sheets with some tricks to help when working with Tree Sitter queries and Topiary.
0 commit comments