emacs.d/modules/jenga-rust.el

31 lines
1.1 KiB
EmacsLisp

;;;; Rust mode configuration.
;; Add rust load hooks.
(require 'jenga-functions)
(instl 'rust-mode)
(instl 'racer)
(add-hook 'rust-mode-hook #'racer-mode)
(add-hook 'racer-mode-hook #'eldoc-mode)
(add-hook 'racer-mode-hook #'company-mode)
(add-hook 'rust-mode-hook 'cargo-minor-mode)
;; Turn on Rust mode with *.rs files.
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
;; Auto-format with rustfmt on save.
(setq rust-format-on-save t)
;; Show company auto-complete list on *.rs files by pressing TAB.
(define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common)
;; Use M-. keybinding to follow tag.
(define-key rust-mode-map (kbd "M-.") 'racer-find-definition)
;; Use M-h keybinding to open symbol documentation.
(define-key rust-mode-map (kbd "M-h") 'racer-describe)
;; Use C-c C-c keybinding to compile with `cargo build`.
(define-key rust-mode-map (kbd "C-c C-b") 'cargo-process-build)
;; Use C-c C-r keybinding to run with `cargo run`.
(define-key rust-mode-map (kbd "C-c C-r") 'cargo-process-run)
;; Use C-c C-t keybinding to test with `cargo test`.
(define-key rust-mode-map (kbd "C-c C-t") 'cargo-process-test)
(provide 'jenga-rust)