From 2586cf9279c73b149f012228ce05b44410d66295 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 31 Jan 2020 15:16:22 +0100 Subject: Implement support for selectAndApplySourceChange (auto import) in Emacs --- editors/emacs/rust-analyzer.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'editors/emacs') 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 @@ (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)) -- cgit v1.2.3