aboutsummaryrefslogtreecommitdiff
path: root/helix-lsp
diff options
context:
space:
mode:
authorttys32022-04-23 08:09:16 +0000
committerGitHub2022-04-23 08:09:16 +0000
commit19d042dde6ac7aad5b597c791c1f142f5c7f7198 (patch)
tree34d07d98dd4bc4fb9cba0e8bf70be7a9dbbb337a /helix-lsp
parentc1d3d49f3f47a991e38e21d96dee3f9081c9a663 (diff)
chore(lsp): check rename capabilities before send rename action (#2203)
Diffstat (limited to 'helix-lsp')
-rw-r--r--helix-lsp/src/client.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index dba134fc..2459554c 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -3,6 +3,7 @@ use crate::{
Call, Error, OffsetEncoding, Result,
};
+use anyhow::anyhow;
use helix_core::{find_root, ChangeSet, Rope};
use jsonrpc_core as jsonrpc;
use lsp_types as lsp;
@@ -861,6 +862,19 @@ impl Client {
position: lsp::Position,
new_name: String,
) -> anyhow::Result<lsp::WorkspaceEdit> {
+ let capabilities = self.capabilities.get().unwrap();
+
+ // check if we're able to rename
+ match capabilities.rename_provider {
+ Some(lsp::OneOf::Left(true)) | Some(lsp::OneOf::Right(_)) => (),
+ // None | Some(false)
+ _ => {
+ let err = "The server does not support rename";
+ log::warn!("rename_symbol failed: {}", err);
+ return Err(anyhow!(err));
+ }
+ };
+
let params = lsp::RenameParams {
text_document_position: lsp::TextDocumentPositionParams {
text_document,