feat(tree-sitter): add +tree-sitter/doctor command

For a quick diagnosis of the state of tree-sitter support in the current
buffer.
This commit is contained in:
Henrik Lissner
2025-09-16 16:57:27 -04:00
parent 5614faca7a
commit 4a6f9f741d
2 changed files with 12 additions and 1 deletions

View File

@@ -75,6 +75,9 @@ requires two additional steps:
version constraints; newer versions of some grammars may not work with older
versions of Emacs).
To test whether tree-sitter is functioning in the current buffer, execute ~M-x
+tree-sitter/doctor~.
* TODO Usage
#+begin_quote
󱌣 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]]

View File

@@ -69,6 +69,14 @@ pre-Emacs 31."
(let (auto-mode-alist interpreter-mode-alist)
(apply fn args)))
;;; TODO: Backwards compatibility
;;;###autoload
(defun +tree-sitter/doctor ()
"Test if the current buffer is correctly tree-sitter-enabled."
(interactive)
(unless (treesit-available-p)
(user-error "This Emacs install wasn't built with treesit support!"))
(unless (treesit-parser-list)
(user-error "No tree-sitter parsers are active in this buffer; are the grammars properly installed?"))
(message "Tree-sitter is functioning in this buffer!"))
;;; tree-sitter.el ends here