From 646876f1cd91976ac1416c72456d96256727e271 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 30 Jul 2022 21:56:24 +0100 Subject: [PATCH] feat(language/caddyfile): format on save, use tab indentation Caddy can now format Caddyfiles with the "caddy fmt" command, so we use reformatter to create a format-on-save mode for Caddyfiles. Also there's no need for the weird whitespace-mode workaround, as we now use tab indentation in Caddyfiles, since that's what "caddy fmt" produces. --- modules/languages/siren-caddyfile.el | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/modules/languages/siren-caddyfile.el b/modules/languages/siren-caddyfile.el index 6f2ad9a..bbc5879 100644 --- a/modules/languages/siren-caddyfile.el +++ b/modules/languages/siren-caddyfile.el @@ -17,17 +17,14 @@ :preface (defun siren-caddyfile-mode-setup () - (setq-local tab-width 4 - indent-tabs-mode nil) + (setq-local tab-width 4) + (caddyfile-format-on-save-mode t)) - ;; TODO: Fix this horrible Hock. To work around prog-mode hooks running - ;; before current method, enabling whitespace-mode before the local - ;; indent-tabs-mode var is set to nil. Hence we need to toggle - ;; whitespace-mode off, and then on again to fix it's complaints about a - ;; space indentation. - (when (bound-and-true-p whitespace-mode) - (whitespace-mode -1) - (whitespace-mode +1)))) + :config + (reformatter-define caddyfile-format + :program "caddy" + :args '("fmt" "-") + :lighter " fmt")) (provide 'siren-caddyfile) ;;; siren-caddyfile.el ends here