From 2e05ad6eb7d5edfecae41de4b33da193c8c9f078 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Sat, 20 Apr 2024 13:48:30 -0700 Subject: [PATCH] Add my/treesit-compile-all --- init.el | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/init.el b/init.el index 53e615d..b2658c9 100644 --- a/init.el +++ b/init.el @@ -128,7 +128,7 @@ (css "https://github.com/tree-sitter/tree-sitter-css") (go "https://github.com/tree-sitter/tree-sitter-go") (gomod "https://github.com/camdencheek/tree-sitter-go-mod") - (js "https://github.com/tree-sitter/tree-sitter-javascript") + (javascript "https://github.com/tree-sitter/tree-sitter-javascript") (bash "https://github.com/tree-sitter/tree-sitter-bash") (cmake "https://github.com/uyha/tree-sitter-cmake") (blueprint "https://github.com/huanie/tree-sitter-blueprint"))) @@ -144,7 +144,19 @@ (yaml-mode . yaml-ts-mode) (css-mode . css-ts-mode) (js-mode . js-ts-mode) - (cmake-mode . cmake-ts-mode)))) + (cmake-mode . cmake-ts-mode))) + (defun my/treesit-compile-all (force) + "Compile all the modules defined in `treesit-language-source-alist'. +If FORCE, recompile all modules, even ones that are already compiled. +Interactively, force the recompile if called with a prefix." + (interactive "P") + (let ((did-build nil)) + (dolist (lang treesit-language-source-alist) + (when (or force (not (treesit-language-available-p (car lang)))) + (treesit-install-language-grammar (car lang)) + (setq did-build t))) + (unless did-build + (message "All defined parsers installed!"))))) (use-package tab-bar :ensure nil