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")