lsp: Fill root_uri property on Initialize again (#25264)
Closes #ISSUE Release Notes: - Fix some language servers (elixir-ls, tailwindcss, phpactor) failing to start up due to an unfilled root_uri property in the InitializeParams Co-authored-by: Anthony Eid <hello@anthonyeid.me>
This commit is contained in:
parent
300ed6bb4a
commit
3a222f0666
1 changed files with 19 additions and 1 deletions
|
@ -100,6 +100,7 @@ pub struct LanguageServer {
|
||||||
output_done_rx: Mutex<Option<barrier::Receiver>>,
|
output_done_rx: Mutex<Option<barrier::Receiver>>,
|
||||||
server: Arc<Mutex<Option<Child>>>,
|
server: Arc<Mutex<Option<Child>>>,
|
||||||
workspace_folders: Arc<Mutex<BTreeSet<Url>>>,
|
workspace_folders: Arc<Mutex<BTreeSet<Url>>>,
|
||||||
|
root_uri: Url,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Identifies a running language server.
|
/// Identifies a running language server.
|
||||||
|
@ -369,6 +370,8 @@ impl LanguageServer {
|
||||||
let stdin = server.stdin.take().unwrap();
|
let stdin = server.stdin.take().unwrap();
|
||||||
let stdout = server.stdout.take().unwrap();
|
let stdout = server.stdout.take().unwrap();
|
||||||
let stderr = server.stderr.take().unwrap();
|
let stderr = server.stderr.take().unwrap();
|
||||||
|
let root_uri = Url::from_file_path(&working_dir)
|
||||||
|
.map_err(|_| anyhow!("{} is not a valid URI", working_dir.display()))?;
|
||||||
let server = Self::new_internal(
|
let server = Self::new_internal(
|
||||||
server_id,
|
server_id,
|
||||||
server_name,
|
server_name,
|
||||||
|
@ -379,6 +382,7 @@ impl LanguageServer {
|
||||||
Some(server),
|
Some(server),
|
||||||
code_action_kinds,
|
code_action_kinds,
|
||||||
binary,
|
binary,
|
||||||
|
root_uri,
|
||||||
cx,
|
cx,
|
||||||
move |notification| {
|
move |notification| {
|
||||||
log::info!(
|
log::info!(
|
||||||
|
@ -404,6 +408,7 @@ impl LanguageServer {
|
||||||
server: Option<Child>,
|
server: Option<Child>,
|
||||||
code_action_kinds: Option<Vec<CodeActionKind>>,
|
code_action_kinds: Option<Vec<CodeActionKind>>,
|
||||||
binary: LanguageServerBinary,
|
binary: LanguageServerBinary,
|
||||||
|
root_uri: Url,
|
||||||
cx: AsyncApp,
|
cx: AsyncApp,
|
||||||
on_unhandled_notification: F,
|
on_unhandled_notification: F,
|
||||||
) -> Self
|
) -> Self
|
||||||
|
@ -487,6 +492,7 @@ impl LanguageServer {
|
||||||
output_done_rx: Mutex::new(Some(output_done_rx)),
|
output_done_rx: Mutex::new(Some(output_done_rx)),
|
||||||
server: Arc::new(Mutex::new(server)),
|
server: Arc::new(Mutex::new(server)),
|
||||||
workspace_folders: Default::default(),
|
workspace_folders: Default::default(),
|
||||||
|
root_uri,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,7 +621,7 @@ impl LanguageServer {
|
||||||
InitializeParams {
|
InitializeParams {
|
||||||
process_id: None,
|
process_id: None,
|
||||||
root_path: None,
|
root_path: None,
|
||||||
root_uri: None,
|
root_uri: Some(self.root_uri.clone()),
|
||||||
initialization_options: None,
|
initialization_options: None,
|
||||||
capabilities: ClientCapabilities {
|
capabilities: ClientCapabilities {
|
||||||
general: Some(GeneralClientCapabilities {
|
general: Some(GeneralClientCapabilities {
|
||||||
|
@ -1385,6 +1391,7 @@ impl FakeLanguageServer {
|
||||||
|
|
||||||
let server_name = LanguageServerName(name.clone().into());
|
let server_name = LanguageServerName(name.clone().into());
|
||||||
let process_name = Arc::from(name.as_str());
|
let process_name = Arc::from(name.as_str());
|
||||||
|
let root = Self::root_path();
|
||||||
let mut server = LanguageServer::new_internal(
|
let mut server = LanguageServer::new_internal(
|
||||||
server_id,
|
server_id,
|
||||||
server_name.clone(),
|
server_name.clone(),
|
||||||
|
@ -1395,6 +1402,7 @@ impl FakeLanguageServer {
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
binary.clone(),
|
binary.clone(),
|
||||||
|
root,
|
||||||
cx.clone(),
|
cx.clone(),
|
||||||
|_| {},
|
|_| {},
|
||||||
);
|
);
|
||||||
|
@ -1412,6 +1420,7 @@ impl FakeLanguageServer {
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
binary,
|
binary,
|
||||||
|
Self::root_path(),
|
||||||
cx.clone(),
|
cx.clone(),
|
||||||
move |msg| {
|
move |msg| {
|
||||||
notifications_tx
|
notifications_tx
|
||||||
|
@ -1446,6 +1455,15 @@ impl FakeLanguageServer {
|
||||||
|
|
||||||
(server, fake)
|
(server, fake)
|
||||||
}
|
}
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
fn root_path() -> Url {
|
||||||
|
Url::from_file_path("C:/").unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
fn root_path() -> Url {
|
||||||
|
Url::from_file_path("/").unwrap()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue