From dd5ae257f13a2fad44d967297634e8b24312136f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 10 Sep 2024 02:26:50 -0400 Subject: [PATCH] nit(indent-guides): reformat config.el & proofread comments --- modules/ui/indent-guides/config.el | 54 ++++++++++++++---------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/modules/ui/indent-guides/config.el b/modules/ui/indent-guides/config.el index 870216bc4..24c3c3733 100644 --- a/modules/ui/indent-guides/config.el +++ b/modules/ui/indent-guides/config.el @@ -27,8 +27,8 @@ be enabled. If any function returns non-nil, the mode will not be activated." ;; 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). + ;; FIX: A bitmap init bug in emacs-pgtk (before v30) could cause + ;; crashes (see jdtsmith/indent-bars#3). (and (featurep 'pgtk) (< emacs-major-version 30))) @@ -45,23 +45,6 @@ be enabled. If any function returns non-nil, the mode will not be activated." ;; TODO: Uncomment once we support treesit ;; (setq indent-bars-treesit-support (modulep! :tools tree-sitter)) - ;; HACK: Both indent-bars and tree-sitter-hl-mode use the jit-font-lock - ;; mechanism, and so they don't play well together. For those particular - ;; cases, we'll use `highlight-indent-guides', at least until the - ;; tree-sitter module adopts treesit. - (defvar-local +indent-guides-p nil) - (add-hook! 'tree-sitter-mode-hook :append - (defun +indent-guides--toggle-on-tree-sitter-h () - (if tree-sitter-mode - (when (bound-and-true-p indent-bars-mode) - (with-memoization (get 'indent-bars-mode 'disabled-in-tree-sitter) - (doom-log "Disabled `indent-bars-mode' because it's not supported in `tree-sitter-mode'") - t) - (indent-bars-mode -1) - (setq +indent-guides-p t)) - (when +indent-guides-p - (indent-bars-mode +1))))) - (unless (boundp 'enable-theme-functions) (add-hook 'doom-load-theme-hook #'indent-bars-reset-styles)) @@ -74,24 +57,20 @@ be enabled. If any function returns non-nil, the mode will not be activated." (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). + ;; Don't display indent guides in childframe popups (which are almost always + ;; used for 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: `indent-bars-mode' interactions with some packages poorly. This - ;; section is dedicated to package interop fixes. + ;; HACK: `indent-bars-mode' interactions with some packages poorly, often + ;; flooding whole sections of the buffer with indent guides. This section is + ;; dedicated to fixing interop with those packages. (when (modulep! :tools magit) (after! magit-blame (add-to-list 'magit-blame-disable-modes 'indent-bars-mode))) (when (modulep! :tools lsp) - ;; HACK: lsp-ui-peek uses overlays, and indent-bars doesn't know how to deal - ;; with all the whitespace it uses to format its popups, spamming it with - ;; indent guides. Making the two work together is a project for another - ;; day, so disable `indent-bars-mode' while its active instead. Doesn't - ;; affect character bars though. ;; REVIEW: Report this upstream to `indent-bars'? (defadvice! +indent-guides--remove-after-lsp-ui-peek-a (&rest _) :after #'lsp-ui-peek--peek-new @@ -107,4 +86,21 @@ be enabled. If any function returns non-nil, the mode will not be activated." (defadvice! +indent-guides--restore-after-lsp-ui-peek-a (&rest _) :after #'lsp-ui-peek--peek-hide (unless indent-bars-prefer-character - (indent-bars-setup))))) + (indent-bars-setup)))) + + ;; HACK: Both indent-bars and tree-sitter-hl-mode use the jit-font-lock + ;; mechanism, and so they don't play well together. For those particular + ;; cases, we'll use `highlight-indent-guides', at least until the + ;; tree-sitter module adopts treesit. + (defvar-local +indent-guides-p nil) + (add-hook! 'tree-sitter-mode-hook :append + (defun +indent-guides--toggle-on-tree-sitter-h () + (if tree-sitter-mode + (when (bound-and-true-p indent-bars-mode) + (with-memoization (get 'indent-bars-mode 'disabled-in-tree-sitter) + (doom-log "Disabled `indent-bars-mode' because it's not supported in `tree-sitter-mode'") + t) + (indent-bars-mode -1) + (setq +indent-guides-p t)) + (when +indent-guides-p + (indent-bars-mode +1))))))