diff options
| author | Claudio Bley <claudio.bley@gmail.com> | 2025-03-04 21:44:34 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-04 12:44:34 -0800 |
| commit | 6ad9e9442365845b1cc5a10035466cfcb1022675 (patch) | |
| tree | 13d591c2b8d9a7be457968f4140de562b7356259 | |
| parent | d8ccc0ba0f127c11df39e79313a17bcb740359c0 (diff) | |
Specify file type for buildifier explicitly (#352)
When formatting Bazel files, buildifier needs to know the concrete file
type which it usually deduces from the file name which is impossible
when operating on stdin.
For example, the order of load statements in a WORKSPACE file is
significant and re-ordering might break it.
---------
Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | apheleia-formatters.el | 8 |
2 files changed, 11 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 880b04e..0adcab1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog]. +## Unreleased +### Formatters +* Format Bazel files according to their type + ## 4.4 (released 2025-02-12) ### Bugs fixed * `$PATH` was not correctly respected for some remote executables ([#341]). diff --git a/apheleia-formatters.el b/apheleia-formatters.el index c12c970..e6adfaa 100644 --- a/apheleia-formatters.el +++ b/apheleia-formatters.el @@ -34,7 +34,13 @@ (apheleia-formatters-fill-column "--line-length") "-")) (brittany . ("brittany")) - (buildifier . ("buildifier")) + (buildifier . ("buildifier" "-type" + (cond + ((eq major-mode 'bazel-workspace-mode) "workspace") + ((eq major-mode 'bazel-module-mode) "module") + ((eq major-mode 'bazel-build-mode) "build") + (t "auto") + ))) (biome . ("apheleia-npx" "biome" "format" "--stdin-file-path" filepath)) (caddyfmt . ("caddy" "fmt" "-")) (clang-format . ("clang-format" |
