Moves the bulk of apheleia.el into a new apheleia-core.el file and move
formatter definitions and mode-associations into a new
apheleia-formatters.el file. The end user experience should be
unchanged. Loading `apheleia.el` will still load everything load
everything, just like it used to.
* Suppress logs for ktlint
Recent versions of ktlint (mine's 0.48.2) have started including logs
in their output when the `--stdin` flag is given. These logs would end
up being included *into the file* by apheleia, which isn't what we
want.
Since emitting log messages is likely never a good idea when
formatting code, I just opted to disable them altogether using a
command line flag. This fixes the issue.
* Add change log message about ktlint fix
When the formatter is an npx command, setcar is used to expand the
binary file path to node_modules/.bin. But setcar overwrites the
underlying list, so the expanded path is set into
apheleia-formatters. (The list was processed by remq before setcar,
but remq seems to return the cdr if only the first element is
removed.) This is undesirable because when working on multiple NPM
packages, each package may have a formatter of different version.
* Add support for rust-ts-mode
* Add new builtin go-, ruby- and yaml- treesit-modes
Modes taken from NEWS.29 emacs29 release notes
* Add new PR number to changelog entry for ts-modes
Per https://github.com/mvdan/sh/issues/963 we should not invoke shfmt
on zsh files. However, Emacs represents all shell scripts using
sh-mode, so in order to enable shfmt by default, we will need a
feature to make the usage of a formatter conditional on another
variable (in this case sh-shell). Until Apheleia supports this
feature, removing shfmt by default (it can still be enabled by the
user, or run manually).
* feat: add support for new tsx-ts-mode in emacs 29
from emacs docs:
> tsx-ts-mode is an autoloaded, interactive and natively compiled
function defined in typescript-ts-mode.el.gz.
Signature
(tsx-ts-mode)
Documentation
Major mode for editing TypeScript.
In addition to any hooks its parent mode typescript-ts-base-mode
might have run, this mode runs the hook tsx-ts-mode-hook, as the
final or penultimate step during initialization.
* update changelog
* Fix broken link in changelog
Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
-------
<!--
To expedite the pull request process, please see the contributor guide
for my projects:
<https://github.com/raxod502/contributor-guide>
-->
Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
<!--
To expedite the pull request process, please see the contributor guide
for my projects:
<https://github.com/raxod502/contributor-guide>
-->
Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
When formatting command is defined with symbol `inplace`, it doesn't
work.
I'm using [casey/just](https://github.com/casey/just) (v1.5.0).
It doesn't support formatting of `stdin`, but it supports in-place
formatting with command `just --unstable --fmt --justfile
/tmp/justfile`. So I've added a list to to `apheleia-formatters` custom
variable:
```elisp
(add-to-list 'apheleia-formatters
'(just . ("just" "--unstable" "--fmt" "--justfile" inplace))
"APPEND:non-nil")
```
Minimal `justfile` before formatting (there is one space before `echo`):
```make
rule:
echo test
```
Expected formatting result (there are four spaces before `echo`):
```make
rule:
echo test
```
Without this pull request there are no visible changes after
<kbd>C-u</kbd> <kbd>M-x</kbd> `apheleia-format-buffer` <kbd>RET</kbd>
`just` <kbd>RET</kbd>. When this pull request is applied, formatting
proceed as expected.
Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
There are just too many Elisp files that are indented in nonstandard
ways for this to be an okay default, I think. And to make matters
worse, Elisp indentation varies depending on what is loaded into the
current environment (due to macros, etc), meaning that your
indentation may become broken if you happen to edit a file with the
wrong libraries loaded.