2015-05-07 13:19:56 +00:00
|
|
|
;;; packages.el --- Rust Layer packages File for Spacemacs
|
|
|
|
;;
|
2020-05-16 21:32:30 +00:00
|
|
|
;; Copyright (c) 2012-2020 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
|
|
|
|
|
2020-05-16 21:32:30 +00:00
|
|
|
(defconst rust-packages
|
|
|
|
'(
|
|
|
|
cargo
|
|
|
|
company
|
|
|
|
counsel-gtags
|
|
|
|
dap-mode
|
|
|
|
flycheck
|
|
|
|
(flycheck-rust :requires flycheck)
|
|
|
|
ggtags
|
|
|
|
helm-gtags
|
|
|
|
racer
|
|
|
|
rust-mode
|
|
|
|
smartparens
|
|
|
|
toml-mode))
|
2015-05-07 13:19:56 +00:00
|
|
|
|
2016-08-17 18:09:01 +00:00
|
|
|
(defun rust/init-cargo ()
|
|
|
|
(use-package cargo
|
2018-03-04 04:37:53 +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
|
2020-02-26 07:15:44 +00:00
|
|
|
"ca" 'cargo-process-add
|
|
|
|
"cA" 'cargo-process-audit
|
2018-01-18 04:17:50 +00:00
|
|
|
"cc" 'cargo-process-build
|
2020-02-26 07:15:44 +00:00
|
|
|
"cC" 'cargo-process-clean
|
2016-08-07 15:37:12 +00:00
|
|
|
"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
|
2020-02-26 07:15:44 +00:00
|
|
|
"cE" 'cargo-process-run-example
|
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
|
2020-02-26 07:15:44 +00:00
|
|
|
"cr" 'cargo-process-rm
|
2016-08-07 15:37:12 +00:00
|
|
|
"cs" 'cargo-process-search
|
2017-12-08 04:04:05 +00:00
|
|
|
"ct" 'cargo-process-current-test
|
2016-08-07 15:37:12 +00:00
|
|
|
"cu" 'cargo-process-update
|
2020-02-26 07:15:44 +00:00
|
|
|
"cU" 'cargo-process-upgrade
|
2016-08-07 15:37:12 +00:00
|
|
|
"cx" 'cargo-process-run
|
2020-02-26 07:15:44 +00:00
|
|
|
"cX" 'cargo-process-run-bin
|
2018-01-18 04:17:50 +00:00
|
|
|
"cv" 'cargo-process-check
|
2016-08-07 15:37:12 +00:00
|
|
|
"t" 'cargo-process-test))))
|
2015-05-07 13:19:56 +00:00
|
|
|
|
2019-09-30 01:30:53 +00:00
|
|
|
(defun rust/post-init-company ()
|
|
|
|
;; backend specific
|
|
|
|
(spacemacs//rust-setup-company))
|
|
|
|
|
|
|
|
(defun rust/post-init-counsel-gtags ()
|
|
|
|
(spacemacs/counsel-gtags-define-keys-for-mode 'rust-mode))
|
|
|
|
|
|
|
|
(defun rust/pre-init-dap-mode ()
|
2020-05-16 21:32:30 +00:00
|
|
|
(pcase (spacemacs//rust-backend)
|
|
|
|
(`lsp (add-to-list 'spacemacs--dap-supported-modes 'rust-mode)))
|
2019-09-30 01:30:53 +00:00
|
|
|
(add-hook 'rust-mode-local-vars-hook #'spacemacs//rust-setup-dap))
|
|
|
|
|
|
|
|
(defun rust/post-init-flycheck ()
|
|
|
|
(spacemacs/enable-flycheck 'rust-mode))
|
|
|
|
|
|
|
|
(defun rust/init-flycheck-rust ()
|
|
|
|
(use-package flycheck-rust
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2019-09-30 01:30:53 +00:00
|
|
|
:init (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)))
|
2016-08-17 18:09:01 +00:00
|
|
|
|
2019-09-30 01:30:53 +00:00
|
|
|
(defun rust/post-init-ggtags ()
|
|
|
|
(add-hook 'rust-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
|
|
|
|
|
|
|
|
(defun rust/post-init-helm-gtags ()
|
|
|
|
(spacemacs/helm-gtags-define-keys-for-mode 'rust-mode))
|
2015-06-16 08:27:54 +00:00
|
|
|
|
2017-03-18 21:51:37 +00:00
|
|
|
(defun rust/init-racer ()
|
2015-08-24 16:00:19 +00:00
|
|
|
(use-package racer
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2018-10-28 21:43:11 +00:00
|
|
|
:commands racer-mode
|
|
|
|
:config
|
2016-01-10 12:36:56 +00:00
|
|
|
(progn
|
2016-10-17 12:14:31 +00:00
|
|
|
(spacemacs/add-to-hook 'rust-mode-hook '(racer-mode))
|
2018-06-25 22:07:58 +00:00
|
|
|
(spacemacs/add-to-hook 'racer-mode-hook '(eldoc-mode))
|
2016-08-28 10:21:45 +00:00
|
|
|
(add-to-list 'spacemacs-jump-handlers-rust-mode 'racer-find-definition)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'rust-mode
|
2018-10-28 21:43:11 +00:00
|
|
|
"hh" 'spacemacs/racer-describe)
|
2017-02-13 13:38:37 +00:00
|
|
|
(spacemacs|hide-lighter racer-mode)
|
|
|
|
(evilified-state-evilify-map racer-help-mode-map
|
|
|
|
:mode racer-help-mode))))
|
2018-10-28 21:43:11 +00:00
|
|
|
|
2019-09-30 01:30:53 +00:00
|
|
|
(defun rust/init-rust-mode ()
|
|
|
|
(use-package rust-mode
|
2018-10-28 21:43:11 +00:00
|
|
|
:defer t
|
2019-09-30 01:30:53 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(spacemacs/add-to-hook 'rust-mode-hook '(spacemacs//rust-setup-backend))
|
|
|
|
(spacemacs/declare-prefix-for-mode 'rust-mode "mg" "goto")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'rust-mode "mh" "help")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'rust-mode "m=" "format")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'rust-mode
|
|
|
|
"==" 'rust-format-buffer
|
2019-12-23 13:28:25 +00:00
|
|
|
"q" 'spacemacs/rust-quick-run))))
|
2018-10-28 21:43:11 +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)))
|
|
|
|
|
2019-09-30 01:30:53 +00:00
|
|
|
(defun rust/init-toml-mode ()
|
|
|
|
(use-package toml-mode
|
|
|
|
:mode "/\\(Cargo.lock\\|\\.cargo/config\\)\\'"))
|