rust: Fix looking up rust-analyzer
in $PATH
by default (#17926)
This is a follow-up to https://github.com/zed-industries/zed/pull/17885, which is reverted and fixed in this PR. This PR actually enables the behavior by default. Release Notes: - Changed `rust-analyzer` support to lookup `rust-analyzer` binaries by default in `$PATH`. That changes the default value to something users requested.
This commit is contained in:
parent
7d97855ed7
commit
d56e3d99b4
1 changed files with 45 additions and 35 deletions
|
@ -38,45 +38,55 @@ impl LspAdapter for RustLspAdapter {
|
||||||
delegate: &dyn LspAdapterDelegate,
|
delegate: &dyn LspAdapterDelegate,
|
||||||
cx: &AsyncAppContext,
|
cx: &AsyncAppContext,
|
||||||
) -> Option<LanguageServerBinary> {
|
) -> Option<LanguageServerBinary> {
|
||||||
let configured_binary = cx.update(|cx| {
|
let configured_binary = cx
|
||||||
language_server_settings(delegate, Self::SERVER_NAME, cx).and_then(|s| s.binary.clone())
|
.update(|cx| {
|
||||||
});
|
language_server_settings(delegate, Self::SERVER_NAME, cx)
|
||||||
|
.and_then(|s| s.binary.clone())
|
||||||
|
})
|
||||||
|
.ok()?;
|
||||||
|
|
||||||
match configured_binary {
|
let (path, env, arguments) = match configured_binary {
|
||||||
Ok(Some(BinarySettings {
|
// If nothing is configured, or path_lookup explicitly enabled,
|
||||||
path,
|
// we lookup the binary in the path.
|
||||||
|
None
|
||||||
|
| Some(BinarySettings {
|
||||||
|
path: None,
|
||||||
|
path_lookup: Some(true),
|
||||||
|
..
|
||||||
|
})
|
||||||
|
| Some(BinarySettings {
|
||||||
|
path: None,
|
||||||
|
path_lookup: None,
|
||||||
|
..
|
||||||
|
}) => {
|
||||||
|
let path = delegate.which(Self::SERVER_NAME.as_ref()).await;
|
||||||
|
let env = delegate.shell_env().await;
|
||||||
|
(path, Some(env), None)
|
||||||
|
}
|
||||||
|
// Otherwise, we use the configured binary.
|
||||||
|
Some(BinarySettings {
|
||||||
|
path: Some(path),
|
||||||
arguments,
|
arguments,
|
||||||
path_lookup,
|
path_lookup,
|
||||||
})) => {
|
}) => {
|
||||||
let (path, env) = match (path, path_lookup) {
|
if path_lookup.is_some() {
|
||||||
(Some(path), lookup) => {
|
log::warn!("Both `path` and `path_lookup` are set, ignoring `path_lookup`");
|
||||||
if lookup.is_some() {
|
}
|
||||||
log::warn!(
|
(Some(path.into()), None, arguments)
|
||||||
"Both `path` and `path_lookup` are set, ignoring `path_lookup`"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
(Some(path.into()), None)
|
|
||||||
}
|
|
||||||
(None, Some(true)) | (None, None) => {
|
|
||||||
// Try to lookup rust-analyzer in PATH by default.
|
|
||||||
let path = delegate.which(Self::SERVER_NAME.as_ref()).await?;
|
|
||||||
let env = delegate.shell_env().await;
|
|
||||||
(Some(path), Some(env))
|
|
||||||
}
|
|
||||||
(None, Some(false)) => (None, None),
|
|
||||||
};
|
|
||||||
path.map(|path| LanguageServerBinary {
|
|
||||||
path,
|
|
||||||
arguments: arguments
|
|
||||||
.unwrap_or_default()
|
|
||||||
.iter()
|
|
||||||
.map(|arg| arg.into())
|
|
||||||
.collect(),
|
|
||||||
env,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
_ => None,
|
|
||||||
}
|
_ => (None, None, None),
|
||||||
|
};
|
||||||
|
|
||||||
|
path.map(|path| LanguageServerBinary {
|
||||||
|
path,
|
||||||
|
env,
|
||||||
|
arguments: arguments
|
||||||
|
.unwrap_or_default()
|
||||||
|
.iter()
|
||||||
|
.map(|arg| arg.into())
|
||||||
|
.collect(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_latest_server_version(
|
async fn fetch_latest_server_version(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue