Skip to content

Emacs Minor Mode for Cargo, Rust's Package Manager.

License

Notifications You must be signed in to change notification settings

matklad/cargo.el

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 

Repository files navigation

cargo.el

Cargo mode for Emacs. This package gives you a set of key combinations to perform Cargo tasks within your Rust projects.

Installation

This package can be installed through melpa:

M-x package-install cargo

Usage

Add cargo-minor-mode to your rust-mode-hook

(add-hook 'rust-mode-hook 'cargo-minor-mode)

You will now have the following key combinations at your disposal:

Keybinding Command
C-c C-c C-e cargo-process-bench
C-c C-c C-b cargo-process-build
C-c C-c C-l cargo-process-clean
C-c C-c C-d cargo-process-doc
C-c C-c C-v cargo-process-doc-open
C-c C-c C-n cargo-process-new
C-c C-c C-i cargo-process-init
C-c C-c C-r cargo-process-run
C-c C-c C-x cargo-process-run-example
C-c C-c C-s cargo-process-search
C-c C-c C-t cargo-process-test
C-c C-c C-u cargo-process-update
C-c C-c C-c cargo-process-repeat
C-c C-c C-f cargo-process-current-test
C-c C-c C-o cargo-process-current-file-tests
C-c C-c C-m cargo-process-fmt
C-c C-c C-k cargo-process-check
C-c C-c C-S-k cargo-process-clippy

Before executing the task, Emacs will prompt you to save any modified buffers associated with the current Cargo project. Setting compilation-ask-about-save to nil makes Emacs save modified buffers without asking.

Variables

Commands can be adjusted by changing their command variable. Here's a list of commands and their default value.

(setq cargo-process--command-bench "cargo bench")
(setq cargo-process--command-build "cargo build")
(setq cargo-process--command-clean "cargo clean")
(setq cargo-process--command-doc "cargo doc")
(setq cargo-process--command-doc-open "cargo doc --open")
(setq cargo-process--command-new "cargo new")
(setq cargo-process--command-init "cargo init")
(setq cargo-process--command-run "cargo run")
(setq cargo-process--command-run-bin "cargo run --bin")
(setq cargo-process--command-run-example "cargo run --example")
(setq cargo-process--command-search "cargo search")
(setq cargo-process--command-test "cargo test")
(setq cargo-process--command-current-test "cargo test")
(setq cargo-process--command-current-file-tests "cargo test")
(setq cargo-process--command-update "cargo update")
(setq cargo-process--command-fmt "cargo fmt")
(setq cargo-process--command-check "cargo check")
(setq cargo-process--command-clippy "cargo clippy")

Advanced usage

If you invoke the prefix argument C-u before calling any of the functions, you may edit the Cargo command before it is run. This allows you to add flags like --release, for example.

Processes run via Cargo mode make use of compilation mode. This mode provides features like jumping to errors or killing runaway processes.

Notes

In order to run cargo-process-fmt you need to have the rustfmt package installed.

cargo install rustfmt

In order to run cargo-process-check you need to have the cargo-check package installed.

cargo install cargo-check

In order to run cargo-process-clippy you need to have the clippy package installed.

cargo install clippy

About

Emacs Minor Mode for Cargo, Rust's Package Manager.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Emacs Lisp 100.0%