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.
This commit is contained in:
2022-07-30 21:56:24 +01:00
parent 7f32de8c49
commit 646876f1cd

View File

@@ -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