Skip to content

Commit

Permalink
Adds a customization to default to workspace or local crate.
Browse files Browse the repository at this point in the history
Adds rust-locate-project-in-workspace custom variable, which controls whether or not to locate the workspace
project using `--workspace` (the default) or not.

In cases where there is only one create, this should make no difference.

The default setting should match the existing behavior.

Github issue #545
  • Loading branch information
bradneuman committed May 13, 2024
1 parent e54bbae commit 26dd5ac
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion rust-cargo.el
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
:type 'boolean
:group 'rust-mode)

(defcustom rust-locate-project-in-workspace t
"Whether to use `--workspace` with `cargo locate-project`. If t,
rust-mode will run commands for the entire workspace. If nil,
rust will search for the Cargo.toml in the local crated"
:type 'boolean
:group 'rust-mode)

(defcustom rust-cargo-default-arguments ""
"Default arguments when running common cargo commands."
:type 'string
Expand All @@ -42,7 +49,11 @@
(setq-local process-environment env)
;; Set PATH so we can find cargo.
(setq-local exec-path path)
(let ((ret (process-file rust-cargo-bin nil (list (current-buffer) nil) nil "locate-project" "--workspace")))
(let ((ret
(let ((args (list rust-cargo-bin nil (list (current-buffer) nil) nil "locate-project")))
(when rust-locate-project-in-workspace
(setq args (append args (list "--workspace"))))
(apply #'process-file args))))
(when (/= ret 0)
(error "`cargo locate-project' returned %s status: %s" ret (buffer-string)))
(goto-char 0)
Expand Down

0 comments on commit 26dd5ac

Please sign in to comment.