2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/rust/config.el -*- lexical-binding: t; -*-
|
2015-09-30 12:28:52 -04:00
|
|
|
|
2017-09-19 05:07:24 +02:00
|
|
|
(defvar +rust-src-dir (concat doom-etc-dir "rust/")
|
|
|
|
"The path to Rust source library. Required by racer.")
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
;; Plugins
|
|
|
|
;;
|
2017-02-21 03:46:07 -05:00
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! rust-mode
|
2015-09-30 12:28:52 -04:00
|
|
|
:mode "\\.rs$"
|
2016-05-01 01:10:30 -04:00
|
|
|
:config
|
2017-10-03 02:49:08 +02:00
|
|
|
(def-menu! +rust/build-menu
|
|
|
|
"TODO"
|
|
|
|
'(("run" :exec "cargo run" :cwd t :when (+rust-cargo-project-p))
|
|
|
|
("build" :exec "cargo build" :cwd t :when (+rust-cargo-project-p)))
|
|
|
|
:prompt "Cargo: "))
|
2015-09-30 12:28:52 -04:00
|
|
|
|
2015-11-30 05:31:20 -05:00
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! racer
|
2016-04-23 22:08:46 -04:00
|
|
|
:after rust-mode
|
2017-02-21 03:46:07 -05:00
|
|
|
:preface
|
2017-02-19 18:57:16 -05:00
|
|
|
:init
|
2017-06-08 11:47:56 +02:00
|
|
|
(add-hook! 'rust-mode-hook #'(racer-mode eldoc-mode flycheck-rust-setup))
|
2016-04-23 22:08:46 -04:00
|
|
|
:config
|
2017-11-02 20:01:34 +01:00
|
|
|
(setq racer-cmd (or (executable-find "racer")
|
|
|
|
(expand-file-name "racer/target/release/racer" +rust-src-dir))
|
|
|
|
racer-rust-src-path (or (getenv "RUST_SRC_PATH")
|
|
|
|
(expand-file-name "rust/src/" +rust-src-dir)))
|
2017-06-08 11:47:56 +02:00
|
|
|
|
2017-10-03 02:49:49 +02:00
|
|
|
(unless (file-exists-p racer-cmd)
|
2017-11-02 20:01:34 +01:00
|
|
|
(warn "rust-mode: racer binary can't be found; auto-completion is disabled"))
|
|
|
|
|
|
|
|
(set! :jump 'rust-mode :definition #'racer-find-definition))
|
2017-02-19 18:57:16 -05:00
|
|
|
|
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! company-racer
|
2017-03-19 22:47:50 -04:00
|
|
|
:when (featurep! :completion company)
|
|
|
|
:after racer
|
|
|
|
:config (set! :company-backend 'rust-mode '(company-racer)))
|
2017-02-19 18:57:16 -05:00
|
|
|
|
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! flycheck-rust
|
2017-03-19 22:47:50 -04:00
|
|
|
:when (featurep! :feature syntax-checker)
|
2017-09-19 05:07:24 +02:00
|
|
|
:after rust-mode
|
|
|
|
:config (add-hook 'rust-mode-hook #'flycheck-mode))
|
2015-09-30 12:28:52 -04:00
|
|
|
|