mirror of
https://github.com/vale981/apheleia
synced 2025-03-05 09:31:40 -05:00

* [#33] Support remote buffers and files CLOSES #33 Adds support for formatting remote files. The new `apheleia-remote-algorithm` option configures this. The default behaviour is consistent with what we had before, with `apheleia` aborting a formatting when dealing with a remote file/buffer. Users can customise apheleia to run the formatter on the remote machine, in which case any temporary files or other checks such as `npx` will be fully handled on the remote machine. Users can also make apheleia run the formatter on the local machine. This works exactly like one would expect, except if the formatter requires access to the physical file (meaning it uses 'file in `apheleia-formatters`) because the file isn't available on the local machine. This PR also fixes a bug in apheleia where `input-fname` was assigned in local let scope, instead of being returned by `apheleia--format-command`, meaning any formatters using a 'input file weren't cleaned up after formatting. * Cleanup + run diffs on remote as well * Fix diff uses correct file path for remote files If a file being diffed is remote, but the program is being run locally, then we create a temporary file on the current machine. * Make a few style changes * Drop support for Emacs 25 * Fix GitHub Actions triggers * Don't run tests on Emacs 25 either * Make apheleia run synchronously when running on remote Also added a metadata field to function based formatters. * feat: Suppress meaningless messages while formatting synchronously Also fixed any linter complaints. * bug: Make running formatter locally on remote buffer synchronous More re-entrant tramp issues. * Update apheleia.el * review: Replace custom temp-file logic with make-nearby-temp-file * review: Revamp functional formatter interface * refactor: Rework remote file handling implementation + Reordered parameters to ensure remote always comes before callback. + Updated some docstrings. * bug: Re-add apheleia--make-temp-file We don't always want to create a temporary file on the remote, only when apheleia-remote-algorithm is 'remote. * bug: Prevent repeat diff-file invocation with 2 files Previously we always made a temp-file for diffing the formatted and unformatted buffer leading to a bug when trying to send stdin to the formatter process. Now we only perform this check when running both locally and remotely. * Update changelog Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
9.4 KiB
9.4 KiB
Changelog
All notable changes to this project will be documented in this file. The format is based on Keep a Changelog.
Unreleased
Breaking changes
- The arguments of formatters defined as Elisp functions has changed.
A formatter function should now be a
cl-defun
taking key-value arguments with support for more keys being provided on a later apheleia release (by including&allow-other-keys
in the parameter list). For a list of provided arguments seeapheleia--run-formatter-function
. - Emacs 25 is no longer supported.
Features
- Support remote files and buffers that were opened through TRAMP (#33).
2.0
Breaking changes
- The interface to
apheleia-format-buffer
has changed. You now pass in the symbol of a formatter fromapheleia-formatters
(or a list of them) rather than the actual command. This change improves the ability of Apheleia to report useful error messages and logging. - Stdout and stderr buffers are no longer retained after running a
formatter. Instead, the stderr is appended into an
*apheleia-cmdname-log*
buffer if it fails, or unconditionally if the new user optionapheleia-log-only-errors
is set to nil. See #64, #65. The log buffer is not hidden by default, unlike the old stdout and stderr buffers, but this can be changed with the new user optionapheleia-hide-log-buffers
. Also, the log shows all command output rather than just the latest run. You can add further customizations using the new hookapheleia-formatter-exited-hook
(#69).
Features
- Apheleia can now format buffers that do not have an underlying file (#52).
- You can now use a Lisp function as a formatter, by providing a
symbol or lambda in
apheleia-formatters
rather than a list of strings (#62). The function should be acl-defun
taking key-value arguments with support for more keys being provided on a later apheleia release (by including&allow-other-keys
in the parameter list). For a list of provided arguments seeapheleia--run-formatter-function
. - Formatters that operate on files in place are now supported, by
using the symbol
inplace
in an entry onapheleia-formatters
to stand in for the name of a temporary file that will be modified in place by the formatter (#23).
Enhancements
- The buffer-local variable
apheleia-formatter
is now marked as safe (#74). This allows you to configure the formatter that Apheleia will use in a file-local variable. Note: only formatters already declared inapheleia-formatters
can be used; this does not allow arbitrary shell commands to be specified in file-local variables.
Bugs fixed
- Allow running the same formatter in multiple buffers in parallel (#64, #65). Previously, when saving a number of files at the same time, the contents of those buffers could be corrupted by a race condition.
- In some circumstances the error
wrong-type-argument bufferp nil
could be reported when running certain formatters under Apheleia. This has been fixed. - Rustfmt is no longer passed the
--unstable-features
and--skip-children
flags, since they are not available on all versions of Rustfmt (#69). - When a formatter cannot be found, orphaned stderr processes are no longer created and left around forever (#47).
- Apheleia no longer resets the major mode to its default value when formatting a buffer. This was never intended and the bug has now been fixed (#58).
Formatters added
- fish_indent for Fish (#68).
Formatter bugs fixed
- isort is passed different arguments so as not to trigger a crash
that appears to be related to the
--stdout
flag. - latexindent now has its log file disabled so as to avoid cluttering the working directory.
- ocamlformat is now configured to work even outside of detected projects.
1.2 (released 2021-12-27)
Enhancements
- Support multiple formatters (#31). You can now configure a list of
formatters for a major-mode in
apheleia-mode-alist
and they will be run in sequence. - Support evaluating items in
apheleia-formatters
to make formatter commands more dynamic (#50, #55).
Formatters
- ClangFormat for C/C++
google-java-format
for Java- isort for Python (#51)
- latexindent for LaTeX
- rustfmt for Rust (#24)
mix format
for Elixir (#48)@prettier/plugin-ruby
for Ruby (#49)
Bugs fixed
- Fix spelling error in generated process names (#32).
- Apheleia no longer conflicts with undo-fu (#39).
- Apheleia no longer triggers
after-set-visited-file-name-hook
, which reduces conflicts with various modes. For example,lsp-mode
will no longer trigger a reconnect every time you save. - Fix inconsistent
:type
spec preventing use ofcustomize-variable
onapheleia-formatters
. - Fix mixed style line ending generated by
diff
(#54) by adding--strip-trailing-cr
todiff
's argument list.
1.1.2 (released 2021-02-26)
Enhancements
- Prettier is now enabled in
json-mode
.
Bugs fixed
- Prettier now respects
.prettierignore
(#21). - Apheleia's global mode should no longer trigger warnings about a locally
let-bound
after-save-hook
(#27).
1.1.1 (released 2020-07-16)
Formatters
- New: OCamlFormat for Ocaml (#19).
Bugs fixed
- Previously, there were some race conditions related to switching the current buffer. In particular, if you switched the current buffer right after saving, or save two buffers in quick succession, then it was possible for one buffer to be overwritten or to not be formatted. These problems have been fixed (#8).
- Previously, enabling
undo-tree-auto-save-history
caused Apheleia to mark the buffer as modified after formatting. This has been fixed (#10). - Apheleia now tries harder to accidentally enter an infinite formatting loop (#12).
1.1 (released 2020-04-02)
Enhancements
- There is now a maximum length for the dynamic programming algorithm,
controlled by
apheleia-max-alignment-size
. This prevents Emacs from hanging due to Apheleia. under any circumstances (#4).
Formatters
Bugs fixed
- Previously, weirdness could happen if manually running Prettier via
M-x apheleia-format-buffer
on a buffer which was modified from what was written to disk. Now we simply abort running a command that uses thefile
keyword if the buffer is modified, since it will not produce correct results. This should not affect normal usage of Apheleia. - Previously, the buffer could be erased when running Apheleia from a buffer that had no backing file. This has been fixed, and Apheleia can run correctly on buffers both with and without backing files (#9).
1.0 (released 2019-09-20)
Added
- Package
apheleia
- Command
apheleia-format-buffer
- User options:
apheleia-formatters
, with supported formatters:black
prettier
gofmt
terraform
apheleia-mode-alist
apheleia-post-format-hook
- Variable
apheleia-formatter
- Minor mode
apheleia-mode
(andapheleia-global-mode
)