From f7670ca7d213767a7acd4ddec0e1b17235d1ee9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Mon, 20 Nov 2023 23:09:29 +0200 Subject: [PATCH] Add support for `dprint` --- CHANGELOG.md | 1 + apheleia-formatters.el | 4 ++++ test/formatters/installers/dprint.bash | 11 +++++++++++ test/formatters/samplecode/dprint/in.toml | 1 + test/formatters/samplecode/dprint/out.toml | 1 + 5 files changed, 18 insertions(+) create mode 100644 test/formatters/installers/dprint.bash create mode 100644 test/formatters/samplecode/dprint/in.toml create mode 100644 test/formatters/samplecode/dprint/out.toml diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d10a8b0..fd16f500 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ The format is based on [Keep a Changelog]. ### Formatters +* [dprint](https://dprint.dev) for various (depends on installed plugins). * [purs-tidy](https://github.com/natefaubion/purescript-tidy) for PureScript ([#182]). * [`jq`](https://stedolan.github.io/jq/) for [JSON](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON) diff --git a/apheleia-formatters.el b/apheleia-formatters.el index 66b0e0c6..a26f98e1 100644 --- a/apheleia-formatters.el +++ b/apheleia-formatters.el @@ -44,6 +44,7 @@ (cmake-format . ("cmake-format" "-")) (crystal-tool-format . ("crystal" "tool" "format" "-")) (dart-format . ("dart" "format")) + (dprint . ("dprint" "fmt" "--stdin" (file-name-nondirectory filepath))) (elm-format . ("elm-format" "--yes" "--stdin")) (fish-indent . ("fish_indent")) (fourmolu . ("fourmolu")) @@ -239,11 +240,13 @@ rather than using this system." (cmake-mode . cmake-format) (cmake-ts-mode . cmake-format) (common-lisp-mode . lisp-indent) + (conf-toml-mode . dprint) (crystal-mode . crystal-tool-format) (css-mode . prettier-css) (css-ts-mode . prettier-css) (dart-mode . dart-format) (dart-ts-mode . dart-format) + (dockerfile-mode . dprint) (elixir-mode . mix-format) (elixir-ts-mode . mix-format) (elm-mode . elm-format) @@ -269,6 +272,7 @@ rather than using this system." (LaTeX-mode . latexindent) (lua-mode . stylua) (lisp-mode . lisp-indent) + (markdown-mode . dprint) (nasm-mode . asmfmt) (nix-mode . nixfmt) (perl-mode . perltidy) diff --git a/test/formatters/installers/dprint.bash b/test/formatters/installers/dprint.bash new file mode 100644 index 00000000..b829174a --- /dev/null +++ b/test/formatters/installers/dprint.bash @@ -0,0 +1,11 @@ +npm install -g dprint +cat <<\EOF >/tmp/dprint.json +{ + "toml": {}, + "excludes": [], + "plugins": [ + "https://plugins.dprint.dev/toml-0.5.4.wasm" + ] +} +EOF +dprint config update diff --git a/test/formatters/samplecode/dprint/in.toml b/test/formatters/samplecode/dprint/in.toml new file mode 100644 index 00000000..1f05503d --- /dev/null +++ b/test/formatters/samplecode/dprint/in.toml @@ -0,0 +1 @@ +title = "Apheleia dprint TOML test" diff --git a/test/formatters/samplecode/dprint/out.toml b/test/formatters/samplecode/dprint/out.toml new file mode 100644 index 00000000..091bd6ba --- /dev/null +++ b/test/formatters/samplecode/dprint/out.toml @@ -0,0 +1 @@ +title = "Apheleia dprint TOML test"