mirror of
https://github.com/doomemacs/doomemacs.git
synced 2025-12-06 02:30:33 -08:00
fix(tree-sitter): suppress "Can't find grammar" warnings
In Emacs <=30, top-level `treesit-ready-p` calls in various *-ts-mode packages (like lua-ts-mode or ruby-ts-mode) are commonplace, and they throw up a warning popup if the grammar isn't available at load time. This is intrusive. Instead, this forces it to log to *Messages* instead before falling back to the normal major mode. Fortunately, these top-level `treesit-ready-p` calls have been removed in most *-ts-mode packages in 31+, but this still impacts users on <=30 or using third party *-ts-modes that haven't adapted. However, this doesn't suppress the warning when opening a *-ts-mode.el file (thanks to the byte-compiler).
This commit is contained in:
parent
86b6ba81ac
commit
94a1fe64a8
1 changed files with 6 additions and 1 deletions
|
|
@ -51,7 +51,12 @@
|
||||||
(memq fallback-mode treesit-enabled-modes))
|
(memq fallback-mode treesit-enabled-modes))
|
||||||
;; Lazily load autoloaded `treesit-language-source-alist'
|
;; Lazily load autoloaded `treesit-language-source-alist'
|
||||||
;; entries.
|
;; entries.
|
||||||
(let ((fn (symbol-function mode)))
|
(let ((fn (symbol-function mode))
|
||||||
|
;; Silence "can't find grammar" warning popups from
|
||||||
|
;; `treesit-ready-p' calls in Emacs <=30.1. We'll
|
||||||
|
;; log it to *Messages* instead.
|
||||||
|
(warning-suppress-types
|
||||||
|
(cons '(treesit) warning-suppress-types)))
|
||||||
(or (not (autoloadp fn))
|
(or (not (autoloadp fn))
|
||||||
(autoload-do-load fn mode)))
|
(autoload-do-load fn mode)))
|
||||||
;; Only prompt once, and log other times.
|
;; Only prompt once, and log other times.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue