refactor!(indent-guides): use indent-bars instead
BREAKING CHANGE: This swaps out the `highlight-indent-guides` package with the newer, and proportedly faster, `indent-bars`. Users don't have to make any changes to their config to support this, unless they've heavily reconfigured `highlight-indent-guides`. Ref: https://github.com/orgs/doomemacs/projects/5/views/1?filterQuery=-status%3ARejected%2CDone+indent&pane=issue&itemId=38113671
This commit is contained in:
parent
ac1122ae67
commit
0d9e188b26
5 changed files with 44 additions and 24 deletions
|
@ -334,7 +334,7 @@
|
|||
(:when (modulep! :checkers syntax)
|
||||
:desc "Flycheck" "f" #'flycheck-mode)
|
||||
(:when (modulep! :ui indent-guides)
|
||||
:desc "Indent guides" "i" #'highlight-indent-guides-mode)
|
||||
:desc "Indent guides" "i" #'indent-bars-mode)
|
||||
(:when (modulep! :ui minimap)
|
||||
:desc "Minimap mode" "m" #'minimap-mode)
|
||||
(:when (modulep! :lang org +present)
|
||||
|
|
|
@ -843,7 +843,7 @@
|
|||
:desc "Frame fullscreen" "F" #'toggle-frame-fullscreen
|
||||
:desc "Evil goggles" "g" #'evil-goggles-mode
|
||||
(:when (modulep! :ui indent-guides)
|
||||
:desc "Indent guides" "i" #'highlight-indent-guides-mode)
|
||||
:desc "Indent guides" "i" #'indent-bars-mode)
|
||||
:desc "Indent style" "I" #'doom/toggle-indent-style
|
||||
:desc "Line numbers" "l" #'doom/toggle-line-numbers
|
||||
(:when (modulep! :ui minimap)
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
/This module has no flags./
|
||||
|
||||
** Packages
|
||||
- [[doom-package:highlight-indent-guides]]
|
||||
- [[doom-package:indent-bars]]
|
||||
|
||||
** Hacks
|
||||
/No hacks documented for this module./
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
;;; ui/indent-guides/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defcustom +indent-guides-inhibit-functions nil
|
||||
(defcustom +indent-guides-inhibit-functions ()
|
||||
"A list of predicate functions.
|
||||
|
||||
Each function will be run in the context of a buffer where
|
||||
`highlight-indent-guides-mode' should be enabled. If any function returns
|
||||
non-nil, the mode will not be activated."
|
||||
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)
|
||||
|
||||
|
@ -13,17 +12,25 @@ non-nil, the mode will not be activated."
|
|||
;;
|
||||
;;; Packages
|
||||
|
||||
(use-package! highlight-indent-guides
|
||||
(use-package! indent-bars
|
||||
:hook ((prog-mode text-mode conf-mode) . +indent-guides-init-maybe-h)
|
||||
:init
|
||||
(setq highlight-indent-guides-method 'character
|
||||
highlight-indent-guides-bitmap-function #'highlight-indent-guides--bitmap-line)
|
||||
|
||||
(defun +indent-guides-init-maybe-h ()
|
||||
"Enable `highlight-indent-guides-mode'.
|
||||
Consults `+indent-guides-inhibit-functions'."
|
||||
"Enable `indent-bars-mode' depending on `+indent-guides-inhibit-functions'."
|
||||
(unless (run-hook-with-args-until-success '+indent-guides-inhibit-functions)
|
||||
(highlight-indent-guides-mode +1)))
|
||||
(indent-bars-mode +1)))
|
||||
:config
|
||||
;; Bitmap performance is inconsistent across display systems (pgtk, ns, mac,
|
||||
;; gtk, etc). There's also a bitmap init bug in PGTK builds of Emacs before
|
||||
;; v30 that could cause crashes (see jdtsmith/indent-bars#3). If you use PGTK
|
||||
;; and reverse this setting, you've been warned!
|
||||
(setq indent-bars-prefer-character t)
|
||||
|
||||
;; 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.
|
||||
|
@ -33,12 +40,23 @@ Consults `+indent-guides-inhibit-functions'."
|
|||
;; 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))))
|
||||
:config
|
||||
;; HACK: If this package is loaded too early (by the user, and in terminal
|
||||
;; Emacs), then `highlight-indent-guides-auto-set-faces' will have been
|
||||
;; called much too early to set its faces correctly. To get around this, we
|
||||
;; need to call it again, but at a time when I can ensure a frame exists an
|
||||
;; the current theme is loaded.
|
||||
(when (doom-context-p 'init)
|
||||
(add-hook 'doom-first-buffer-hook #'highlight-indent-guides-auto-set-faces)))
|
||||
(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)))
|
||||
|
||||
;; HACK: Out of the box, indent-bars offers no way to fully disable
|
||||
;; "highlighting the current line", so I advise on in, since the feature is
|
||||
;; unnecessary work (and allocation of timers) for users that don't want it,
|
||||
;; and for our performance-leaning defaults.
|
||||
(setq indent-bars-depth-update-delay nil)
|
||||
(defadvice! +indent-guides--disable-highlight-current-line-a (fn &rest args)
|
||||
:around #'indent-bars-setup
|
||||
(letf! (defun indent-bars--highlight-current-depth ()
|
||||
(when indent-bars-depth-update-delay
|
||||
(funcall indent-bars--highlight-current-depth)))
|
||||
(prog1 (apply fn args)
|
||||
(unless indent-bars-depth-update-delay
|
||||
(remove-hook 'post-command-hook #'indent-bars--highlight-current-depth t))))))
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; ui/indent-guides/packages.el
|
||||
|
||||
(package! highlight-indent-guides :pin "cf352c85cd15dd18aa096ba9d9ab9b7ab493e8f6")
|
||||
(package! indent-bars
|
||||
:recipe (:host github :repo "jdtsmith/indent-bars")
|
||||
:pin "c8376cf4373a6444ca88e88736db7576dedb51d6")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue