From 8ac83f4600963b74bd8cbd5091df2b56ecfc0f20 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 15 May 2025 14:15:50 +0200 Subject: [PATCH] fix(indent-guides): treesit support --- modules/ui/indent-guides/config.el | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/modules/ui/indent-guides/config.el b/modules/ui/indent-guides/config.el index 898920d5f..b60191a9c 100644 --- a/modules/ui/indent-guides/config.el +++ b/modules/ui/indent-guides/config.el @@ -21,7 +21,8 @@ be enabled. If any function returns non-nil, the mode will not be activated." (unless (run-hook-with-args-until-success '+indent-guides-inhibit-functions) (indent-bars-mode +1))) :config - (setq indent-bars-prefer-character + (setq indent-bars-treesit-support (modulep! :tools tree-sitter) + 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 @@ -42,9 +43,6 @@ be enabled. If any function returns non-nil, the mode will not be activated." ;; 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)) - ;; indent-bars adds this to `enable-theme-functions', which was introduced in ;; 29.1, which will be redundant with `doom-load-theme-hook'. (unless (boundp 'enable-theme-functions) @@ -105,21 +103,4 @@ 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)))) - - ;; 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)))))) + (indent-bars-setup)))))