mirror of
https://github.com/vale981/apheleia
synced 2025-03-04 09:01:42 -05:00
Make it so that if there is a `.formatter.exs` file somewhere in the parent directories, then Apheleia will run `mix format` from there instead of the current directory. Close #232
This commit is contained in:
parent
598ef3c7cb
commit
ddea9bea70
3 changed files with 27 additions and 1 deletions
|
@ -34,6 +34,9 @@ The format is based on [Keep a Changelog].
|
|||
* Autoload the apheleia-goto-error command ([#215]).
|
||||
* Use `lisp-indent` as default formatter for `emacs-lisp-mode` ([#223])
|
||||
* Use `hclfmt` for formatting hashicorp HCL files ([#231])
|
||||
* The `mix format` formatter will respect `.formatter.exs` files even
|
||||
if they are present in a parent directory rather than the same
|
||||
directory as the file being formatted ([#232]).
|
||||
|
||||
### Internal Changes
|
||||
* Refactored the organisation of the apheleia package for ease of
|
||||
|
@ -104,6 +107,7 @@ The format is based on [Keep a Changelog].
|
|||
[#215]: https://github.com/radian-software/apheleia/pull/215
|
||||
[#223]: https://github.com/radian-software/apheleia/pull/223
|
||||
[#231]: https://github.com/radian-software/apheleia/pull/231
|
||||
[#232]: https://github.com/radian-software/apheleia/issues/232
|
||||
[#236]: https://github.com/radian-software/apheleia/pull/236
|
||||
[#242]: https://github.com/radian-software/apheleia/pull/242
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
(lisp-indent . apheleia-indent-lisp-buffer)
|
||||
(ktlint . ("ktlint" "--log-level=none" "--stdin" "-F" "-"))
|
||||
(latexindent . ("latexindent" "--logfile=/dev/null"))
|
||||
(mix-format . ("mix" "format" "-"))
|
||||
(mix-format . ("apheleia-mix" "format" "-"))
|
||||
(nixfmt . ("nixfmt"))
|
||||
(ocamlformat . ("ocamlformat" "-" "--name" filepath
|
||||
"--enable-outside-detected-project"))
|
||||
|
|
22
scripts/formatters/apheleia-mix
Executable file
22
scripts/formatters/apheleia-mix
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This function prints the name of the current directory if it
|
||||
# contains a file or directory named after the first argument, or the
|
||||
# parent directory if it contains such a file, or the parent's parent,
|
||||
# and so on. If no such file is found it returns nonzero.
|
||||
# https://unix.stackexchange.com/a/22215
|
||||
find_upwards() {
|
||||
fname="$1"
|
||||
|
||||
path="${PWD}"
|
||||
while [[ -n "${path}" && ! -e "${path}/${fname}" ]]; do
|
||||
path="${path%/*}"
|
||||
done
|
||||
[[ -n "${path}" ]] && echo "${path}"
|
||||
}
|
||||
|
||||
if dir="$(find_upwards .formatter.exs)"; then
|
||||
cd -- "${dir}" || exit
|
||||
fi
|
||||
|
||||
exec mix "$@"
|
Loading…
Add table
Reference in a new issue