Skip to content

eval-exec/rust-mode

 
 

Repository files navigation

MELPA

Emacs mode for editing Rust source code

Table of Contents

Installation via MELPA

rust-mode makes editing Rust code with Emacs enjoyable. It requires Emacs 24 or later. The package is available on MELPA. Add this to your init.el.

(require 'package)
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(package-refresh-contents)

Now you can install rust-mode with:

M-x package-install rust-mode

And put this in your config to load rust-mode automatically:

(require 'rust-mode)

Manual Installation

Add this to your init.el:

(add-to-list 'load-path "/path/to/rust-mode/")
(autoload 'rust-mode "rust-mode" nil t)

Indentation

The Rust style guide recommends spaces for indentation; to follow the recommendation add this to your init.el:

(add-hook 'rust-mode-hook
          (lambda () (setq indent-tabs-mode nil)))

rustfmt

The rust-format-buffer function will format your code with rustfmt if installed. By default, this is bound to C-c C-f.

Placing (setq rust-format-on-save t) in your init.el will enable automatic running of rust-format-buffer when you save a buffer.

Tests

The file rust-mode-tests.el contains tests that can be run via ERT. You can use run_rust_emacs_tests.sh to run them in batch mode, if you set the environment variable EMACS to a program that runs emacs.

Other useful packages

  • cargo.el Emacs Minor Mode for Cargo, Rust's Package Manager
  • emacs-racer Racer support for Emacs
  • rustic Rust development environment for Emacs

About

Emacs configuration for Rust

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Emacs Lisp 99.0%
  • Other 1.0%