aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-01-31 14:16:22 +0000
committerFlorian Diebold <[email protected]>2020-01-31 21:24:05 +0000
commit2586cf9279c73b149f012228ce05b44410d66295 (patch)
treeb4100fd9e5b08c83a7daccaaadfd27edaa0d01ec /editors
parentba45c60611f0f41b3138c11b6059bb68b7c9743d (diff)
Implement support for selectAndApplySourceChange (auto import) in Emacs
Diffstat (limited to 'editors')
-rw-r--r--editors/emacs/rust-analyzer.el10
1 files changed, 9 insertions, 1 deletions
diff --git a/editors/emacs/rust-analyzer.el b/editors/emacs/rust-analyzer.el
index bcd1b5c67..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))