版本发布 7
### Enhancements * Black will respect configuration in `pyproject.toml` when run via Apheleia. ### Bugs fixed * A formatter that moves a line to the top of the file would sometimes place it as the second line instead ([#299]). * Fix invoking the diff command on Windows by always passing the --text flag. ### Formatters * Format Bazel files according to their type [#299]: https://github.com/radian-software/apheleia/issues/299
### Bugs fixed * `$PATH` was not correctly respected for some remote executables ([#341]). ### Formatters * [cljstyle](https://github.com/greglook/cljstyle) for clojure, clojurescript, edn files. * `biome` ([#339]). * `gdformat` for [gdscript](https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html) ([#342]). * `prettier-json-stringify` ([#183]). * `nix-ts-mode` buffers are now formatted with nixfmt like `nix-mode` buffers are. * Fix `foumolu` arguements * Both `haskell-mode` and the newly added `haskell-ts-mode` buffers are formatted with `fourmolu` ### Internal * You can run the formatter tests locally with podman instead of docker now, if you want. Export `USE_PODMAN=1` ([#343]). [#183]: https://github.com/radian-software/apheleia/pull/183 [#339]: https://github.com/radian-software/apheleia/pull/339 [#341]: https://github.com/radian-software/apheleia/pull/341 [#342]: https://github.com/radian-software/apheleia/pull/342 [#343]: https://github.com/radian-software/apheleia/pull/343
### Features * New user option `apheleia-skip-functions`, like `apheleia-inhibit-functions` but for skipping a formatter run even when `apheleia-mode` is generally enabled ([#317]). * [`ocp-indent`](https://github.com/OCamlPro/ocp-indent) for [Ocaml](https://ocaml.org/) ([#306]). ### Formatters * `vfmt` for [vlang](https://vlang.io/) ([#324]). * [`typstyle`](https://github.com/Enter-tainer/typstyle) for [typst](https://typst.app/) ([#313]). * [`rubocop`](https://github.com/rubocop/rubocop) changed to use `-a` instead of deprecated `--auto-correct` ([#316]). * `snakefmt` official formatter for [Snakemake](https://snakemake.readthedocs.io) ([#307]). * [`gleam`](https://github.com/gleam-lang/gleam) official formatter for [`gleam`](https://github.com/gleam-lang/gleam) ([#325]) * `zig fmt` official formatter for [zig](https://ziglang.org/) ([#327]). ### Bugs fixed * `apheleia-npx` would use an incorrect path for the Yarn PnP ESM loader ([#301]). * `apheleia-npx` did not correctly guard against word splitting and would fail when directory names contained spaces ([#301]). * `apheleia-npx` was sometimes not able to find formatters in a Yarn PnP project if there was also a `node_modules` folder at the root of the project ([#301]). * Ormolu is now passed the `--stdin-input-file` argument, which has become required ([#312]). * `mix format` is now passed the `--stdin-filename` argument which is required in some cases. The version of Mix is autodetected and this option is only passed when it is supported ([#319]). * `mix format` is now run with `MIX_QUIET` to supress compilation output ([#326]) * Beancount files are formatted without an error ([#309]). ## Internal * Improvements to formatter test framework, it is now possible to write tests that have additional data files ([#301]). [#301]: https://github.com/radian-software/apheleia/pull/301 [#306]: https://github.com/radian-software/apheleia/pull/306 [#307]: https://github.com/radian-software/apheleia/pull/307 [#309]: https://github.com/radian-software/apheleia/issues/309 [#312]: https://github.com/radian-software/apheleia/issues/312 [#313]: https://github.com/radian-software/apheleia/pull/313 [#316]: https://github.com/radian-software/apheleia/pull/316 [#317]: https://github.com/radian-software/apheleia/issues/317 [#319]: https://github.com/radian-software/apheleia/pull/319 [#324]: https://github.com/radian-software/apheleia/pull/324 [#325]: https://github.com/radian-software/apheleia/pull/325 [#326]: https://github.com/radian-software/apheleia/pull/326 [#327]: https://github.com/radian-software/apheleia/pull/327
### Changes * Custom Emacs Lisp formatting functions have the option to report an error asynchronously by invoking their callback with an error as argument. Passing nil as argument indicates that there was no error, as before. The old calling convention is still supported for backwards compatibility, and errors can also be reported by throwing, as normal. Implemented in [#204]. ### Features * New user option `apheleia-mode-predicates`. The default value handles `mhtml-mode` correctly by always using whatever formatter you have configured for that mode, rather than using `css-mode`, `html-mode`, etc formatters depending on the position of point ([#302]). ### Enhancements * There is a new keyword argument to `apheleia-format-buffer` which is a more powerful callback that is guaranteed to be called except in cases of synchronous nonlocal exit. See the docstring for details. The old callback, which is only invoked on success and receives no information about errors, is still supported and will continue to be called if provided. See [#204]. ### Formatters ### Bugs fixed * The point alignment algorithm, which has been slightly wrong since 2019, has been fixed to more correctly use dynamic programming to maintain the position of point. Also, some cases of a nil pointer error during point alignment have been fixed ([#290]). * `apheleia-indent-lisp-buffer` updated to apply local variables after calling major-mode. Also includes setting for `indent-tabs-mode` ([#286]). * [Formatter scripts](scripts/formatters) will now work on Windows if Emacs can find the executable defined in the shebang. ### Internal * Major internal refactoring has occurred to make it possible to write integration tests against Apheleia. This should improve future stability but could have introduced some bugs in the initial version. See [#204]. * Some debugging log messages have changed, see [#204]. [#204]: https://github.com/radian-software/apheleia/pull/204 [#286]: https://github.com/radian-software/apheleia/pull/286 [#285]: https://github.com/radian-software/apheleia/issues/285 [#290]: https://github.com/radian-software/apheleia/pull/290 [#302]: https://github.com/radian-software/apheleia/issues/302
### Enhancements * Use `perltidy` as default formatter for `cperl-mode` ([#260]). * The `perltidy` formatter now supports Emacs indentation and line length settings ([#261]). * Indent level is now determined for `graphql-mode`, `html-mode`, `ruby-mode`, `ruby-ts-mode`, `svelte-mode`, and `yaml-mode` ([#258]). * Indent level support when using yq to format JSON, XML, and YAML ([#259]). ### Formatters * [`dprint`](https://dprint.dev) for various (depending on [installed plugins](https://dprint.dev/plugins/)) ([#209]). * [`js-beautify`](https://github.com/beautify-web/js-beautify) for [JavaScript](https://www.javascript.com/), [JSON](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON), [HTML](https://en.wikipedia.org/wiki/HTML) and [CSS](https://www.google.com/search?q=css) ([#229]) * [`python3-json`](https://docs.python.org/3/library/json.html#module-json.tool) for JSON ([#257]). * [`robotidy`](https://robotidy.readthedocs.io) for Robot Framework files ([#263]). * [`ruff-isort`](https://github.com/astral-sh/ruff) for [Python](https://python.org) imports using ruff ([#279]). * [denofmt](https://docs.deno.com/runtime/manual/tools/formatter) for js, jsx, ts, tsx, json, jsonc, md files. ([#264]) * [docformatter](https://github.com/PyCQA/docformatter) for Python docstrings ([#267]) * [cljfmt](https://github.com/weavejester/cljfmt) for clojure, clojurescript, edn files. ([#271]) * Stylua is used now in `lua-ts-mode` as well as just `lua-mode`, by default ([#275]). * [`treefmt`](https://numtide.github.io/treefmt) for project configured formatters ([#280]). * [`pyang`](https://github.com/mbj4668/pyang) for [YANG](https://www.rfc-editor.org/rfc/rfc7950.html) ([#282]). ### Bugs fixed * Apheleia sometimes failed to determine indent level from Emacs settings even when configured to do so. This is fixed ([#274]). [#209]: https://github.com/radian-software/apheleia/pull/209 [#229]: https://github.com/radian-software/apheleia/pull/229 [#257]: https://github.com/radian-software/apheleia/pull/257 [#258]: https://github.com/radian-software/apheleia/pull/258 [#259]: https://github.com/radian-software/apheleia/pull/259 [#260]: https://github.com/radian-software/apheleia/pull/260 [#261]: https://github.com/radian-software/apheleia/pull/261 [#263]: https://github.com/radian-software/apheleia/pull/263 [#264]: https://github.com/radian-software/apheleia/pull/264 [#267]: https://github.com/radian-software/apheleia/pull/267 [#271]: https://github.com/radian-software/apheleia/pull/271 [#274]: https://github.com/radian-software/apheleia/issues/274 [#275]: https://github.com/radian-software/apheleia/pull/275 [#279]: https://github.com/radian-software/apheleia/pull/279 [#282]: https://github.com/radian-software/apheleia/pull/282
### Breaking changes * The order of entries in `apheleia-mode-alist` is no longer as important. Specifically, if two different mode entries in `apheleia-mode-alist` match the current buffer, then the more specific one is used, even if it comes later. This is generally speaking what you would expect to happen. For other cases, such as ordering of regex entries, or modes versus regexes, order is respected as before ([#206]). * Disable formatting of go module files with gofmt. This was never supported ([#214]). * Remove support for Emacs 26 ([#215]). * Emacs will infer indentation configuration from your major mode and, by default, supply this configuration to formatters, to ensure consistency between how you have Emacs configured and how your formatter is configured. You can disable this by setting `apheleia-formatters-respect-indent-level` to nil ([#167], [#208]). ### Enhancements * Use the `prettier-json` formatter for `js-json-mode` ([#209]). * Prettier is now enabled in `svelte-mode`. * More tree-sitter based major modes have been added to `apheleia-mode-alist` ([#191]). * All marks (the current `(mark)`, and the `mark-ring`) are now adjusted, alongside `(point)` ([#197]). * Built-in formatters now use a new `"apheleia-npx"` built-in script instead of the legacy `npx` keyword. The effect of the new script is the same, except that it also works with Yarn PNP projects as well as `node_modules` style projects ([#200]). * Autoload the apheleia-goto-error command ([#215]). * Use `lisp-indent` as default formatter for `emacs-lisp-mode` ([#223]) * Use `hclfmt` for formatting hashicorp HCL files ([#231]) * The `mix format` formatter will respect `.formatter.exs` files even if they are present in a parent directory rather than the same directory as the file being formatted ([#232]). ### Internal Changes * Refactored the organisation of the apheleia package for ease of understanding and usability ([#215]). * The new `scripts/pnp-bin.js` script is standalone minified nodejs built from the [`pnp-bin`](https://github.com/PuddleByteComputing/pnp-bin) repo, extracted from apheleia PR [#200]. * Test environment bumped from Ubuntu 20.04 to 22.04 ([#242]). * The function `apheleia--format-after-save` was renamed to `apheleia-format-after-save`. This is only called out explicitly because it was added to `after-save-hook` so customization that assumed this behavior might break. ### Bugs fixed * `ktlint` would emit log messages into its stdout when formatting, and these would get spliced into the source file. This has been fixed by suppressing all logs from `ktlint`. * Disable colorized output with the jq formatter ([#213]). * Fixed apheleia skipped running a formatter on a remote when it isn't installed locally ([#215]). * Fixed clang-format formatter did not respect remote file-name component for the assumed file-name ([#215]). * Always supply `--stdin-filepath` to Prettier to allow it to pick up the correct settings from project-level config files ([#253]). ### Formatters * [`asmfmt`](https://github.com/klauspost/asmfmt) for assembly ([#168]). * [`astyle`](https://github.com/steinwurf/astyle) for C ([#169]). * [`beautysh`](https://github.com/lovesegfault/beautysh) for shell scripts ([#170]) * [`buildifier`](https://github.com/bazelbuild/buildtools) for [Bazel Build](https://bazel.build/) ([#171]). * [`cmake-format`](https://github.com/cheshirekow/cmake_format) for [CMake](https://cmake.org/) ([#172]). * [`fourmolu`](https://github.com/fourmolu/fourmolu) for haskell * [`gawk`](https://www.gnu.org/software/gawk/) for [awk](https://en.wikipedia.org/wiki/AWK) ([#187]). * [`hclfmt`](https://github.com/hashicorp/hcl/tree/main/cmd/hclfmt) for [HCL](https://github.com/hashicorp/hcl) ([#231]) * [`html-tidy`](https://www.html-tidy.org/) for HTML/XML ([#173]). * [`jq`](https://stedolan.github.io/jq/) for [JSON](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON) ([#174]). * [`ormolu`](https://github.com/tweag/ormolu) for haskell. * [`perltidy`](https://perltidy.sourceforge.net/) for [perl](https://www.perl.org/) ([#175]). * [`pgformatter`](https://github.com/darold/pgFormatter) for [SQL](https://en.wikipedia.org/wiki/SQL) ([#247]) * [purs-tidy](https://github.com/natefaubion/purescript-tidy) for PureScript ([#182]). * [`rubocop`](https://github.com/rubocop/rubocop) for [ruby](https://www.ruby-lang.org/en/) ([#176]). * [`ruby-standard`](https://github.com/standardrb/standard) for [ruby](https://www.ruby-lang.org/en/) ([#201]) * [`ruff`](https://github.com/astral-sh/ruff) for [python](https://python.org) ([#236]) * [`rufo`](https://github.com/ruby-formatter/rufo) for [Ruby](https://www.ruby-lang.org/en/) ([#177]). * [`xmllint`](https://gitlab.gnome.org/GNOME/libxml2) for XML ([#251]). * [`yapf`](https://github.com/google/yapf) for [Python](https://www.python.org/) ([#196]) * [`yq`](https://mikefarah.gitbook.io/yq/) for YAML, JSON, CSV, TSV, XML and [.properties](https://en.wikipedia.org/wiki/.properties) ([#250]). [#167]: https://github.com/radian-software/apheleia/pull/167 [#168]: https://github.com/radian-software/apheleia/pull/168 [#169]: https://github.com/radian-software/apheleia/pull/169 [#170]: https://github.com/radian-software/apheleia/pull/170 [#171]: https://github.com/radian-software/apheleia/pull/171 [#172]: https://github.com/radian-software/apheleia/pull/172 [#173]: https://github.com/radian-software/apheleia/pull/173 [#174]: https://github.com/radian-software/apheleia/pull/174 [#175]: https://github.com/radian-software/apheleia/pull/175 [#176]: https://github.com/radian-software/apheleia/pull/176 [#177]: https://github.com/radian-software/apheleia/pull/177 [#182]: https://github.com/radian-software/apheleia/pull/182 [#187]: https://github.com/radian-software/apheleia/pull/187 [#196]: https://github.com/radian-software/apheleia/pull/196 [#197]: https://github.com/radian-software/apheleia/issues/197 [#208]: https://github.com/radian-software/apheleia/discussions/208 [#209]: https://github.com/radian-software/apheleia/pull/209 [#213]: https://github.com/radian-software/apheleia/pull/213 [#214]: https://github.com/radian-software/apheleia/pull/214 [#215]: https://github.com/radian-software/apheleia/pull/215 [#223]: https://github.com/radian-software/apheleia/pull/223 [#231]: https://github.com/radian-software/apheleia/pull/231 [#232]: https://github.com/radian-software/apheleia/issues/232 [#236]: https://github.com/radian-software/apheleia/pull/236 [#242]: https://github.com/radian-software/apheleia/pull/242 [#253]: https://github.com/radian-software/apheleia/pull/253 [#247]: https://github.com/radian-software/apheleia/pull/247
### Features * You can use `apheleia-inhibit` as a file-local variable to disable Apheleia turning on automatically for a file or directory. You can also use `apheleia-inhibit-functions` to configure custom logic to prevent Apheleia from turning on automatically under certain circumstances, without needing to adjust file-local variables. See [#134] and [#138]. * `apheleia-mode` lighter is now customizable ([#143]). ### Changes * shfmt is no longer enabled by default in order to prevent corruption of zsh scripts. Re-enabling shfmt in a future release is intended, but depends on further implementation work in Apheleia to only enable it for supported shells. ### Enhancements * Emacs 29's tree-sitter-based major modes have been added to `apheleia-mode-alist` ([#145], [#148], [#151], [#155]). ### Bugs fixed * If a formatter exited with a zero exit code when being killed by a signal (even though that is really weird behavior and arguably a bug in the formatter), then if a file was saved multiple times in quick succession, its contents could be erased and replaced with an error message from the formatter. This has been fixed. See [#131] for more details. * Npx commands in apheleia-formatters are not overwritten when expanding binary path to node_modules directory ([#152]). * Error is no longer reported when the first element of a command is an evaluable form rather than a literal string ([#156]). ### Formatters * [`crystal tool format`](https://crystal-lang.org/reference/1.6/man/crystal/index.html#crystal-tool-format) for [Crystal](https://crystal-lang.org/) ([#137]). * [gofumpt](https://pkg.go.dev/mvdan.cc/gofumpt) and [goimports](https://pkg.go.dev/golang.org/x/tools/cmd/goimports) for [Go](https://golang.google.cn/) ([#147]). * [`caddy fmt`](https://caddyserver.com/docs/command-line#caddy-fmt) for [Caddyfile](https://caddyserver.com/docs/caddyfile), used by [Caddy 2](https://caddyserver.com/) ([#136]) [#131]: https://github.com/radian-software/apheleia/issues/131 [#134]: https://github.com/radian-software/apheleia/issues/134 [#136]: https://github.com/radian-software/apheleia/issues/136 [#137]: https://github.com/radian-software/apheleia/pull/137 [#138]: https://github.com/radian-software/apheleia/pull/138 [#143]: https://github.com/radian-software/apheleia/pull/143 [#145]: https://github.com/radian-software/apheleia/pull/145 [#147]: https://github.com/radian-software/apheleia/pull/147 [#148]: https://github.com/radian-software/apheleia/pull/148 [#152]: https://github.com/radian-software/apheleia/pull/152