refactor(vc-gutter): simplify & DRY
These advice were unnecessary when not only does diff-hl expose variables to change them, but one of the overridden definitions is identical to the function it's replacing. Also includes some other minor refactors.
This commit is contained in:
parent
78304f4d79
commit
f1f72c291a
1 changed files with 6 additions and 8 deletions
|
@ -32,17 +32,15 @@
|
||||||
(make-string (- w half-w) ?0)))
|
(make-string (- w half-w) ?0)))
|
||||||
2))
|
2))
|
||||||
nil nil 'center)))
|
nil nil 'center)))
|
||||||
(defun +vc-gutter-type-face-fn (type _pos)
|
|
||||||
(intern (format "diff-hl-%s" type)))
|
|
||||||
(defun +vc-gutter-type-at-pos-fn (type _pos)
|
(defun +vc-gutter-type-at-pos-fn (type _pos)
|
||||||
(if (eq type 'delete)
|
(if (eq type 'delete)
|
||||||
'diff-hl-bmp-delete
|
'diff-hl-bmp-delete
|
||||||
'diff-hl-bmp-middle))
|
'diff-hl-bmp-middle))
|
||||||
(advice-add #'diff-hl-fringe-bmp-from-pos :override #'+vc-gutter-type-at-pos-fn)
|
(setq diff-hl-fringe-bmp-function #'+vc-gutter-type-at-pos-fn)
|
||||||
(advice-add #'diff-hl-fringe-bmp-from-type :override #'+vc-gutter-type-at-pos-fn)
|
|
||||||
(setq diff-hl-draw-borders nil)
|
(setq diff-hl-draw-borders nil)
|
||||||
|
|
||||||
(add-hook! 'diff-hl-mode-hook
|
(add-hook! 'diff-hl-mode-hook
|
||||||
(defun +vc-gutter-fix-diff-hl-faces-h ()
|
(defun +vc-gutter-make-diff-hl-faces-transparent-h ()
|
||||||
(mapc (doom-rpartial #'set-face-background nil)
|
(mapc (doom-rpartial #'set-face-background nil)
|
||||||
'(diff-hl-insert
|
'(diff-hl-insert
|
||||||
diff-hl-delete
|
diff-hl-delete
|
||||||
|
@ -122,9 +120,9 @@
|
||||||
(when (modulep! :editor evil)
|
(when (modulep! :editor evil)
|
||||||
(add-hook! 'diff-hl-flydiff-mode-hook
|
(add-hook! 'diff-hl-flydiff-mode-hook
|
||||||
(defun +vc-gutter-init-flydiff-mode-h ()
|
(defun +vc-gutter-init-flydiff-mode-h ()
|
||||||
(if (not diff-hl-flydiff-mode)
|
(if diff-hl-flydiff-mode
|
||||||
(remove-hook 'evil-insert-state-exit-hook #'diff-hl-flydiff-update)
|
(add-hook 'evil-insert-state-exit-hook #'diff-hl-flydiff-update)
|
||||||
(add-hook 'evil-insert-state-exit-hook #'diff-hl-flydiff-update)))))
|
(remove-hook 'evil-insert-state-exit-hook #'diff-hl-flydiff-update)))))
|
||||||
|
|
||||||
;; FIX: Reverting a hunk causes the cursor to be moved to an unexpected place,
|
;; FIX: Reverting a hunk causes the cursor to be moved to an unexpected place,
|
||||||
;; often far from the target hunk.
|
;; often far from the target hunk.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue