Sped up my startup by not cloning all the treesitter mods
Spent more than a minute of my Emacs start time on Tree Sitter, as I would clone _all_ the grammars each time. Now, I need to call my install function with a `force` if I want to update them. Also, I no longer need the `sit-for` entry that I forgot about.
This commit is contained in:
parent
d33044dbed
commit
22f44e8b9f
1 changed files with 12 additions and 5 deletions
|
|
@ -450,6 +450,7 @@ Note that Emacs already has the ability to download and install grammars, so fol
|
||||||
;; (julia "https://github.com/tree-sitter/tree-sitter-julia" "master" "src")
|
;; (julia "https://github.com/tree-sitter/tree-sitter-julia" "master" "src")
|
||||||
;; (lua "https://github.com/MunifTanjim/tree-sitter-lua" "main" "src")
|
;; (lua "https://github.com/MunifTanjim/tree-sitter-lua" "main" "src")
|
||||||
(make "https://github.com/alemuller/tree-sitter-make")
|
(make "https://github.com/alemuller/tree-sitter-make")
|
||||||
|
(mermaid "https://github.com/monaqa/tree-sitter-mermaid")
|
||||||
;; (markdown "https://github.com/ikatyang/tree-sitter-markdown")
|
;; (markdown "https://github.com/ikatyang/tree-sitter-markdown")
|
||||||
;; (meson "https://github.com/Decodetalkers/tree-sitter-meson" "master" "src")
|
;; (meson "https://github.com/Decodetalkers/tree-sitter-meson" "master" "src")
|
||||||
;; (python "https://github.com/tree-sitter/tree-sitter-python")
|
;; (python "https://github.com/tree-sitter/tree-sitter-python")
|
||||||
|
|
@ -460,11 +461,17 @@ Note that Emacs already has the ability to download and install grammars, so fol
|
||||||
;; (typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src")
|
;; (typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src")
|
||||||
(yaml "https://github.com/tree-sitter-grammars/tree-sitter-yaml")))
|
(yaml "https://github.com/tree-sitter-grammars/tree-sitter-yaml")))
|
||||||
|
|
||||||
(defun mp-setup-install-grammars ()
|
(defun mp-setup-install-grammars (&optional force)
|
||||||
"Install Tree-sitter grammars if they are absent."
|
"Install Tree-sitter grammars if they are absent.
|
||||||
(interactive)
|
Each grammar in `treesit-language-source-alist' is only cloned and
|
||||||
(sit-for 30)
|
compiled when `treesit-language-available-p' says it is missing, as
|
||||||
(mapc #'treesit-install-language-grammar (mapcar #'car treesit-language-source-alist)))
|
installing one takes a second or two. With a prefix argument, FORCE
|
||||||
|
reinstalls every grammar, which is how we pick up upstream changes."
|
||||||
|
(interactive "P")
|
||||||
|
(dolist (lang (mapcar #'car treesit-language-source-alist))
|
||||||
|
(when (or force (not (treesit-language-available-p lang)))
|
||||||
|
(message "Installing Tree-sitter grammar for `%s' ..." lang)
|
||||||
|
(treesit-install-language-grammar lang))))
|
||||||
|
|
||||||
;; Optional, but Mickey recommends. Tree-sitter enabled major
|
;; Optional, but Mickey recommends. Tree-sitter enabled major
|
||||||
;; modes are distinct from their ordinary counterparts, however,
|
;; modes are distinct from their ordinary counterparts, however,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue