fix(indent-guides): treesit support

This commit is contained in:
Henrik Lissner
2025-05-15 14:15:50 +02:00
parent 1670ce2767
commit 8ac83f4600

View File

@ -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)))))