Implement support for selectAndApplySourceChange (auto import) in Emacs
(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)))
(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))
