lang/rust: minor refactor

This commit is contained in:
Henrik Lissner 2017-09-19 05:07:24 +02:00
parent ad8418a84b
commit 235576d168
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -1,12 +1,15 @@
;;; lang/rust/config.el -*- lexical-binding: t; -*- ;;; lang/rust/config.el -*- lexical-binding: t; -*-
(defvar +rust-ext-dir (concat doom-etc-dir "rust/") (defvar +rust-src-dir (concat doom-etc-dir "rust/")
"TODO") "The path to Rust source library. Required by racer.")
;;
;; Plugins
;;
(def-package! rust-mode (def-package! rust-mode
:mode "\\.rs$" :mode "\\.rs$"
:init
(add-hook 'rust-mode-hook #'flycheck-mode)
:config :config
(set! :build 'run-cargo '(rust-mode toml-mode) #'+rust/run-cargo (set! :build 'run-cargo '(rust-mode toml-mode) #'+rust/run-cargo
:when #'+rust-cargo-project-p)) :when #'+rust-cargo-project-p))
@ -18,8 +21,8 @@
:init :init
(add-hook! 'rust-mode-hook #'(racer-mode eldoc-mode flycheck-rust-setup)) (add-hook! 'rust-mode-hook #'(racer-mode eldoc-mode flycheck-rust-setup))
:config :config
(setq racer-cmd (expand-file-name "racer/target/release/racer" +rust-ext-dir) (setq racer-cmd (expand-file-name "racer/target/release/racer" +rust-src-dir)
racer-rust-src-path (expand-file-name "rust/src/" +rust-ext-dir)) racer-rust-src-path (expand-file-name "rust/src/" +rust-src-dir))
(unless (file-exists-p racer-cmd) (unless (file-exists-p racer-cmd)
(warn "rust-mode: racer binary can't be found; auto-completion is disabled")) (warn "rust-mode: racer binary can't be found; auto-completion is disabled"))
@ -36,5 +39,6 @@
(def-package! flycheck-rust (def-package! flycheck-rust
:when (featurep! :feature syntax-checker) :when (featurep! :feature syntax-checker)
:after rust-mode) :after rust-mode
:config (add-hook 'rust-mode-hook #'flycheck-mode))