diff options
-rw-r--r-- | Cargo.toml | 19 | ||||
-rw-r--r-- | editors/emacs/rust-analyzer.el | 13 |
2 files changed, 30 insertions, 2 deletions
diff --git a/Cargo.toml b/Cargo.toml index 31a0560d9..e5620b1b7 100644 --- a/Cargo.toml +++ b/Cargo.toml | |||
@@ -10,5 +10,24 @@ debug = 0 | |||
10 | incremental = true | 10 | incremental = true |
11 | debug = 0 # set this to 1 or 2 to get more useful backtraces in debugger | 11 | debug = 0 # set this to 1 or 2 to get more useful backtraces in debugger |
12 | 12 | ||
13 | # ideally, we would use `build-override` here, but some crates are also | ||
14 | # needed at run-time and we end up compiling them twice | ||
15 | [profile.release.package.proc-macro2] | ||
16 | opt-level = 0 | ||
17 | [profile.release.package.quote] | ||
18 | opt-level = 0 | ||
19 | [profile.release.package.syn] | ||
20 | opt-level = 0 | ||
21 | [profile.release.package.serde_derive] | ||
22 | opt-level = 0 | ||
23 | [profile.release.package.chalk-derive] | ||
24 | opt-level = 0 | ||
25 | [profile.release.package.chalk-macros] | ||
26 | opt-level = 0 | ||
27 | [profile.release.package.salsa-macros] | ||
28 | opt-level = 0 | ||
29 | [profile.release.package.xtask] | ||
30 | opt-level = 0 | ||
31 | |||
13 | [patch.'crates-io'] | 32 | [patch.'crates-io'] |
14 | # rowan = { path = "../rowan" } | 33 | # rowan = { path = "../rowan" } |
diff --git a/editors/emacs/rust-analyzer.el b/editors/emacs/rust-analyzer.el index 06db4f15f..9b426fcae 100644 --- a/editors/emacs/rust-analyzer.el +++ b/editors/emacs/rust-analyzer.el | |||
@@ -38,7 +38,9 @@ | |||
38 | 38 | ||
39 | (defconst rust-analyzer--action-handlers | 39 | (defconst rust-analyzer--action-handlers |
40 | '(("rust-analyzer.applySourceChange" . | 40 | '(("rust-analyzer.applySourceChange" . |
41 | (lambda (p) (rust-analyzer--apply-source-change-command p))))) | 41 | (lambda (p) (rust-analyzer--apply-source-change-command p))) |
42 | ("rust-analyzer.selectAndApplySourceChange" . | ||
43 | (lambda (p) (rust-analyzer--select-and-apply-source-change-command p))))) | ||
42 | 44 | ||
43 | (defun rust-analyzer--uri-filename (text-document) | 45 | (defun rust-analyzer--uri-filename (text-document) |
44 | (lsp--uri-to-path (gethash "uri" text-document))) | 46 | (lsp--uri-to-path (gethash "uri" text-document))) |
@@ -71,6 +73,12 @@ | |||
71 | (let ((data (-> p (ht-get "arguments") (lsp-seq-first)))) | 73 | (let ((data (-> p (ht-get "arguments") (lsp-seq-first)))) |
72 | (rust-analyzer--apply-source-change data))) | 74 | (rust-analyzer--apply-source-change data))) |
73 | 75 | ||
76 | (defun rust-analyzer--select-and-apply-source-change-command (p) | ||
77 | (let* ((options (-> p (ht-get "arguments") (lsp-seq-first))) | ||
78 | (chosen-option (lsp--completing-read "Select option:" options | ||
79 | (-lambda ((&hash "label")) label)))) | ||
80 | (rust-analyzer--apply-source-change chosen-option))) | ||
81 | |||
74 | (lsp-register-client | 82 | (lsp-register-client |
75 | (make-lsp-client | 83 | (make-lsp-client |
76 | :new-connection (lsp-stdio-connection (lambda () rust-analyzer-command)) | 84 | :new-connection (lsp-stdio-connection (lambda () rust-analyzer-command)) |
@@ -143,7 +151,8 @@ | |||
143 | 151 | ||
144 | (defun rust-analyzer-run (runnable) | 152 | (defun rust-analyzer-run (runnable) |
145 | (interactive (list (rust-analyzer--select-runnable))) | 153 | (interactive (list (rust-analyzer--select-runnable))) |
146 | (-let (((&hash "env" "bin" "args" "label") runnable)) | 154 | (-let* (((&hash "env" "bin" "args" "label") runnable) |
155 | (compilation-environment (-map (-lambda ((k v)) (concat k "=" v)) (ht-items env)))) | ||
147 | (compilation-start | 156 | (compilation-start |
148 | (string-join (append (list bin) args '()) " ") | 157 | (string-join (append (list bin) args '()) " ") |
149 | ;; cargo-process-mode is nice, but try to work without it... | 158 | ;; cargo-process-mode is nice, but try to work without it... |