2015-05-07 13:19:56 +00:00
|
|
|
;;; packages.el --- Rust Layer packages File for Spacemacs
|
|
|
|
;;
|
2016-01-12 02:40:54 +00:00
|
|
|
;; Copyright (c) 2012-2016 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
|
|
|
'(
|
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
|
2015-05-28 01:26:33 +00:00
|
|
|
flycheck-rust
|
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-05-23 16:06:55 +00:00
|
|
|
(when (configuration-layer/package-usedp 'flycheck)
|
2016-01-10 12:36:56 +00:00
|
|
|
(defun rust/post-init-flycheck ()
|
2016-01-27 20:08:25 +00:00
|
|
|
(spacemacs/add-flycheck-hook 'rust-mode))
|
2016-01-10 12:36:56 +00:00
|
|
|
|
2015-06-03 03:18:31 +00:00
|
|
|
(defun rust/init-flycheck-rust ()
|
|
|
|
(use-package flycheck-rust
|
|
|
|
:defer t
|
2015-07-01 05:37:31 +00:00
|
|
|
:init (add-hook 'flycheck-mode-hook #'flycheck-rust-setup))))
|
2015-05-28 01:26:33 +00:00
|
|
|
|
2015-05-07 13:19:56 +00:00
|
|
|
(defun rust/init-rust-mode ()
|
|
|
|
(use-package rust-mode
|
|
|
|
:defer t
|
|
|
|
:config
|
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-02-17 13:37:27 +00:00
|
|
|
"=" 'rust-format-buffer
|
2016-04-11 18:45:47 +00:00
|
|
|
"cC" 'spacemacs/rust-cargo-clean
|
2015-11-18 00:38:05 +00:00
|
|
|
"cc" 'spacemacs/rust-cargo-build
|
|
|
|
"cd" 'spacemacs/rust-cargo-doc
|
2016-04-21 16:18:51 +00:00
|
|
|
"cf" 'spacemacs/rust-cargo-fmt
|
2016-04-11 18:45:47 +00:00
|
|
|
"ct" 'spacemacs/rust-cargo-test
|
2016-04-21 16:18:51 +00:00
|
|
|
"cx" 'spacemacs/rust-cargo-run))))
|
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-23 16:17:05 +00:00
|
|
|
(when (configuration-layer/package-usedp 'company)
|
2015-06-16 08:27:54 +00:00
|
|
|
(defun rust/post-init-company ()
|
2016-01-10 12:36:56 +00:00
|
|
|
(push 'company-capf company-backends-rust-mode)
|
|
|
|
(spacemacs|add-company-hook rust-mode)
|
|
|
|
(add-hook 'rust-mode-hook
|
|
|
|
(lambda ()
|
|
|
|
(setq-local 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
|
|
|
|
|
|
|
(defun rust/init-racer ()
|
2015-09-16 02:08:10 +00:00
|
|
|
(when (memq window-system '(mac ns x))
|
|
|
|
(exec-path-from-shell-copy-env "RUST_SRC_PATH"))
|
|
|
|
|
2015-08-24 16:00:19 +00:00
|
|
|
(use-package racer
|
2016-04-06 07:54:26 +00:00
|
|
|
:diminish racer-mode
|
2015-08-24 16:00:19 +00:00
|
|
|
:defer t
|
2016-01-10 12:36:56 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(spacemacs/add-to-hook 'rust-mode-hook '(racer-mode eldoc-mode))
|
|
|
|
(spacemacs/declare-prefix-for-mode 'rust-mode "mg" "goto")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'rust-mode
|
|
|
|
"gg" 'racer-find-definition))))
|