From 7c750343be6309a78d3fd289959bca241d9daf5d Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Fri, 21 Oct 2022 18:50:24 -0700 Subject: [PATCH] * lisp/treesit.el (treesit-font-lock-enable): Add function back. --- lisp/treesit.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lisp/treesit.el b/lisp/treesit.el index 136b756badd..3096a21f6fe 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -508,6 +508,18 @@ If LOUDLY is non-nil, message some debugging information." (let ((font-lock-unfontify-region-function #'ignore)) (funcall #'font-lock-default-fontify-region start end loudly))) +(defun treesit-font-lock-enable () + "Enable tree-sitter font-locking for the current buffer." + (treesit-font-lock-recompute-features) + (setq-local font-lock-fontify-region-function + #'treesit-font-lock-fontify-region) + ;; If we don't set `font-lock-defaults' to some non-nil value, + ;; font-lock doesn't enable properly (`font-lock-mode-internal' + ;; doesn't run). See `font-lock-specified-p'. + (when (null font-lock-defaults) + (setq font-lock-defaults '(nil))) + (font-lock-mode 1)) + ;;; Indent (defvar treesit--indent-verbose nil -- 2.39.2