renzmann / treesit-auto

Automatic installation, usage, and fallback for tree-sitter major modes in Emacs 29
GNU General Public License v3.0
369 stars 28 forks source link

`treesit-auto-install-all` keeps asking about recipes. #38

Closed abougouffa closed 1 year ago

abougouffa commented 1 year ago

Hello,

I'm using treesit-auto as follows:

(use-package treesit-auto
  :straight (:host github :repo "renzmann/treesit-auto")
  :after treesit
  :demand t
  :custom
  (treesit-auto-install 'prompt)
  :config
  (setq ;; Auto install all supported languages
   treesit-auto-langs
   (cl-loop for recipe in treesit-auto-recipe-list
            collect (treesit-auto-recipe-lang recipe)))
 (global-treesit-auto-mode 1))

I like to install all the grammars ahead of time, so I call treesit-auto-install-all. However, when invoking it, it keeps saying:

Screenshot_20230318_173552

The problem comes from treesit-language-source-alist, which is set to nil globally and only modified locally in treesit-auto--on. This hack fixes the issue:

(setq treesit-language-source-alist (treesit-auto--build-treesit-source-alist))

;; OR THIS ONE

(advice-add
 'treesit-auto-install-all :before
 (lambda ()
   (setq-local treesit-language-source-alist
               (treesit-auto--build-treesit-source-alist))))