diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-12-12 22:39:04 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-12-12 22:39:04 +0100 |
commit | 511c6e2b7a5c3a9dcf84764e3ae94ecc0457c5e9 (patch) | |
tree | 727a04b54d291df22a8724395e6fc45042b256f3 | |
parent | fa8512aa5fcd8b4d9af12fecfde0d790606c0502 (diff) |
-rw-r--r-- | .config/emacs/modules/mm-treesit.el | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/.config/emacs/modules/mm-treesit.el b/.config/emacs/modules/mm-treesit.el index f939df6..a41f52c 100644 --- a/.config/emacs/modules/mm-treesit.el +++ b/.config/emacs/modules/mm-treesit.el @@ -34,32 +34,23 @@ ;;; Install Missing Parsers -(defun mm-treesit-sync-sources () - "Sync Tree-Sitter parsers. -Reinstall the Tree-Sitter parsers specified by - `treesit-language-source-alist'." +(defun mm-treesit-install-all () + "Install all Tree-Sitter parsers. +This is like `mm-treesit-install-missing' but also reinstalls parsers +that are already installed." (interactive) - (let ((total (length treesit-language-source-alist)) - (count 0) - (work treesit-language-source-alist) - (processors-to-use (max 1 (1- (num-processors))))) - (while work - (let ((specs (seq-take work processors-to-use))) - (dolist (spec specs) - (async-start - `(lambda () - ,(async-inject-variables "\\`treesit-language-source-alist\\'") - (treesit-install-language-grammar ',(car spec))) - (lambda (_) - (setq count (1+ count)) - (message "Done syncing Tree-Sitter grammar for `%s' [%d/%d]" - (car spec) count total)))) - (setq work (seq-drop work processors-to-use)))))) - -(thread-last - (mapcar #'car treesit-language-source-alist) - (seq-remove #'treesit-language-available-p) - (mapc #'treesit-install-language-grammar)) + (cl-loop for (lang) in treesit-language-source-alist + do (treesit-install-language-grammar lang))) + +(defun mm-treesit-install-missing () + "Install missing Tree-Sitter parsers. +The parsers are taken from `treesit-language-source-alist'." + (interactive) + (cl-loop for (lang) in treesit-language-source-alist + unless (treesit-language-available-p lang) + do (treesit-install-language-grammar lang))) + +(mm-treesit-install-missing) ;;; Install Additional TS Modes |