Skip to content

Commit b4b79e7

Browse files
committed
clojure-ts--ensure-grammars: prefer looping over grammar recipes
instead of manually typing each out. should be more future proof if we decide to pull in more. See suggestion 9af0a6b#r126929527
1 parent 61fc513 commit b4b79e7

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

clojure-ts-mode.el

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -828,16 +828,16 @@ forms like deftype, defrecord, reify, proxy, etc."
828828
(defun clojure-ts--ensure-grammars ()
829829
"Install required language grammars if not already available."
830830
(when clojure-ts-ensure-grammars
831-
;; `treesit-language-source-alist' is dynamically scoped.
832-
;; Setting it here allows `treesit-install-language-gramamr' to pick up
833-
;; the grammar recipes we want without modifying what the user has set.
834-
(let ((treesit-language-source-alist clojure-ts-grammar-recipes))
835-
(unless (treesit-language-available-p 'clojure nil)
836-
(message "Installing clojure tree-sitter grammar.")
837-
(treesit-install-language-grammar 'clojure))
838-
(unless (treesit-language-available-p 'markdown_inline nil)
839-
(message "Installing markdown tree-sitter grammar.")
840-
(treesit-install-language-grammar 'markdown_inline)))))
831+
(dolist (recipe clojure-ts-grammar-recipes)
832+
(let ((grammar (car recipe)))
833+
(unless (treesit-language-available-p grammar nil)
834+
(message "Installing %s tree-sitter grammar" grammar)
835+
;; `treesit-language-source-alist' is dynamically scoped.
836+
;; Binding it in this let expression allows
837+
;; `treesit-install-language-gramamr' to pick up the grammar recipes
838+
;; without modifying what the user has configured themselves.
839+
(let ((treesit-language-source-alist clojure-ts-grammar-recipes))
840+
(treesit-install-language-grammar grammar)))))))
841841

842842
(defun clojure-ts-mode-variables (&optional markdown-available)
843843
"Set up initial buffer-local variables for clojure-ts-mode.

0 commit comments

Comments
 (0)