diff --git a/modules/lang/rust/config.el b/modules/lang/rust/config.el index 22e5b8bf9..7afabf06e 100644 --- a/modules/lang/rust/config.el +++ b/modules/lang/rust/config.el @@ -24,13 +24,15 @@ :init (add-hook! 'rust-mode-hook #'(racer-mode eldoc-mode flycheck-rust-setup)) :config - (setq racer-cmd (expand-file-name "racer/target/release/racer" +rust-src-dir) - racer-rust-src-path (expand-file-name "rust/src/" +rust-src-dir)) - - (set! :jump 'rust-mode :definition #'racer-find-definition) + (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))) (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")) + + (set! :jump 'rust-mode :definition #'racer-find-definition)) (def-package! company-racer