lang/rust: run cargo commands from Cargo.toml dir

Instead of the current directory, which breaks file links in the
compilation buffer.
This commit is contained in:
Henrik Lissner 2019-04-10 18:51:37 -04:00
parent da34862e56
commit 8e18b402ce
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 10 additions and 4 deletions

View file

@ -6,3 +6,9 @@
(defun +rust-cargo-project-p ()
"Return t if this is a cargo project."
(locate-dominating-file buffer-file-name "Cargo.toml"))
;;;###autoload
(defun +rust-cargo-compile (command)
"TODO"
(let ((default-directory (+rust-cargo-project-p)))
(compile command)))

View file

@ -10,10 +10,10 @@
(map! :map rust-mode-map
:localleader
:prefix "b"
:desc "cargo build" "b" (λ! (compile "cargo build --color always"))
:desc "cargo check" "c" (λ! (compile "cargo check --color always"))
:desc "cargo run" "r" (λ! (compile "cargo run --color always"))
:desc "cargo test" "t" (λ! (compile "cargo test --color always"))))
:desc "cargo build" "b" (λ! (+rust-cargo-compile "cargo build --color always"))
:desc "cargo check" "c" (λ! (+rust-cargo-compile "cargo check --color always"))
:desc "cargo run" "r" (λ! (+rust-cargo-compile "cargo run --color always"))
:desc "cargo test" "t" (λ! (+rust-cargo-compile "cargo test --color always"))))
(def-package! racer