aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrimaryCanary <46076977+PrimaryCanary@users.noreply.github.com>2021-08-08 13:07:08 +0000
committerGitHub <noreply@github.com>2021-08-08 06:07:08 -0700
commit8e022c67fea4248f831c678b31c19646cbcbbf6f (patch)
tree8b2bee84d1f33cc46bf4787d7ede00d3d1b8a989
parent52e0a140a8414699e2ed58000300f526995237f5 (diff)
[DRAFT] More formatters (#24)
* Add Rust formatter rustfmt. * Add LaTeX formatter latexindent. There's a lot of LaTeX modes. I'm not sure how to distinguish them. * Alphabetize apheleia-formatters and apheleia-mode-alist. Alphabetizing them makes it easier to find which formatters are supported. * Add Java formatter with google-java-format. * Add C and C++ formatter with clang-format. * Update changelog Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
-rw-r--r--CHANGELOG.md10
-rw-r--r--apheleia.el29
2 files changed, 31 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 09a0f87..09f2eb0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog].
## Unreleased
+### Formatters
+* [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) for
+ C/C++,
+ [`google-java-format`](https://github.com/google/google-java-format)
+ for Java, [latexindent](https://ctan.org/pkg/latexindent?lang=en)
+ for [LaTeX](https://www.latex-project.org/), and
+ [rustfmt](https://github.com/rust-lang/rustfmt) for
+ [Rust](https://www.rust-lang.org/) ([#24]).
+
### Bugs fixed
* Fix spelling error in generated process names ([#32]).
* Apheleia no longer conflicts with undo-fu (#[39]).
@@ -13,6 +22,7 @@ The format is based on [Keep a Changelog].
* Fix inconsistent `:type` spec preventing use of `customize-variable`
on `apheleia-formatters`.
+[#24]: https://github.com/raxod502/apheleia/pull/24
[#30]: https://github.com/raxod502/apheleia/issues/30
[#32]: https://github.com/raxod502/apheleia/pull/32
[#39]: https://github.com/raxod502/apheleia/issues/39
diff --git a/apheleia.el b/apheleia.el
index 9ec573c..11b6176 100644
--- a/apheleia.el
+++ b/apheleia.el
@@ -461,9 +461,13 @@ modified from what is written to disk, then don't do anything."
(defcustom apheleia-formatters
'((black . ("black" "-"))
(brittany . ("brittany" file))
- (prettier . (npx "prettier" "--stdin-filepath" filepath))
+ (clang-format . ("clang-format" file))
(gofmt . ("gofmt"))
+ (google-java-format . ("google-java-format" file))
+ (latexindent . ("latexindent" file))
(ocamlformat . ("ocamlformat" file))
+ (prettier . (npx "prettier" "--stdin-filepath" filepath))
+ (rustfmt . ("rustfmt" "--quiet" "--emit" "stdout" file))
(terraform . ("terraform" "fmt" "-")))
"Alist of code formatting commands.
The keys may be any symbols you want, and the values are
@@ -482,20 +486,29 @@ commands, lists of strings and symbols, in the format of
(const :tag "Name of temporary file used for output" output)))))
(defcustom apheleia-mode-alist
- '((css-mode . prettier)
+ '((cc-mode . clang-format)
+ (c-mode . clang-format)
+ (css-mode . prettier)
(go-mode . gofmt)
- (js-mode . prettier)
+ (haskell-mode . brittany)
+ (html-mode . prettier)
+ (java-mode . google-java-format)
(js3-mode . prettier)
+ (js-mode . prettier)
(json-mode . prettier)
- (html-mode . prettier)
+ (latex-mode . latexindent)
+ (LaTeX-mode . latexindent)
(python-mode . black)
+ (rustic-mode . rustfmt)
+ (rust-mode . rustfmt)
(sass-mode . prettier)
- (typescript-mode . prettier)
- (web-mode . prettier)
- (yaml-mode . prettier)
(terraform-mode . terraform)
+ (TeX-latex-mode . latexindent)
+ (TeX-mode . latexindent)
(tuareg-mode . ocamlformat)
- (haskell-mode . brittany))
+ (typescript-mode . prettier)
+ (web-mode . prettier)
+ (yaml-mode . prettier))
"Alist mapping major mode names to formatters to use in those modes.
This determines what formatter to use in buffers without a
setting for `apheleia-formatter'. The keys are major mode