fix(format): handle git-gutter nicely
This commit is contained in:
parent
7e15504163
commit
dc3b5c3710
2 changed files with 18 additions and 11 deletions
|
@ -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)))
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -116,6 +116,11 @@ is deferred until the file is saved. Respects `git-gutter:disabled-modes'."
|
|||
;; UX: update git-gutter on focus (in case I was using git externally)
|
||||
(add-hook 'focus-in-hook #'git-gutter:update-all-windows)
|
||||
|
||||
;; Stop git-gutter doing things when we don't want
|
||||
(remove-hook 'post-command-hook #'git-gutter:post-command-hook)
|
||||
(advice-remove #'quit-window #'git-gutter:quit-window)
|
||||
(advice-remove #'switch-to-buffer #'git-gutter:switch-to-buffer)
|
||||
|
||||
(add-hook! '(doom-escape-hook doom-switch-window-hook) :append
|
||||
(defun +vc-gutter-update-h (&rest _)
|
||||
"Refresh git-gutter on ESC. Return nil to prevent shadowing other
|
||||
|
@ -130,6 +135,9 @@ is deferred until the file is saved. Respects `git-gutter:disabled-modes'."
|
|||
(advice-add #'magit-stage-file :after #'+vc-gutter-update-h)
|
||||
(advice-add #'magit-unstage-file :after #'+vc-gutter-update-h)
|
||||
|
||||
;; UX: update git-gutter after reverting a buffer
|
||||
(add-hook 'after-revert-hook #'+vc-gutter-update-h)
|
||||
|
||||
;; FIX: stop git-gutter:{next,previous}-hunk from jumping to random hunks.
|
||||
(defadvice! +vc-gutter--fix-linearity-of-hunks-a (diffinfos is-reverse)
|
||||
:override #'git-gutter:search-near-diff-index
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue