on master help sign in
fix: Some LSPs still want rootPath, so provide it
84e799fBlaž Hrastnik
helix-lsp/src/client.rs+8−4
@@ -235,7 +235,10 @@ impl Client {
235
235
236 pub(crate) async fn initialize(&self) -> Result<lsp::InitializeResult> {
236 pub(crate) async fn initialize(&self) -> Result<lsp::InitializeResult> {
237 // TODO: delay any requests that are triggered prior to initialize
237 // 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()
239 .and_then(|root| lsp::Url::from_file_path(root).ok());
242 .and_then(|root| lsp::Url::from_file_path(root).ok());
240
243
241 if self.config.is_some() {
244 if self.config.is_some() {
@@ -245,9 +248,10 @@ impl Client {
245 #[allow(deprecated)]
248 #[allow(deprecated)]
246 let params = lsp::InitializeParams {
249 let params = lsp::InitializeParams {
247 process_id: Some(std::process::id()),
250 process_id: Some(std::process::id()),
248− // root_path is obsolete, use root_uri
251+ // root_path is obsolete, but some clients like pyright still use it so we specify both.
249− root_path: None,
252+ // clients will prefer _uri if possible
253+ root_path: root_path.and_then(|path| path.to_str().map(|path| path.to_owned())),
250− root_uri: root,
254+ root_uri,
251 initialization_options: self.config.clone(),
255 initialization_options: self.config.clone(),
252 capabilities: lsp::ClientCapabilities {
256 capabilities: lsp::ClientCapabilities {
253 workspace: Some(lsp::WorkspaceClientCapabilities {
257 workspace: Some(lsp::WorkspaceClientCapabilities {