From 13c41c97993c01b109399d4e0bf78d15ee6a7f4d Mon Sep 17 00:00:00 2001 From: John Turner Date: Sun, 16 Jul 2023 23:38:07 -0400 Subject: [PATCH] setup ts modes in the treesit use-package expression python-ts-mode and bash-ts-mode are not packages or features, so we can't use them in a use-package expression. Since we can't create use-package expressions for them, just set up the requires variables in the treesit use-package expression. --- packages/treesit.el | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/packages/treesit.el b/packages/treesit.el index 00c383b..31e4c43 100644 --- a/packages/treesit.el +++ b/packages/treesit.el @@ -1,21 +1,18 @@ (use-package treesit - :if (>= emacs-major-version 29)) + :if (ignore-errors (treesit-available-p)) + :mode + ((rx (literal ".") "rs" eos) . rust-ts-mode) + ((rx (literal ".") "py" eos) . python-ts-mode) + ((rx (literal ".") "sh" eos) . bash-ts-mode) + :interpreter + (("python" "python3" "python2") . python-ts-mode) + (("bash" "sh" "openrc-run") . bash-ts-mode)) (use-package rust-ts-mode :requires treesit - :mode (rx (literal ".") "rs" eos) - :hook (rust-ts-mode . (lambda () - (when (featurep 'rust-mode) - (add-hook before-save-hook rust-before-save-method) - (add-hook after-save-hook rust-after-save-method) - (use-local-map (make-composed-keymap (list rust-ts-mode-map rust-mode-map))))))) - -(use-package python-ts-mode - :requires treesit - :mode (rx (literal ".") "py" eos) - :interpreter ("python" "python3" "python2")) - -(use-package bash-ts-mode - :requires treesit - :mode (rx (literal ".") "sh" eos) - :interpreter ("bash" "sh" "openrc-run")) + :hook + (rust-ts-mode . (lambda () + (when (featurep 'rust-mode) + (add-hook before-save-hook rust-before-save-method) + (add-hook after-save-hook rust-after-save-method) + (use-local-map (make-composed-keymap (list rust-ts-mode-map rust-mode-map)))))))