Skip to content

Commit 3592c10

Browse files
committed
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.
1 parent b2b18aa commit 3592c10

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: rust-mode-treesitter.el

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
(require 'treesit)
1414
(require 'rust-ts-mode)
1515

16+
;; HACK: `rust-ts-mode' adds itself to the `auto-mode-alist'
17+
;; after us, so we need to readd `rust-mode' to the front of
18+
;; the list after loading `rust-ts-mode'.
19+
(setq auto-mode-alist (delete '("\\.rs\\'" . rust-mode) auto-mode-alist))
20+
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
21+
1622
(define-derived-mode rust-mode rust-ts-mode "Rust"
1723
"Major mode for Rust code.
1824

0 commit comments

Comments
 (0)