2015-05-07 13:19:56 +00:00
|
|
|
;;; packages.el --- Rust Layer packages File for Spacemacs
|
|
|
|
;;
|
2017-01-06 03:51:13 +00:00
|
|
|
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
|
2015-05-07 13:19:56 +00:00
|
|
|
;;
|
|
|
|
;; Author: Chris Hoeppner <me@mkaito.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2015-07-01 05:37:31 +00:00
|
|
|
(setq rust-packages
|
2015-05-07 13:19:56 +00:00
|
|
|
'(
|
2016-08-07 15:37:12 +00:00
|
|
|
cargo
|
2015-07-01 05:37:31 +00:00
|
|
|
company
|
2015-08-24 16:00:19 +00:00
|
|
|
racer
|
2015-06-03 03:18:31 +00:00
|
|
|
flycheck
|
2017-07-03 07:52:54 +00:00
|
|
|
(flycheck-rust :requires flycheck)
|
2016-04-05 04:08:34 +00:00
|
|
|
ggtags
|
2017-03-18 21:51:37 +00:00
|
|
|
exec-path-from-shell
|
2016-04-05 04:08:34 +00:00
|
|
|
helm-gtags
|
2015-05-07 13:19:56 +00:00
|
|
|
rust-mode
|
|
|
|
toml-mode
|
2015-07-01 05:37:31 +00:00
|
|
|
))
|
2015-05-07 13:19:56 +00:00
|
|
|
|
2016-08-17 18:09:01 +00:00
|
|
|
(defun rust/init-cargo ()
|
|
|
|
(use-package cargo
|
2015-05-07 13:19:56 +00:00
|
|
|
:defer t
|
2016-08-17 18:09:01 +00:00
|
|
|
:init
|
2015-05-12 01:30:31 +00:00
|
|
|
(progn
|
2016-01-02 13:36:43 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'rust-mode "mc" "cargo")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'rust-mode
|
2016-08-07 15:37:12 +00:00
|
|
|
"c." 'cargo-process-repeat
|
|
|
|
"cC" 'cargo-process-clean
|
|
|
|
"cX" 'cargo-process-run-example
|
|
|
|
"cc" 'cargo-process-build
|
|
|
|
"cd" 'cargo-process-doc
|
2017-01-07 15:48:57 +00:00
|
|
|
"cD" 'cargo-process-doc-open
|
2016-08-07 15:37:12 +00:00
|
|
|
"ce" 'cargo-process-bench
|
|
|
|
"cf" 'cargo-process-current-test
|
2016-08-17 18:09:01 +00:00
|
|
|
"cf" 'cargo-process-fmt
|
2016-08-07 15:37:12 +00:00
|
|
|
"ci" 'cargo-process-init
|
2017-06-26 09:14:48 +00:00
|
|
|
"cl" 'cargo-process-clippy
|
2016-08-07 15:37:12 +00:00
|
|
|
"cn" 'cargo-process-new
|
|
|
|
"co" 'cargo-process-current-file-tests
|
|
|
|
"cs" 'cargo-process-search
|
|
|
|
"cu" 'cargo-process-update
|
|
|
|
"cx" 'cargo-process-run
|
|
|
|
"t" 'cargo-process-test))))
|
2015-05-07 13:19:56 +00:00
|
|
|
|
2016-08-17 18:09:01 +00:00
|
|
|
(defun rust/post-init-flycheck ()
|
2017-02-14 03:27:29 +00:00
|
|
|
(spacemacs/enable-flycheck 'rust-mode))
|
2016-08-17 18:09:01 +00:00
|
|
|
|
|
|
|
(defun rust/init-flycheck-rust ()
|
|
|
|
(use-package flycheck-rust
|
|
|
|
:defer t
|
|
|
|
:init (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)))
|
|
|
|
|
|
|
|
(defun rust/post-init-ggtags ()
|
2016-08-15 19:24:44 +00:00
|
|
|
(add-hook 'rust-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
|
2016-08-17 18:09:01 +00:00
|
|
|
|
|
|
|
(defun rust/post-init-helm-gtags ()
|
|
|
|
(spacemacs/helm-gtags-define-keys-for-mode 'rust-mode))
|
|
|
|
|
|
|
|
(defun rust/init-rust-mode ()
|
|
|
|
(use-package rust-mode
|
|
|
|
:defer t
|
|
|
|
:init
|
2016-08-13 13:43:37 +00:00
|
|
|
(progn
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'rust-mode
|
2016-11-16 18:33:01 +00:00
|
|
|
"=" 'rust-format-buffer
|
|
|
|
"q" 'spacemacs/rust-quick-run))))
|
2016-08-17 18:09:01 +00:00
|
|
|
|
2015-05-07 13:19:56 +00:00
|
|
|
(defun rust/init-toml-mode ()
|
|
|
|
(use-package toml-mode
|
2016-03-14 21:01:06 +00:00
|
|
|
:mode "/\\(Cargo.lock\\|\\.cargo/config\\)\\'"))
|
2015-06-16 08:27:54 +00:00
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun rust/post-init-company ()
|
2017-01-02 05:39:04 +00:00
|
|
|
(spacemacs|add-company-backends
|
|
|
|
:backends company-capf
|
|
|
|
:modes rust-mode
|
|
|
|
:variables company-tooltip-align-annotations t))
|
2015-06-16 08:27:54 +00:00
|
|
|
|
2016-01-10 12:36:56 +00:00
|
|
|
(defun rust/post-init-smartparens ()
|
|
|
|
(with-eval-after-load 'smartparens
|
|
|
|
;; Don't pair lifetime specifiers
|
|
|
|
(sp-local-pair 'rust-mode "'" nil :actions nil)))
|
2015-08-24 16:00:19 +00:00
|
|
|
|
2015-09-16 02:08:10 +00:00
|
|
|
|
2017-03-18 21:51:37 +00:00
|
|
|
(defun rust/pre-init-exec-path-from-shell ()
|
|
|
|
(spacemacs|use-package-add-hook exec-path-from-shell
|
|
|
|
:pre-config
|
|
|
|
(let ((var "RUST_SRC_PATH"))
|
|
|
|
(unless (or (member var exec-path-from-shell-variables) (getenv var))
|
|
|
|
(push var exec-path-from-shell-variables)))))
|
|
|
|
|
|
|
|
(defun rust/init-racer ()
|
2015-08-24 16:00:19 +00:00
|
|
|
(use-package racer
|
|
|
|
:defer t
|
2016-01-10 12:36:56 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2016-10-17 12:14:31 +00:00
|
|
|
(spacemacs/add-to-hook 'rust-mode-hook '(racer-mode))
|
2016-01-10 12:36:56 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'rust-mode "mg" "goto")
|
2016-08-28 10:21:45 +00:00
|
|
|
(add-to-list 'spacemacs-jump-handlers-rust-mode 'racer-find-definition)
|
|
|
|
(spacemacs/declare-prefix-for-mode 'rust-mode "mh" "help")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'rust-mode
|
2016-11-12 12:14:55 +00:00
|
|
|
"hh" 'spacemacs/racer-describe))
|
|
|
|
:config
|
2017-02-13 13:38:37 +00:00
|
|
|
(progn
|
|
|
|
(spacemacs|hide-lighter racer-mode)
|
|
|
|
(evilified-state-evilify-map racer-help-mode-map
|
|
|
|
:mode racer-help-mode))))
|