diff options
| author | Jimmy Yuen Ho Wong <wyuenho@users.noreply.github.com> | 2025-07-24 18:14:43 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-24 10:14:43 -0700 |
| commit | 7dd0c477231165535beba267ff734b6918385cb6 (patch) | |
| tree | 0b3bdcbb162442c3016949173f1a491357298ba6 | |
| parent | 20498e941b61231370d31b0fac64cd723089ce78 (diff) | |
Add taplo for formatting TOML files (#373)
Taplo is a very popular formatter and linter for TOML.
https://github.com/tamasfe/taplo
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | apheleia-formatters.el | 2 | ||||
| -rw-r--r-- | test/formatters/installers/taplo.bash | 1 | ||||
| -rw-r--r-- | test/formatters/samplecode/taplo/in.toml | 33 | ||||
| -rw-r--r-- | test/formatters/samplecode/taplo/out.toml | 30 |
5 files changed, 67 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 26d0944..36b50f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog]. ### Formatters * [hurlfmt](https://hurl.dev) for hurl files. * [csharpier](https://github.com/belav/csharpier) for C#. +* [taplo](https://taplo.tamasfe.dev/) for TOML. ## 4.4.1 (released 2025-05-13) ### Enhancements diff --git a/apheleia-formatters.el b/apheleia-formatters.el index 8536c2c..581a9a1 100644 --- a/apheleia-formatters.el +++ b/apheleia-formatters.el @@ -214,6 +214,7 @@ (rufo . ("rufo" "--filename" filepath "--simple-exit")) (stylua . ("stylua" "-")) (rustfmt . ("rustfmt" "--quiet" "--emit" "stdout")) + (taplo . ("taplo" "format" "--colors" "never" "-")) (terraform . ("terraform" "fmt" "-")) (treefmt . ("treefmt" "--stdin" filepath)) (typstyle . ("typstyle")) @@ -394,6 +395,7 @@ rather than using this system." (terraform-mode . terraform) (TeX-latex-mode . latexindent) (TeX-mode . latexindent) + (toml-ts-mode . taplo) (tsx-ts-mode . prettier-typescript) (tuareg-mode . ocamlformat) (typescript-mode . prettier-typescript) diff --git a/test/formatters/installers/taplo.bash b/test/formatters/installers/taplo.bash new file mode 100644 index 0000000..a7dc7f6 --- /dev/null +++ b/test/formatters/installers/taplo.bash @@ -0,0 +1 @@ +npm install -g @taplo/cli diff --git a/test/formatters/samplecode/taplo/in.toml b/test/formatters/samplecode/taplo/in.toml new file mode 100644 index 0000000..175515a --- /dev/null +++ b/test/formatters/samplecode/taplo/in.toml @@ -0,0 +1,33 @@ +# This is a TOML document. + +title = "TOML Example" + +[owner] +name = "Tom Preston-Werner" +dob = 1979-05-27T07:32:00-08:00 # First class dates + +[database] +server = "192.168.1.1" +ports = [ 8000, 8001, 8002 ] +connection_max = 5000 +enabled = true + +[servers] + + # Indentation (tabs and/or spaces) is allowed but not required + [servers.alpha] + ip = "10.0.0.1" + dc = "eqdc10" + + [servers.beta] + ip = "10.0.0.2" + dc = "eqdc10" + +[clients] +data = [ ["gamma", "delta"], [1, 2] ] + +# Line breaks are OK when inside arrays +hosts = [ + "alpha", + "omega" +] diff --git a/test/formatters/samplecode/taplo/out.toml b/test/formatters/samplecode/taplo/out.toml new file mode 100644 index 0000000..77669bd --- /dev/null +++ b/test/formatters/samplecode/taplo/out.toml @@ -0,0 +1,30 @@ +# This is a TOML document. + +title = "TOML Example" + +[owner] +name = "Tom Preston-Werner" +dob = 1979-05-27T07:32:00-08:00 # First class dates + +[database] +server = "192.168.1.1" +ports = [8000, 8001, 8002] +connection_max = 5000 +enabled = true + +[servers] + +# Indentation (tabs and/or spaces) is allowed but not required +[servers.alpha] +ip = "10.0.0.1" +dc = "eqdc10" + +[servers.beta] +ip = "10.0.0.2" +dc = "eqdc10" + +[clients] +data = [["gamma", "delta"], [1, 2]] + +# Line breaks are OK when inside arrays +hosts = ["alpha", "omega"] |
