Skip to content

Commit

Permalink
feat: add gdformat formatter for godot/gdscript (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpza and raxod502 authored Jan 19, 2025
1 parent e3db0e7 commit 37f0a04
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions apheleia-formatters.el
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions test/formatters/installers/gdformat.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
apt-get install -y python3-pip
pip3 install "gdtoolkit==4.*"
9 changes: 9 additions & 0 deletions test/formatters/samplecode/gdformat/in.gd
Original file line number Diff line number Diff line change
@@ -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')
15 changes: 15 additions & 0 deletions test/formatters/samplecode/gdformat/out.gd
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 37f0a04

Please sign in to comment.