summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDev380 <49997896+Dev380@users.noreply.github.com>2024-04-13 14:12:25 -0400
committerDev380 <49997896+Dev380@users.noreply.github.com>2024-04-13 14:12:25 -0400
commit3592c10cc1f5d4b5b005961202738b530d9635cf (patch)
treea1770b7acd09bf4fbf8d0960596c7ed89bd3ed4f
parentb2b18aa6c135d9b06242b3d081d94fe0c0cb8e86 (diff)
downloadrust-mode-3592c10cc1f5d4b5b005961202738b530d9635cf.tar.gz
fix(treesit): auto mode precedence of rust-mode
Currently, `rust-ts-mode` will add itself to the `auto-mode-alist` when it is loaded, which is after the autoload for adding `rust-mode`. We need to re-add `rust-mode` after loading the treesitter package to make sure this mode has higher priority.
-rw-r--r--rust-mode-treesitter.el6
1 files changed, 6 insertions, 0 deletions
diff --git a/rust-mode-treesitter.el b/rust-mode-treesitter.el
index 21eab59..5f84a00 100644
--- a/rust-mode-treesitter.el
+++ b/rust-mode-treesitter.el
@@ -13,6 +13,12 @@
(require 'treesit)
(require 'rust-ts-mode)
+ ;; HACK: `rust-ts-mode' adds itself to the `auto-mode-alist'
+ ;; after us, so we need to readd `rust-mode' to the front of
+ ;; the list after loading `rust-ts-mode'.
+ (setq auto-mode-alist (delete '("\\.rs\\'" . rust-mode) auto-mode-alist))
+ (add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
+
(define-derived-mode rust-mode rust-ts-mode "Rust"
"Major mode for Rust code.