mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-05 12:37:33 -05:00
BREAKING CHANGE: This rewrites the :tools tree-sitter module to use treesit instead of tree-sitter.el. Users will need to adapt to treesit and remove any tree-sitter-specific config in their dotfiles. Ref: #7623 Ref: #7742 Ref: #8197
44 lines
1.8 KiB
EmacsLisp
44 lines
1.8 KiB
EmacsLisp
;;; tools/tree-sitter/autoload/compat-30.el -*- lexical-binding: t; -*-
|
|
;;;###if (and (fboundp 'treesit-available-p) (version< emacs-version "31.1"))
|
|
;;
|
|
;; Backported from 31.1
|
|
;;
|
|
;;; Code:
|
|
|
|
(autoload 'treesit-ready-p "treesit")
|
|
|
|
;;;###autoload
|
|
(defcustom treesit-auto-install-grammar 'ask
|
|
"Whether to install tree-sitter language grammar libraries when needed.
|
|
This controls whether Emacs will install missing grammar libraries
|
|
when they are needed by some tree-sitter based mode.
|
|
If `ask', ask for confirmation before installing the required grammar library.
|
|
If `always', install the grammar library without asking.
|
|
If nil or `never' or anything else, don't install the grammar library
|
|
even while visiting a file in the mode that requires such grammar; this
|
|
might display a warning and/or fail to turn on the mode."
|
|
:type '(choice (const :tag "Never install grammar libraries" never)
|
|
(const :tag "Always automatically install grammar libraries"
|
|
always)
|
|
(const :tag "Ask whether to install missing grammar libraries"
|
|
ask))
|
|
:version "31.1"
|
|
:group 'treesit)
|
|
|
|
;;;###autoload
|
|
(defun treesit-ensure-installed (lang)
|
|
"Ensure that the grammar library for the language LANG is installed.
|
|
The option `treesit-auto-install-grammar' defines whether to install
|
|
the grammar library if it's unavailable."
|
|
(or (treesit-ready-p lang t)
|
|
(when (or (eq treesit-auto-install-grammar 'always)
|
|
(and (eq treesit-auto-install-grammar 'ask)
|
|
(y-or-n-p (format "\
|
|
Tree-sitter grammar for `%s' is missing; install it?"
|
|
lang))))
|
|
(treesit-install-language-grammar lang)
|
|
;; Check that the grammar was installed successfully
|
|
(treesit-ready-p lang))))
|
|
|
|
;;; compat-30.el ends here
|