aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Perez Alvarez <danielpza@protonmail.com>2025-01-19 12:28:28 -0800
committerGitHub <noreply@github.com>2025-01-19 12:28:28 -0800
commit37f0a048bf91c7a145b33e98c984eb58132fb2f6 (patch)
tree487e711d7a33cf10256bea2ed932bfdd3818aa9b
parente3db0e795b7675062b9a65ed19077dfa6d913ea8 (diff)
feat: add gdformat formatter for godot/gdscript (#342)
Add [gdformat](https://github.com/Scony/godot-gdscript-toolkit?tab=readme-ov-file#formatting-with-gdformat-more) for godot gdscript files See - https://godotengine.org/ - https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html - https://github.com/Scony/godot-gdscript-toolkit --------- Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
-rw-r--r--CHANGELOG.md4
-rw-r--r--apheleia-formatters.el3
-rw-r--r--test/formatters/installers/gdformat.bash2
-rw-r--r--test/formatters/samplecode/gdformat/in.gd9
-rw-r--r--test/formatters/samplecode/gdformat/out.gd15
5 files changed, 32 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6158708..a1d4a5f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,10 +6,12 @@ The format is based on [Keep a Changelog].
## Unreleased
### Formatters
* `biome` ([#339]).
+* `gdformat` for [gdscript](https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html) ([#342]).
* `prettier-json-stringify` ([#183]).
-[#339]: https://github.com/radian-software/apheleia/pull/339
[#183]: https://github.com/radian-software/apheleia/pull/183
+[#339]: https://github.com/radian-software/apheleia/pull/339
+[#342]: https://github.com/radian-software/apheleia/pull/342
## 4.3 (released 2024-11-12)
### Features
diff --git a/apheleia-formatters.el b/apheleia-formatters.el
index 092b41e..7366262 100644
--- a/apheleia-formatters.el
+++ b/apheleia-formatters.el
@@ -64,6 +64,7 @@
(fish-indent . ("fish_indent"))
(fourmolu . ("fourmolu"))
(gawk . ("gawk" "-f" "-" "--pretty-print=-"))
+ (gdformat . ("gdformat" "-"))
(gleam . ("gleam" "format" "--stdin"))
(gofmt . ("gofmt"))
(gofumpt . ("gofumpt"))
@@ -328,6 +329,8 @@ rather than using this system."
(elm-mode . elm-format)
(emacs-lisp-mode . lisp-indent)
(fish-mode . fish-indent)
+ (gdscript-mode . gdformat)
+ (gdscript-ts-mode . gdformat)
(gleam-ts-mode . gleam)
(go-mode . gofmt)
(go-ts-mode . gofmt)
diff --git a/test/formatters/installers/gdformat.bash b/test/formatters/installers/gdformat.bash
new file mode 100644
index 0000000..4ecfae1
--- /dev/null
+++ b/test/formatters/installers/gdformat.bash
@@ -0,0 +1,2 @@
+apt-get install -y python3-pip
+pip3 install "gdtoolkit==4.*"
diff --git a/test/formatters/samplecode/gdformat/in.gd b/test/formatters/samplecode/gdformat/in.gd
new file mode 100644
index 0000000..9e30e3d
--- /dev/null
+++ b/test/formatters/samplecode/gdformat/in.gd
@@ -0,0 +1,9 @@
+class X:
+ var x=[1,2,{'a':1}]
+ var y=[1,2,3,] # trailing comma
+ func foo(a:int,b,c=[1,2,3]):
+ if a in c and \
+ b > 100:
+ print('foo')
+func bar():
+ print('bar')
diff --git a/test/formatters/samplecode/gdformat/out.gd b/test/formatters/samplecode/gdformat/out.gd
new file mode 100644
index 0000000..bede6f6
--- /dev/null
+++ b/test/formatters/samplecode/gdformat/out.gd
@@ -0,0 +1,15 @@
+class X:
+ var x = [1, 2, {"a": 1}]
+ var y = [
+ 1,
+ 2,
+ 3,
+ ] # trailing comma
+
+ func foo(a: int, b, c = [1, 2, 3]):
+ if a in c and b > 100:
+ print("foo")
+
+
+func bar():
+ print("bar")