Repository: autozimu/LanguageClient-neovim (language: rust)

Issue:
Support for auto import
I wanted to try the [new `auto import` feature from rust-analyzer](https://github.com/rust-analyzer/rust-analyzer/pull/2887), but unfortunately it does not seem to work out of the box for LanguageClient.

I don't know if it is something that could be implemented easily or if it requires non trivial efforts. In any case I think it could be something interesting for a Rust codebase :wink:


Discussion / hints:

Fix patch:
diff --git a/src/language_server_protocol.rs b/src/language_server_protocol.rs
index 4eef63d8d..603288c4f 100644
--- a/src/language_server_protocol.rs
+++ b/src/language_server_protocol.rs
@@ -847,6 +847,23 @@ impl LanguageClient {
                     }
                 }
             }
+            "rust-analyzer.selectAndApplySourceChange" => {
+                if let Some(ref edits) = cmd.arguments {
+                    for edit in edits {
+                        let workspace_edits: Vec<WorkspaceEditWithCursor> =
+                            serde_json::from_value(edit.clone())?;
+                        for edit in workspace_edits {
+                            self.apply_WorkspaceEdit(&edit.workspaceEdit)?;
+                            if let Some(cursorPosition) = edit.cursorPosition {
+                                self.vim()?.cursor(
+                                    cursorPosition.position.line + 1,
+                                    cursorPosition.position.character + 1,
+                                )?;
+                            }
+                        }
+                    }
+                }
+            }
             "rust-analyzer.applySourceChange" => {
                 if let Some(ref edits) = cmd.arguments {
                     for edit in edits {


Test patch: