fix(tree-sitter): arity error installing grammars on <=29

This commit is contained in:
Henrik Lissner 2025-12-03 03:58:30 -05:00
parent fd643d78a8
commit 0d2f10dcab
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -99,15 +99,19 @@
mode))) mode)))
:config :config
;; HACK: Keep $EMACSDIR clean by installing grammars to the active profile. ;; HACK: Keep $EMACSDIR clean by installing grammars to central location (the
(add-to-list 'treesit-extra-load-path (file-name-concat doom-profile-data-dir "tree-sitter")) ;; active profile).
(defadvice! +tree-sitter--install-grammar-to-local-dir-a (fn lang &optional outdir &rest args) (let ((data-dir (file-name-concat doom-profile-data-dir "tree-sitter")))
"Write grammars to `doom-profile-data-dir' instead." (add-to-list 'treesit-extra-load-path data-dir)
;; Treesit's API saw major changes in 30.x.
(if (< emacs-major-version 30)
(defadvice! +tree-sitter--install-grammar-to-local-dir-a (fn out-dir &rest args)
:around #'treesit--install-language-grammar-1
(apply fn (or out-dir data-dir) args))
(defadvice! +tree-sitter--install-grammar-to-local-dir-a (fn lang &optional out-dir &rest args)
:around #'treesit-install-language-grammar :around #'treesit-install-language-grammar
:around #'treesit--build-grammar :around #'treesit--build-grammar
(apply fn lang (apply fn lang (or out-dir data-dir) args))))
(or outdir (file-name-concat doom-profile-data-dir "tree-sitter"))
args))
;; TODO: Move most of these out to modules ;; TODO: Move most of these out to modules
(dolist (map '((awk "https://github.com/Beaglefoot/tree-sitter-awk" nil nil nil nil) (dolist (map '((awk "https://github.com/Beaglefoot/tree-sitter-awk" nil nil nil nil)