From af814ff86a3961d38e1fc741fa840461ded4bd82 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 8 Sep 2024 17:48:39 -0400 Subject: [PATCH] fix(indent-guides): interop with lsp-ui-peek Ref: #8052 --- modules/ui/indent-guides/config.el | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/ui/indent-guides/config.el b/modules/ui/indent-guides/config.el index fc527baba..c835abb9a 100644 --- a/modules/ui/indent-guides/config.el +++ b/modules/ui/indent-guides/config.el @@ -60,4 +60,27 @@ be enabled. If any function returns non-nil, the mode will not be activated." ;; 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)))) + (frame-parameter nil 'parent-frame))) + + (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 + (when (and indent-bars-mode + (not indent-bars-prefer-character) + (overlayp lsp-ui-peek--overlay)) + (save-excursion + (let ((indent-bars--display-function #'ignore) + (indent-bars--display-blank-lines-function #'ignore)) + (indent-bars--fontify (overlay-start lsp-ui-peek--overlay) + (1+ (overlay-end lsp-ui-peek--overlay)) + nil))))) + (defadvice! +indent-guides--restore-after-lsp-ui-peek-a (&rest _) + :after #'lsp-ui-peek--peek-hide + (unless indent-bars-prefer-character + (indent-bars-setup)))))