From ba45c60611f0f41b3138c11b6059bb68b7c9743d Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Wed, 29 Jan 2020 21:39:25 +0100 Subject: [PATCH 1/3] Fix env in emacs runnables support --- editors/emacs/rust-analyzer.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/editors/emacs/rust-analyzer.el b/editors/emacs/rust-analyzer.el index 06db4f15fdf..bcd1b5c679b 100644 --- a/editors/emacs/rust-analyzer.el +++ b/editors/emacs/rust-analyzer.el @@ -143,7 +143,8 @@ (defun rust-analyzer-run (runnable) (interactive (list (rust-analyzer--select-runnable))) - (-let (((&hash "env" "bin" "args" "label") runnable)) + (-let* (((&hash "env" "bin" "args" "label") runnable) + (compilation-environment (-map (-lambda ((k v)) (concat k "=" v)) (ht-items env)))) (compilation-start (string-join (append (list bin) args '()) " ") ;; cargo-process-mode is nice, but try to work without it... From f83154d4bfa3e82a9b8a2ed0c4904820be829c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Fri, 31 Jan 2020 21:49:44 +0200 Subject: [PATCH 2/3] Disable optimizations for some build-time crates --- Cargo.toml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 31a0560d936..e5620b1b7dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,5 +10,24 @@ debug = 0 incremental = true debug = 0 # set this to 1 or 2 to get more useful backtraces in debugger +# ideally, we would use `build-override` here, but some crates are also +# needed at run-time and we end up compiling them twice +[profile.release.package.proc-macro2] +opt-level = 0 +[profile.release.package.quote] +opt-level = 0 +[profile.release.package.syn] +opt-level = 0 +[profile.release.package.serde_derive] +opt-level = 0 +[profile.release.package.chalk-derive] +opt-level = 0 +[profile.release.package.chalk-macros] +opt-level = 0 +[profile.release.package.salsa-macros] +opt-level = 0 +[profile.release.package.xtask] +opt-level = 0 + [patch.'crates-io'] # rowan = { path = "../rowan" } From 2586cf9279c73b149f012228ce05b44410d66295 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 31 Jan 2020 15:16:22 +0100 Subject: [PATCH 3/3] Implement support for selectAndApplySourceChange (auto import) in Emacs --- editors/emacs/rust-analyzer.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/editors/emacs/rust-analyzer.el b/editors/emacs/rust-analyzer.el index bcd1b5c679b..9b426fcae92 100644 --- a/editors/emacs/rust-analyzer.el +++ b/editors/emacs/rust-analyzer.el @@ -38,7 +38,9 @@ (defconst rust-analyzer--action-handlers '(("rust-analyzer.applySourceChange" . - (lambda (p) (rust-analyzer--apply-source-change-command p))))) + (lambda (p) (rust-analyzer--apply-source-change-command p))) + ("rust-analyzer.selectAndApplySourceChange" . + (lambda (p) (rust-analyzer--select-and-apply-source-change-command p))))) (defun rust-analyzer--uri-filename (text-document) (lsp--uri-to-path (gethash "uri" text-document))) @@ -71,6 +73,12 @@ (let ((data (-> p (ht-get "arguments") (lsp-seq-first)))) (rust-analyzer--apply-source-change data))) +(defun rust-analyzer--select-and-apply-source-change-command (p) + (let* ((options (-> p (ht-get "arguments") (lsp-seq-first))) + (chosen-option (lsp--completing-read "Select option:" options + (-lambda ((&hash "label")) label)))) + (rust-analyzer--apply-source-change chosen-option))) + (lsp-register-client (make-lsp-client :new-connection (lsp-stdio-connection (lambda () rust-analyzer-command))