Commit graph

265 commits

Author SHA1 Message Date
Jesse Claven
9f1ee0385a
feat: Add Elixir Tree-sitter mode (#155)
Builds on #145, #148, and #151.
2023-02-15 18:18:21 -08:00
Radon Rosborough
1bd5f2b8fa [#156] Document evaluation of non-strings 2023-02-15 18:11:24 -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
Radon Rosborough
b4aa52da76
[#131] Ignore interrupted processes (#139)
Should fix https://github.com/radian-software/apheleia/issues/131
2022-10-24 18:01:55 -07: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
7aa46ba84f Fix json-mode not working 2022-09-14 19:08:37 -07: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ő
4c66f76b22
docs: add note about wiki (#129)
Refs:
https://github.com/radian-software/apheleia/issues/115#issuecomment-1246138394
2022-09-14 14:22:56 +01: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
Ellis Kenyő
8ff45766fa
Ignore narrowed buffers (#127)
Fixes #124

Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
2022-09-10 17:06:06 -07:00
Ellis Kenyő
4555ace65b
Only format when the buffer is live (#125)
* fix: only format when the buffer is live

Fixes #123

* Update changelog

Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
2022-09-10 16:37:13 -07:00
Ellis Kenyő
9b745df2fa
Add emacs-lisp formatting (#102)
* feat: add emacs-lisp formatting

* Disable indent-tabs-mode

* Add stub file for installation

* Fix lint errors

* fix: correctly format based on previous mode

* Formatting

* Fix weird indent

* Add checkindent target

* Update changelog

* Long line

* Empty commit

* fix ci

* revert changelog reformatting

* more changelog

* more

Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
2022-09-03 11:22:35 -07:00
Ellis Kenyő
4d59a9b696
Add elm-format (#100)
* feat: add elm-format

* fix: master => main

* Update elm-format.bash

Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
2022-09-03 10:57:40 -07:00
Ellis Kenyő
04366a90df
Only process when there is output to return (#116)
* fix: only process when there is output to return

scalafmt only returns stdout when there are errors, this could also help
in other cases where a formatter returns incorrectly.

Ideally, this would also be improved by basic error checking heuristics
to work out if we need to update the buffer.

* Update changelog

Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
2022-08-21 15:21:21 -07:00
Leo Gaskin
ebb62564a8
Use :connection-type pipe when creating local processes (#119)
* Use :connection-type pipe when creating local processes

This is helpful because some formatters, rather than having an option
to enable reading from stdin, simply check whether their input comes
from a pipe or terminal.

Should close #118

* Document changes

* Break long lines

* Link to PR

Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
2022-08-21 14:47:20 -07:00
Anders Kaseorg
0c5e40e8bc
Allow formatter using 'filepath on a modified buffer (#110)
* Run bean-format on stdin (fixing incorrect 'filepath use)

'filepath is supposed to indicate that the formatter doesn’t actually
read from the named file, meaning it’s safe to use on a modified
buffer.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>

* Allow formatter using 'filepath on a modified buffer

Fixes #109.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>

* Add links to changelog

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
2022-08-14 16:28:01 -07:00
Radon Rosborough
12804a5020 Change URLs in changelog 2022-06-20 14:51:38 -07:00
Ellis Kenyő
ac6f733d7b
Add bean-format (#101)
* feat: add bean-format

* fix: apt => apt-get

Co-authored-by: Radon Rosborough <radon.neon@gmail.com>

* fix: pip => pip3

Co-authored-by: Radon Rosborough <radon.neon@gmail.com>

* Update changelog

Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
2022-06-20 14:51:17 -07:00
Kisaragi Hiu
2fa9dd97ed
Add stylua (#105) 2022-06-20 14:21:27 -07:00
Radon Rosborough
67853e98b1 Use spaces instead of tabs in shfmt 2022-06-04 15:39:09 -07:00
Radon Rosborough
b25256f1b0 [#99] Remove erroneous reference to master 2022-06-03 17:41:25 -07:00
Radon Rosborough
18ccacc5cf Release version 3.0 2022-06-01 10:37:53 -07:00
michzappa
cececba08f
Add nixfmt (#98)
* Add nixfmt

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
2022-05-15 21:36:47 -07:00
Ellis Kenyő
363d634c5c
Add ktlint (#97)
* feat: add ktlint

* Apply suggestions from code review

Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
2022-05-13 09:23:57 -07:00
Ellis Kenyő
b5dbab53ea
Add shfmt (#90)
* feat: add shfmt

Add support for shfmt

* Handle multiple architectures

Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
2022-05-12 12:52:57 -07:00
Ellis Kenyő
982df5a2e0
Add phpcs & introduce scripts/formatters (#87)
* feat: add phpcs & introduce scripts/formatters

Add phpcs as a supported formatter, and include support for
apheleia-defined scripts for more troublesome formatters

* Revert Emacs version requirement

* More quoting

* Adjust language in documentation

* Thanks checkdoc, lol

Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
2022-05-11 16:26:33 -07:00
Ellis Kenyő
83179060f2
Use ocamlformat for caml-mode too (#94)
* fix: use ocamlformat for caml-mode too

* Update changelog

Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
2022-05-11 16:26:22 -07:00
Radon Rosborough
a0737fd695 Update to reflect IP transfer 2022-05-09 15:58:41 -07:00
dalu
50da8cd1a9
Dart format support (#89)
* Dart format support

* fix: different architexture

* Update changelog

* Improve installation

Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
2022-05-01 14:51:27 -07:00
Radon Rosborough
b7251e54a0 Avoid using git to get project root 2022-05-01 14:40:02 -07:00
Radon Rosborough
9804f241ac [#86] Update outdated docstring
Closes #86
2022-04-17 11:59:32 -07:00
Mohsin Kaleem
806210414b
Support formatting remote files with Tramp (#76)
* [#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>
2022-04-10 14:21:50 -07:00
Radon Rosborough
84b04329d7 Release version 2.0 2022-04-10 13:54:40 -07:00
Radon Rosborough
9ed3c9d72a
[#82] Fix typo
Closes #82
2022-03-20 15:38:33 -07:00
Terje Larsen
75074a2f11
Define apheleia-formatter as a safe-local-variable (#74)
* Define apheleia-formatter as a safe-local-variable

This adds support for variables from .dir-locals for users that are
using the setting enable-local-variables :safe or it won't ask for those
who have it set to t.

* Update changelog

Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
2022-01-14 15:29:26 -08:00
Radon Rosborough
e95769bf34 Changelog fixes 2022-01-11 21:14:17 -08:00
Radon Rosborough
53f243b111
Add formatter tests (#72)
Closes #24
Builds on #25 by @PrimaryCanary
2022-01-05 15:35:12 -08:00
Radon Rosborough
41fa1f70ee [#58] Do not change the mode when saving
Closes #58
2022-01-04 21:07:17 -08:00