aboutsummaryrefslogtreecommitdiff
path: root/helix-lsp/src
diff options
context:
space:
mode:
authorKyle Smith2023-03-08 02:11:43 +0000
committerGitHub2023-03-08 02:11:43 +0000
commit44ff8a1df1f69733bc40ea866674fcfd7e0cdded (patch)
tree91e69301836f46a3c0676be821d4ca380212c797 /helix-lsp/src
parent3849ca4c2abdb1c6076d391eab4c3f43dda30234 (diff)
LSP: Support textDocument/prepareRename (#6103)
* LSP: Support textDocument/prepareRename 'textDocument/prepareRename' can be used by the client to ask the server the range of the symbol under the cursor which would be changed by a subsequent call to 'textDocument/rename' with that position. We can use this information to fill the prompt with an accurate prefill which can improve the UX for renaming symbols when the symbol doesn't align with the "word" textobject. (We currently use the "word" textobject as a default value for the prompt.) Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * clippy fixes * rustfmt * Update helix-term/src/commands/lsp.rs Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * Update helix-term/src/commands/lsp.rs Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * fix clippy from suggestions * Update helix-term/src/commands/lsp.rs Co-authored-by: Michael Davis <mcarsondavis@gmail.com> --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
Diffstat (limited to 'helix-lsp/src')
-rw-r--r--helix-lsp/src/client.rs25
1 files changed, 24 insertions, 1 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index 95f3ea34..9fa118fb 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -359,7 +359,7 @@ impl Client {
}),
rename: Some(lsp::RenameClientCapabilities {
dynamic_registration: Some(false),
- prepare_support: Some(false),
+ prepare_support: Some(true),
prepare_support_default_behavior: None,
honors_change_annotations: Some(false),
}),
@@ -1034,6 +1034,29 @@ impl Client {
Some(self.call::<lsp::request::DocumentSymbolRequest>(params))
}
+ pub fn prepare_rename(
+ &self,
+ text_document: lsp::TextDocumentIdentifier,
+ position: lsp::Position,
+ ) -> Option<impl Future<Output = Result<Value>>> {
+ let capabilities = self.capabilities.get().unwrap();
+
+ match capabilities.rename_provider {
+ Some(lsp::OneOf::Right(lsp::RenameOptions {
+ prepare_provider: Some(true),
+ ..
+ })) => (),
+ _ => return None,
+ }
+
+ let params = lsp::TextDocumentPositionParams {
+ text_document,
+ position,
+ };
+
+ Some(self.call::<lsp::request::PrepareRenameRequest>(params))
+ }
+
// empty string to get all symbols
pub fn workspace_symbols(&self, query: String) -> Option<impl Future<Output = Result<Value>>> {
let capabilities = self.capabilities.get().unwrap();