Ine0a926d
, I defaulted to not using bitmaps for indent-guides, but after some more research, I realize this slowness is more prominent on MacOS, older PGTK builds, and (possibly) Windows, so I've opted to re-enable bitmaps by default, unless you're on one of those systems (except Windows; still testing that). This change also makes the guide bars more subtle, since the default is too distracting and colorful. Ref: #8052 Ref:e0a926dc1e
63 lines
2.6 KiB
EmacsLisp
63 lines
2.6 KiB
EmacsLisp
;;; ui/indent-guides/config.el -*- lexical-binding: t; -*-
|
|
|
|
(defcustom +indent-guides-inhibit-functions ()
|
|
"A list of predicate functions.
|
|
|
|
Each function will be run in the context of a buffer where `indent-bars' should
|
|
be enabled. If any function returns non-nil, the mode will not be activated."
|
|
:type 'hook
|
|
:group '+indent-guides)
|
|
|
|
|
|
;;
|
|
;;; Packages
|
|
|
|
(use-package! indent-bars
|
|
:hook ((prog-mode text-mode conf-mode) . +indent-guides-init-maybe-h)
|
|
:init
|
|
(defun +indent-guides-init-maybe-h ()
|
|
"Enable `indent-bars-mode' depending on `+indent-guides-inhibit-functions'."
|
|
(unless (run-hook-with-args-until-success '+indent-guides-inhibit-functions)
|
|
(indent-bars-mode +1)))
|
|
:config
|
|
(setq indent-bars-prefer-character
|
|
(or
|
|
;; Bitmaps are far slower on MacOS, inexplicably, but this needs more
|
|
;; testing to see if it's specific to ns or emacs-mac builds, or is
|
|
;; just a general MacOS issue.
|
|
(featurep :system 'macos)
|
|
;; FIX: A bitmap init bug in PGTK builds of Emacs before v30 that could
|
|
;; cause crashes (see jdtsmith/indent-bars#3).
|
|
(and (featurep 'pgtk)
|
|
(< emacs-major-version 30)))
|
|
|
|
;; Show indent guides starting from the first column.
|
|
indent-bars-starting-column 0
|
|
;; Make indent guides subtle; the default is too distractingly colorful.
|
|
indent-bars-width-frac 0.15 ; make bitmaps thinner
|
|
indent-bars-color-by-depth nil
|
|
indent-bars-color '(font-lock-comment-face :face-bg nil :blend 0.425)
|
|
;; Don't highlight current level indentation; it's distracting and is
|
|
;; unnecessary overhead for little benefit.
|
|
indent-bars-highlight-current-depth nil)
|
|
|
|
;; TODO: Uncomment once we support treesit
|
|
;; (setq indent-bars-treesit-support (modulep! :tools tree-sitter))
|
|
|
|
(unless (boundp 'enable-theme-functions)
|
|
(add-hook 'doom-load-theme-hook #'indent-bars-reset-styles))
|
|
|
|
(add-hook! '+indent-guides-inhibit-functions
|
|
;; Org's virtual indentation messes up indent-guides.
|
|
(defun +indent-guides-in-org-indent-mode-p ()
|
|
(bound-and-true-p org-indent-mode))
|
|
;; Fix #6438: indent-guides prevent inline images from displaying in ein
|
|
;; notebooks.
|
|
(defun +indent-guides-in-ein-notebook-p ()
|
|
(and (bound-and-true-p ein:notebook-mode)
|
|
(bound-and-true-p ein:output-area-inlined-images)))
|
|
;; Don't display indent guides in childframe popups (not helpful in
|
|
;; completion or eldoc popups).
|
|
;; REVIEW: Swap with `frame-parent' when 27 support is dropped
|
|
(defun +indent-guides-in-childframe-p ()
|
|
(frame-parameter nil 'parent-frame))))
|