Skip to content

Commit 84e799f

Browse files
committed
fix: Some LSPs still want rootPath, so provide it
Refs #1898
1 parent 5d61631 commit 84e799f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

helix-lsp/src/client.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,10 @@ impl Client {
235235

236236
pub(crate) async fn initialize(&self) -> Result<lsp::InitializeResult> {
237237
// TODO: delay any requests that are triggered prior to initialize
238-
let root = find_root(None, &self.root_markers)
238+
let root_path = find_root(None, &self.root_markers);
239+
240+
let root_uri = root_path
241+
.clone()
239242
.and_then(|root| lsp::Url::from_file_path(root).ok());
240243

241244
if self.config.is_some() {
@@ -245,9 +248,10 @@ impl Client {
245248
#[allow(deprecated)]
246249
let params = lsp::InitializeParams {
247250
process_id: Some(std::process::id()),
248-
// root_path is obsolete, use root_uri
249-
root_path: None,
250-
root_uri: root,
251+
// root_path is obsolete, but some clients like pyright still use it so we specify both.
252+
// clients will prefer _uri if possible
253+
root_path: root_path.and_then(|path| path.to_str().map(|path| path.to_owned())),
254+
root_uri,
251255
initialization_options: self.config.clone(),
252256
capabilities: lsp::ClientCapabilities {
253257
workspace: Some(lsp::WorkspaceClientCapabilities {

0 commit comments

Comments
 (0)