Function: rust-ts-mode
rust-ts-mode is an autoloaded, interactive and byte-compiled function
defined in rust-ts-mode.el.gz.
Signature
(rust-ts-mode)
Documentation
Major mode for editing Rust, powered by tree-sitter.
In addition to any hooks its parent mode prog-mode might have run,
this mode runs the hook rust-ts-mode-hook, as the final or
penultimate step during initialization.
Probably introduced at or before Emacs version 29.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/rust-ts-mode.el.gz
;;;###autoload
(define-derived-mode rust-ts-mode prog-mode "Rust"
"Major mode for editing Rust, powered by tree-sitter."
:group 'rust
:syntax-table rust-ts-mode--syntax-table
(when (treesit-ready-p 'rust)
(treesit-parser-create 'rust)
;; Syntax.
(setq-local syntax-propertize-function
#'rust-ts-mode--syntax-propertize)
;; Comments.
(c-ts-common-comment-setup)
;; Font-lock.
(setq-local treesit-font-lock-settings rust-ts-mode--font-lock-settings)
(setq-local treesit-font-lock-feature-list
'(( comment definition)
( keyword string)
( assignment attribute builtin constant escape-sequence
number type)
( bracket delimiter error function operator property variable)))
;; Imenu.
(setq-local treesit-simple-imenu-settings
`(("Module" "\\`mod_item\\'" nil nil)
("Enum" "\\`enum_item\\'" nil nil)
("Impl" "\\`impl_item\\'" nil nil)
("Type" "\\`type_item\\'" nil nil)
("Struct" "\\`struct_item\\'" nil nil)
("Fn" "\\`function_item\\'" nil nil)))
;; Indent.
(setq-local indent-tabs-mode nil
treesit-simple-indent-rules rust-ts-mode--indent-rules)
;; Electric
(setq-local electric-indent-chars
(append "{}():;,#" electric-indent-chars))
;; Navigation.
(setq-local treesit-defun-type-regexp
(regexp-opt '("enum_item"
"function_item"
"impl_item"
"struct_item")))
(setq-local treesit-defun-name-function #'rust-ts-mode--defun-name)
(treesit-major-mode-setup)))