Archived
1
0
Fork 0
This repository has been archived on 2024-10-19. You can view files and clone it, but cannot push or open issues or pull requests.
emacs/code/elpa/rust-mode-20240520.749/rust-mode-treesitter.el

33 lines
1,022 B
EmacsLisp
Raw Normal View History

2024-07-28 16:03:37 +00:00
;;; rust-mode-treesitter.el --- use native rust-ts-mode -*-lexical-binding: t-*-
;;; Commentary:
;; Derive from rust-ts-mode instead of prog-mode
;;; Code:
(require 'rust-mode)
;; Do not compile or load on Emacs releases that don't support
;; this. See https://github.com/rust-lang/rust-mode/issues/520.
(when (version<= "29.1" emacs-version)
(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.
\\{rust-mode-map}"
:group 'rust-mode
(add-hook 'before-save-hook rust-before-save-hook nil t)
(add-hook 'after-save-hook rust-after-save-hook nil t)))
(provide 'rust-mode-treesitter)
;;; rust-mode-treesitter.el ends here