mirror of
https://github.com/doomemacs/doomemacs
synced 2025-09-16 15:56:52 -05:00
fix: backport treesit-available-p sooner
This fixes Doom for Emacs 27-28 users (or builds without treesit).
This commit is contained in:
@@ -132,6 +132,25 @@ The functions in the hook are called with one parameter -- the
|
|||||||
(funcall fn theme)
|
(funcall fn theme)
|
||||||
(run-hook-with-args 'enable-theme-functions theme))))
|
(run-hook-with-args 'enable-theme-functions theme))))
|
||||||
|
|
||||||
|
;; Introduced in 29.1
|
||||||
|
;; In case of Emacs builds where treesit isn't built in (to avoid void-function
|
||||||
|
;; errors and verbose, redundant checks everywhere).
|
||||||
|
;;;###autodef
|
||||||
|
(unless (fboundp 'treesit-available-p)
|
||||||
|
(defun treesit-available-p ()
|
||||||
|
"Return non-nil if tree-sitter support is built-in and available."
|
||||||
|
nil))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(unless (fboundp 'treesit-library-abi-version)
|
||||||
|
(defun treesit-library-abi-version (&optional _min-compatible)
|
||||||
|
0))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(unless (fboundp 'treesit-language-abi-version)
|
||||||
|
(defun treesit-language-abi-version (&optional _lang)
|
||||||
|
nil))
|
||||||
|
|
||||||
|
|
||||||
;;; From Emacs >= 30
|
;;; From Emacs >= 30
|
||||||
;; Introduced in 30.1
|
;; Introduced in 30.1
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
;;; tools/tree-sitter/autoload/compat-30.el -*- lexical-binding: t; -*-
|
;;; tools/tree-sitter/autoload/compat-30.el -*- lexical-binding: t; -*-
|
||||||
;;;###if (and (fboundp 'treesit-available-p) (version< emacs-version "31.1"))
|
;;;###if (and (treesit-available-p) (version< emacs-version "31.1"))
|
||||||
;;
|
;;
|
||||||
;; Backported from 31.1
|
;; Backported from 31.1
|
||||||
;;
|
;;
|
||||||
@@ -7,24 +7,6 @@
|
|||||||
|
|
||||||
(autoload 'treesit-ready-p "treesit")
|
(autoload 'treesit-ready-p "treesit")
|
||||||
|
|
||||||
;; In case of Emacs builds where treesit isn't built in (to avoid void-function
|
|
||||||
;; errors and verbose, redundant checks everywhere).
|
|
||||||
;;;###autodef
|
|
||||||
(unless (fboundp 'treesit-available-p)
|
|
||||||
(defun treesit-available-p ()
|
|
||||||
"Return non-nil if tree-sitter support is built-in and available."
|
|
||||||
nil))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(unless (fboundp 'treesit-library-abi-version)
|
|
||||||
(defun treesit-library-abi-version (&optional _min-compatible)
|
|
||||||
0))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(unless (fboundp 'treesit-language-abi-version)
|
|
||||||
(defun treesit-language-abi-version (&optional _lang)
|
|
||||||
nil))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defcustom treesit-auto-install-grammar 'ask
|
(defcustom treesit-auto-install-grammar 'ask
|
||||||
"Whether to install tree-sitter language grammar libraries when needed.
|
"Whether to install tree-sitter language grammar libraries when needed.
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
;;; Packages
|
;;; Packages
|
||||||
|
|
||||||
(use-package! treesit
|
(use-package! treesit
|
||||||
:when (fboundp 'treesit-available-p)
|
|
||||||
:when (treesit-available-p)
|
:when (treesit-available-p)
|
||||||
:defer t
|
:defer t
|
||||||
:preface
|
:preface
|
||||||
@@ -48,8 +47,7 @@
|
|||||||
(let ((mode (funcall fn mode)))
|
(let ((mode (funcall fn mode)))
|
||||||
(if-let* ((ts (get mode '+tree-sitter))
|
(if-let* ((ts (get mode '+tree-sitter))
|
||||||
(fallback-mode (car ts)))
|
(fallback-mode (car ts)))
|
||||||
(cond ((or (not (fboundp 'treesit-available-p))
|
(cond ((not (treesit-available-p))
|
||||||
(not (treesit-available-p)))
|
|
||||||
(message "Treesit unavailable, falling back to `%S'" fallback-mode)
|
(message "Treesit unavailable, falling back to `%S'" fallback-mode)
|
||||||
fallback-mode)
|
fallback-mode)
|
||||||
((not (fboundp mode))
|
((not (fboundp mode))
|
||||||
|
@@ -5,6 +5,5 @@
|
|||||||
|
|
||||||
(if (version< emacs-version "29.1")
|
(if (version< emacs-version "29.1")
|
||||||
(error! "Emacs 29.1 or newer is required for tree-sitter support")
|
(error! "Emacs 29.1 or newer is required for tree-sitter support")
|
||||||
(unless (and (fboundp 'treesit-available-p)
|
(unless (treesit-available-p)
|
||||||
(treesit-available-p))
|
|
||||||
(error! "Emacs not built with tree-sitter support!")))
|
(error! "Emacs not built with tree-sitter support!")))
|
||||||
|
Reference in New Issue
Block a user