Skip to content

Commit

Permalink
rust-analyzer: Add defcustoms for extra args and env vars to cargo. (#…
Browse files Browse the repository at this point in the history
…4015)

* rust-analyzer: Add defcustoms for extra args and env vars to cargo.

* lsp-rust-analyzer-cargo-extra-args,
lsp-rust-analyzer-cargo-extra-env: New config variables for
lsp-rust-analyzer.

* lsp-rust-analyzer--make-init-options: Set fields cargo.extraArgs and
cargo.extraEnv from lsp-rust-analyzer-cargo-extra-args and
lsp-rust-analyzer-cargo-extra-env respectively.

* fix: conflict

* Resolve conflict

---------

Co-authored-by: Jen-Chieh Shen <[email protected]>
  • Loading branch information
vibhavp and jcs090218 authored Mar 24, 2024
1 parent 3422c85 commit fd0a4f1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion clients/lsp-rust.el
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,19 @@ or JSON objects in `rust-project.json` format."
:group 'lsp-rust-analyzer
:package-version '(lsp-mode . "8.0.0"))

(defcustom lsp-rust-analyzer-cargo-extra-args []
"Extra arguments that are passed to every cargo invocation."
:type 'lsp-string-vector
:group 'lsp-rust-analyzer
:package-version '(lsp-mode . "8.0.1"))

(defcustom lsp-rust-analyzer-cargo-extra-env []
"Extra environment variables that will be set when running cargo, rustc or
other commands within the workspace. Useful for setting RUSTFLAGS."
:type 'lsp-string-vector
:group 'lsp-rust-analyzer
:package-version '(lsp-mode . "8.0.1"))

(defconst lsp-rust-notification-handlers
'(("rust-analyzer/publishDecorations" . (lambda (_w _p)))))

Expand Down Expand Up @@ -1664,6 +1677,8 @@ https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/lsp-extensions.m
:cargo ( :allFeatures ,(lsp-json-bool lsp-rust-all-features)
:noDefaultFeatures ,(lsp-json-bool lsp-rust-no-default-features)
:features ,lsp-rust-features
:extraArgs ,lsp-rust-analyzer-cargo-extra-args
:extraEnv ,lsp-rust-analyzer-cargo-extra-env
:target ,lsp-rust-analyzer-cargo-target
:runBuildScripts ,(lsp-json-bool lsp-rust-analyzer-cargo-run-build-scripts)
;; Obsolete, but used by old Rust-Analyzer versions
Expand Down Expand Up @@ -1745,7 +1760,6 @@ https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/lsp-extensions.m
:download-server-fn (lambda (_client callback error-callback _update?)
(lsp-package-ensure 'rust-analyzer callback error-callback))))


(lsp-consistency-check lsp-rust)

(provide 'lsp-rust)
Expand Down

0 comments on commit fd0a4f1

Please sign in to comment.