What it says in the subject :)
Apheleia is opinionated about using a formatter, and which to use as a
default, in every other mode it supports, so it seems it should have an
opinion about emacs-lisp-mode, too?
---------
Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
CLOSES#212
PR to restructure apheleia to make it more modular and improve some of
the separation of concerns. Before merging we should make sure that we
don't reintroduce the issues from #181.
Found while trying to `make fmt-build` that the installer for `brittany`
was broken, and couldn't fix it.
This removes brittany, and adds the ormolu and fourmolu formatters for
haskell, and sets ormolu as the default for haskell-mode.
---------
Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
Set the -M flag to jq:
```text
λ jq --help mohkale@mk-desktop ~
jq - commandline JSON processor [version 1.7]
Usage: jq [options] <jq filter> [file...]
jq [options] --args <jq filter> [strings...]
jq [options] --jsonargs <jq filter> [JSON_TEXTS...]
jq is a tool for processing JSON inputs, applying the given filter to
its JSON text inputs and producing the filter's results as JSON on
standard output.
The simplest filter is ., which copies jq's input to its output
unmodified except for formatting. For more advanced filters see
the jq(1) manpage ("man jq") and/or https://jqlang.github.io/jq/.
Example:
$ echo '{"foo": 0}' | jq .
{
"foo": 0
}
Command options:
-n, --null-input use `null` as the single input value;
-R, --raw-input read each line as string instead of JSON;
-s, --slurp read all inputs into an array and use it as
the single input value;
-c, --compact-output compact instead of pretty-printed output;
-r, --raw-output output strings without escapes and quotes;
--raw-output0 implies -r and output NUL after each output;
-j, --join-output implies -r and output without newline after
each output;
-a, --ascii-output output strings by only ASCII characters
using escape sequences;
-S, --sort-keys sort keys of each object on output;
-C, --color-output colorize JSON output;
-M, --monochrome-output disable colored output;
--tab use tabs for indentation;
--indent n use n spaces for indentation (max 7 spaces);
--unbuffered flush output stream after each output;
--stream parse the input value in streaming fashion;
--stream-errors implies --stream and report parse error as
an array;
--seq parse input/output as application/json-seq;
-f, --from-file file load filter from the file;
-L directory search modules from the directory;
--arg name value set $name to the string value;
--argjson name value set $name to the JSON value;
--slurpfile name file set $name to an array of JSON values read
from the file;
--rawfile name file set $name to string contents of file;
--args consume remaining arguments as positional
string values;
--jsonargs consume remaining arguments as positional
JSON values;
-e, --exit-status set exit status code based on the output;
-V, --version show the version;
--build-configuration show jq's build configuration;
-h, --help show the help;
-- terminates argument processing;
Named arguments are also available as $ARGS.named[], while
positional arguments are available as $ARGS.positional[].
```
* 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.