refactor!(vc-gutter): move style defaults behind +pretty

BREAKING CHANGE: This changes moves its default configuration of the
fringe behind a +pretty flag. This won't cause breakage, but will cause
a (possibly unwanted) visual change: git-gutter will use its default
indicators (e.g. + and - symbols) instead of the continuous bars from
before.

To get back the old look, enable `+pretty` on the `:ui vc-gutter`
module.

This was done to make the defaults toggleable, to standardize +pretty,
to document issues with this customization that have been brought up by
members of the Emacs community, and to better document it in comments
for posterity.
This commit is contained in:
Henrik Lissner 2022-08-08 17:36:23 +02:00
parent 232e9d4b91
commit cd9bc5a1fd
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
3 changed files with 41 additions and 2 deletions

View file

@ -13,7 +13,13 @@ Supports Git, Svn, Hg, and Bzr.
[[doom-contrib-maintainer:][Become a maintainer?]]
** Module flags
/This module has no flags./
- +pretty ::
Apply some stylistic defaults to the fringe, enabling thin bars in the fringe.
This look takes after the modern look of git-gutter in VSCode and Sublime
Text, without sacrificing on fringe width (which squeeze other indicators,
like flycheck's, flymake's, or flyspell's). However, this will look bad with
themes that invert the foreground/background of either git-gutter's or
diff-hl's faces (like modus-themes does).
** Packages
- [[doom-package:][git-gutter-fringe]]

View file

@ -16,6 +16,39 @@ This means subtle thin bitmaps on the left, an arrow bitmap for flycheck, and
flycheck indicators moved to the right fringe.")
;;
;;; Default styles
(when (featurep! +pretty)
;; UI: make the fringe small enough that the diff bars aren't too domineering,
;; while leaving enough room for other indicators.
(if (fboundp 'fringe-mode) (fringe-mode '8))
;; UI: the gutter looks less cramped with some space between it and buffer.
(setq-default fringes-outside-margins t)
;; STYLE: Redefine fringe bitmaps to take up only half the horizontal space in
;; the fringe. This way we avoid overbearingly large diff bars without having
;; to shrink the fringe and sacrifice precious space for other fringe
;; indicators (like flycheck or flyspell).
;; TODO Extract these into a package with faces that themes can target.
(after! git-gutter-fringe
(define-fringe-bitmap 'git-gutter-fr:added [224]
nil nil '(center repeated))
(define-fringe-bitmap 'git-gutter-fr:modified [224]
nil nil '(center repeated))
(define-fringe-bitmap 'git-gutter-fr:deleted [128 192 224 240]
nil nil 'bottom))
;; FIX: To minimize overlap between flycheck indicators and git-gutter/diff-hl
;; indicators in the left fringe.
(after! flycheck
;; let diff have left fringe, flycheck can have right fringe
(setq flycheck-indication-mode 'right-fringe)
;; A non-descript, left-pointing arrow
(define-fringe-bitmap 'flycheck-fringe-bitmap-double-arrow
[16 48 112 240 112 48 16] nil nil 'center)))
;;
;;; Packages

View file

@ -46,7 +46,7 @@
;;tabs ; a tab bar for Emacs
;;treemacs ; a project drawer, like neotree but cooler
;;unicode ; extended unicode support for various languages
vc-gutter ; vcs diff in the fringe
(vc-gutter +pretty) ; vcs diff in the fringe
vi-tilde-fringe ; fringe tildes to mark beyond EOB
;;window-select ; visually switch windows
workspaces ; tab emulation, persistence & separate workspaces