aboutsummaryrefslogtreecommitdiff
path: root/apheleia-formatters.el
diff options
context:
space:
mode:
authorClaudio Bley <claudio.bley@gmail.com>2025-03-04 21:44:34 +0100
committerGitHub <noreply@github.com>2025-03-04 12:44:34 -0800
commit6ad9e9442365845b1cc5a10035466cfcb1022675 (patch)
tree13d591c2b8d9a7be457968f4140de562b7356259 /apheleia-formatters.el
parentd8ccc0ba0f127c11df39e79313a17bcb740359c0 (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>
Diffstat (limited to 'apheleia-formatters.el')
-rw-r--r--apheleia-formatters.el8
1 files changed, 7 insertions, 1 deletions
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"