Skip to content

Commit

Permalink
enable/disable advising treesit-install-language-grammar through gl…
Browse files Browse the repository at this point in the history
…obal mode
  • Loading branch information
renzmann committed Jan 31, 2023
1 parent 12f6991 commit 015880f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion treesit-auto.el
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ the grammar it will then re-enable the current major-mode."
(add-to-list 'treesit-language-source-alist elt t))
(mapcar #'treesit-auto--remap-language-source treesit-language-source-alist))

(defun treesit-auto--install-language-grammar-wrapper (&rest _r)
"Run `treesit-auto-apply-remap' after `treesit-install-language-grammar'."
(treesit-auto-apply-remap))

;;;###autoload
(define-minor-mode global-treesit-auto-mode
"Toggle `global-treesit-auto-mode'."
Expand All @@ -179,8 +183,11 @@ the grammar it will then re-enable the current major-mode."
(if global-treesit-auto-mode
(progn
(add-hook 'prog-mode-hook #'treesit-auto--maybe-install-grammar)
(advice-add 'treesit-install-language-grammar
:after #'treesit-auto--install-language-grammar-wrapper)
(treesit-auto-apply-remap))
(remove-hook 'prog-mode-hook #'treesit-auto--maybe-install-grammar)))
(remove-hook 'prog-mode-hook #'treesit-auto--maybe-install-grammar)
(advice-remove 'treesit-install-language-grammar #'treesit-auto--install-language-grammar-wrapper)))

(provide 'treesit-auto)
;;; treesit-auto.el ends here

0 comments on commit 015880f

Please sign in to comment.