fix(format): handle git-gutter nicely

This commit is contained in:
Ellis Kenyő 2022-09-07 22:23:34 +01:00 committed by Ellis Kenyo
parent 7e15504163
commit dc3b5c3710
No known key found for this signature in database
GPG key ID: 298BE5D997EBAA02
2 changed files with 18 additions and 11 deletions

View file

@ -33,17 +33,16 @@ select buffers.")
(funcall orig-fn)))
(add-hook! 'apheleia-post-format-hook
;; HACK `web-mode' doesn't update syntax highlighting after arbitrary buffer
;; modifications, so we must trigger refontification manually.
(defun +format--fix-web-mode-fontification-h ()
(when (eq major-mode 'web-mode)
(setq web-mode-fontification-off nil)
(when (and web-mode-scan-beg web-mode-scan-end global-font-lock-mode)
(save-excursion
(font-lock-fontify-region web-mode-scan-beg web-mode-scan-end)))))
(defun +format--refresh-git-gutter-h ()
(when (bound-and-true-p git-gutter-mode)
(git-gutter))))
;; HACK `web-mode' doesn't update syntax highlighting after arbitrary buffer
;; modifications, so we must trigger refontification manually.
(defun +format--fix-web-mode-fontification-h ()
(when (eq major-mode 'web-mode)
(setq web-mode-fontification-off nil)
(when (and web-mode-scan-beg web-mode-scan-end global-font-lock-mode)
(save-excursion
(font-lock-fontify-region web-mode-scan-beg web-mode-scan-end)))))
(defun +format--refresh-git-gutter-h ()
(+vc-gutter-init-maybe-h)))
;;