diff options
author | Blaž Hrastnik | 2022-03-31 08:45:51 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2022-03-31 08:45:51 +0000 |
commit | 84e799f0e4fdbae1dd574439f5b9776ce8ea3f8e (patch) | |
tree | e77d55ab92b57cfbf1922153ac0b1f6809b8bf44 | |
parent | 5d61631507143194594f1dff6af9f862ce79992e (diff) |
fix: Some LSPs still want rootPath, so provide it
Refs #1898
-rw-r--r-- | helix-lsp/src/client.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 1ce5158b..dbdd885b 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -235,7 +235,10 @@ impl Client { pub(crate) async fn initialize(&self) -> Result<lsp::InitializeResult> { // TODO: delay any requests that are triggered prior to initialize - let root = find_root(None, &self.root_markers) + let root_path = find_root(None, &self.root_markers); + + let root_uri = root_path + .clone() .and_then(|root| lsp::Url::from_file_path(root).ok()); if self.config.is_some() { @@ -245,9 +248,10 @@ impl Client { #[allow(deprecated)] let params = lsp::InitializeParams { process_id: Some(std::process::id()), - // root_path is obsolete, use root_uri - root_path: None, - root_uri: root, + // root_path is obsolete, but some clients like pyright still use it so we specify both. + // clients will prefer _uri if possible + root_path: root_path.and_then(|path| path.to_str().map(|path| path.to_owned())), + root_uri, initialization_options: self.config.clone(), capabilities: lsp::ClientCapabilities { workspace: Some(lsp::WorkspaceClientCapabilities { |