Commit graph

114 commits

Author SHA1 Message Date
Ed Slocomb
54a192c345
Add support for formatters locally installed via yarn 2+ pnp mode (#200)
This adds support for formatters installed locally in project
directories via yarn 2's "zero install" [pnp
mode](https://yarnpkg.com/features/pnp).

It's quite similar to the support for formatters installed locally in a
project's `node_modules` via npm, and leverages the `npx` symbol, so
existing formatter definitions should work without modification.

This checks for a `.pnp.cjs` file (expected in the project root for yarn
pnp projects), then looks for a yarn executable, and checks the version
of yarn to make sure it supports pnp. If that works, we just push
`"yarn"` onto the front of `command`.

I've only tested this with a locally installed `prettier.js`. It's very
much a works-for-me draft, I'm putting in a PR to make sure this is a
workable approach before going any further with it.

---------

Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
2023-11-05 12:08:58 -08:00
Chris Rose
392028d823
Add support for the ruff python formatter (#236)
This adds support, but does not make it the default
Fixes: #233

---------

Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
2023-11-04 18:23:00 +00:00
Dhananjay Balan
5bade7a734
Use hclfmt to format hashicorp HCL files. (#231)
Add formatter `hclfmt` for Hashicorp Configuration Langauge (HCL).
2023-10-29 15:17:34 -07:00
Ed Slocomb
f4157e8c39
Use lisp-indent formatter in emacs-lisp-mode (#223)
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>
2023-10-21 18:41:15 +00:00
Mohsin Kaleem
51b8a796b6
Restructure and refactor apheleia package (#215)
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.
2023-10-17 21:20:38 +01:00
Radon Rosborough
f57d21ef1f
[#208] Allow ignoring Emacs indentation settings (#211)
For
https://github.com/radian-software/apheleia/discussions/208#discussioncomment-7086819
2023-10-12 20:19:14 -07:00
Ed Slocomb
afa0e54e43
Add ormolu and fourmolu, remove brittany (#221)
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>
2023-10-06 21:39:38 -07:00
Radon Rosborough
970b331171 Update changelog 2023-09-30 21:40:48 -07:00
realazy
1fae320aae
Use prettier-json for js-json-mode (#209)
By default Emacs 29 uses `js-json-mode` for JSON file (correct me if I'm
wrong), this pr enables the right formatter for this mode.
2023-09-30 21:40:04 -07:00
Mohsin Kaleem
bac7277ed0
Run jq without colorization (#213)
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[].
```
2023-09-30 16:40:18 -07:00
Mohsin Kaleem
c7e41940ca Update changelog for last commit 2023-09-30 09:37:20 +01:00
Radon Rosborough
e944e24584
Make apheleia-mode-alist order-independent(-ish) (#207)
Solves https://github.com/radian-software/apheleia/issues/206
2023-09-09 16:13:13 -07:00
Ed Slocomb
706d6bd347
Add ruby-standard formatter (#201)
There are *so many* opinionated no-config ruby formatters ;)
2023-08-11 17:25:58 -07:00
Semen
f85b48e2ee
Add yapf formatter (#196)
<!--

To expedite the pull request process, please see the contributor guide
for my projects:

  <https://github.com/raxod502/contributor-guide>

-->
2023-05-27 10:55:56 -07:00
dalu
d4a5965d29
Add more tree-sitter based modes (#191) 2023-05-12 17:48:33 -07:00
Mohsin Kaleem
e9e595f003
Add rufo formatter (#177) 2023-04-22 11:56:29 +01:00
Mohsin Kaleem
95bea3371b
Add rubocop formatter (#176) 2023-04-22 11:53:13 +01:00
Mohsin Kaleem
93c11bf5e3
Add perltidy formatter (#175) 2023-04-22 11:48:38 +01:00
Mohsin Kaleem
2686e7b17d
Add html-tidy formatter (#173) 2023-04-22 11:44:44 +01:00
Mohsin Kaleem
568862dc84
Add cmake-format formatter (#172) 2023-04-22 11:41:37 +01:00
Mohsin Kaleem
5cb7156ef5
Add buildifier formatter (#171) 2023-04-22 11:38:15 +01:00
Mohsin Kaleem
85a2ab7e5e
Add beautysh formatter (#170) 2023-04-22 11:34:12 +01:00
Mohsin Kaleem
0290ae18cc
Add astyle formatter (#169) 2023-04-22 10:36:38 +01:00
Mohsin Kaleem
bc6b72c05d
Add asmfmt formatter (#168) 2023-04-22 10:26:49 +01:00
Mohsin Kaleem
49890c3762
Add gawk formatter (#187) 2023-04-20 14:33:53 +01:00
Mohsin Kaleem
6516abee4a
Add jq formatter (#174) 2023-04-20 13:50:03 +01:00
Daniel Perez Alvarez
0a5a84ab03
docs: fix broken links in changelog (#184)
links for PRs #151 and #155 were broken in the changelog

use the rich view mode in github for better view of the result:

![image](https://user-images.githubusercontent.com/17787042/228892528-888ec39a-8681-4f57-952a-72f512f5d2cd.png)
2023-04-06 16:26:42 -07:00
Tomasz Hołubowicz
23c8b7d1ca
Add purs-tidy formatter (#182)
Hello!

I would like to add support for `purs-tidy` - PureScript formatter. 

Best wishes
alternateved
2023-03-29 14:35:02 -07:00
Jay Barra
43ffed7890
Pretter svelte-mode (#178)
Adds support for `svelte-mode` using prettier.

Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
2023-03-23 14:00:51 -07:00
Aleksandar Dimitrov
60f897a3a0
Fix ktlint (#159)
* 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
2023-03-11 15:46:17 -08:00
Radon Rosborough
ffa8d58651 Release version 3.2 2023-02-25 11:31:26 -08:00
Nikolai Prokoschenko
972b9906bf
Add formatter for Caddyfile (#154)
Add formatter for Caddyfile (#136)
2023-02-18 17:00:08 -08:00
Radon Rosborough
4f2e4cd925 [#156] Fix error when first arg is symbol 2023-02-15 19:01:53 -08:00
Jesse Claven
9f1ee0385a
feat: Add Elixir Tree-sitter mode (#155)
Builds on #145, #148, and #151.
2023-02-15 18:18:21 -08:00
Yuxuan Kang
a74cd991a6
Avoid overwriting apheleia-formatters for npx commands (#152)
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.
2023-02-03 16:07:25 -08:00
Michael Eliachevitch
2520f14e1f
Add support for remaining treesit modes built into Emacs29 (#151)
* 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
2023-01-26 19:14:55 -08:00
Radon Rosborough
93d2b30dd0 Do not enable shfmt by default
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).
2023-01-20 20:34:58 -07:00
Daniel Perez Alvarez
5ebd6bf581
Add support for tsx-ts-mode (#148)
* 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>
2022-12-24 10:04:22 -07:00
Abin Simon
deab8fb972
Add gofumpt and goimports as formatter options (#147)
* Add gofumpt and goimports as formatter options

* Add tests for gofumpt and goimports

* changelog

Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
2022-12-10 02:07:34 +00:00
Brian Leung
049b724858
apheleia-mode-alist: Add new tree-sitter based major modes (#145)
-------

<!--

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>
2022-11-27 02:17:13 +00:00
Radon Rosborough
33d4542b58 Merge tag 'v3.1' 2022-11-11 19:50:56 -08:00
Radon Rosborough
5286b1c61c Release version 3.1 2022-11-11 19:47:03 -08:00
Dan
a82e40c450
Introduce apheleia-inhibit-functions (#138)
Fixes #134

(I accidentally force-pushed #135 from a shallow repo)

Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
2022-11-12 03:28:40 +00:00
Valeriy Litkovskyy
d72168740a
Make apheleia-mode lighter customizable (#143)
<!--

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>
2022-11-12 03:03:14 +00:00
Billy.Zheng
823a81319f
Add Crystal lang support. (#137)
Thanks

Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
2022-10-24 17:42:15 -07:00
leonidborisenko
aae79b7b2a
Use inplace formatter output (#132)
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>
2022-10-05 23:19:36 +00:00
Radon Rosborough
1eedb7e666 Do not format Elisp by default
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.
2022-09-14 19:05:04 -07:00
Ellis Kenyő
9101a3380c
Assume filename correctly (#128)
Fixes #108

Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
2022-09-13 19:05:22 -07:00
Ellis Kenyő
e01ced3ac9
Guard against missing formatters (#126)
Fixes #122
2022-09-11 09:18:30 +01:00
Radon Rosborough
46d373f4bd
[#103] Specify --parser in Prettier (#107)
Closes #103
2022-09-10 17:24:54 -07:00