Emacs config utilizing prelude as a base
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.0 KiB

  1. ;;; prelude-rust.el --- Emacs Prelude: Rust programming support.
  2. ;;
  3. ;; Authors: Doug MacEachern, Manoel Vilela
  4. ;; Version: 1.0.1
  5. ;; Keywords: convenience rust
  6. ;; This file is not part of GNU Emacs.
  7. ;;; Commentary:
  8. ;; Prelude configuration for Rust
  9. ;;; License:
  10. ;; This program is free software; you can redistribute it and/or
  11. ;; modify it under the terms of the GNU General Public License
  12. ;; as published by the Free Software Foundation; either version 3
  13. ;; of the License, or (at your option) any later version.
  14. ;;
  15. ;; This program is distributed in the hope that it will be useful,
  16. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;; GNU General Public License for more details.
  19. ;;
  20. ;; You should have received a copy of the GNU General Public License
  21. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  22. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  23. ;; Boston, MA 02110-1301, USA.
  24. ;;; Code:
  25. (require 'prelude-programming)
  26. ;; You may need installing the following packages on your system:
  27. ;; * rustc (Rust Compiler)
  28. ;; * cargo (Rust Package Manager)
  29. ;; * racer (Rust Completion Tool)
  30. ;; * rustfmt (Rust Tool for formatting code)
  31. (prelude-require-packages '(rust-mode
  32. racer
  33. flycheck-rust
  34. cargo))
  35. (setq rust-format-on-save t)
  36. (with-eval-after-load 'rust-mode
  37. (add-hook 'rust-mode-hook 'racer-mode)
  38. (add-hook 'racer-mode-hook 'eldoc-mode)
  39. (add-hook 'rust-mode-hook 'cargo-minor-mode)
  40. (add-hook 'rust-mode-hook 'flycheck-rust-setup)
  41. (add-hook 'flycheck-mode-hook 'flycheck-rust-setup)
  42. (defun prelude-rust-mode-defaults ()
  43. (local-set-key (kbd "C-c C-d") 'racer-describe)
  44. ;; CamelCase aware editing operations
  45. (subword-mode +1))
  46. (setq prelude-rust-mode-hook 'prelude-rust-mode-defaults)
  47. (add-hook 'rust-mode-hook (lambda ()
  48. (run-hooks 'prelude-rust-mode-hook))))
  49. (provide 'prelude-rust)
  50. ;;; prelude-rust.el ends here