add open Cargo.toml action
This commit is contained in:
@@ -1322,6 +1322,28 @@ pub(crate) fn handle_open_docs(
|
||||
Ok(remote.and_then(|remote| Url::parse(&remote).ok()))
|
||||
}
|
||||
|
||||
pub(crate) fn handle_open_cargo_toml(
|
||||
snap: GlobalStateSnapshot,
|
||||
params: lsp_ext::OpenCargoTomlParams,
|
||||
) -> Result<Option<lsp_types::GotoDefinitionResponse>> {
|
||||
let _p = profile::span("handle_open_cargo_toml");
|
||||
let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?;
|
||||
let maybe_cargo_spec = CargoTargetSpec::for_file(&snap, file_id)?;
|
||||
if maybe_cargo_spec.is_none() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let cargo_spec = maybe_cargo_spec.unwrap();
|
||||
let cargo_toml_path = cargo_spec.workspace_root.join("Cargo.toml");
|
||||
if !cargo_toml_path.exists() {
|
||||
return Ok(None);
|
||||
}
|
||||
let cargo_toml_url = to_proto::url_from_abs_path(&cargo_toml_path);
|
||||
let cargo_toml_location = Location::new(cargo_toml_url, Range::default());
|
||||
let res = lsp_types::GotoDefinitionResponse::from(cargo_toml_location);
|
||||
Ok(Some(res))
|
||||
}
|
||||
|
||||
fn implementation_title(count: usize) -> String {
|
||||
if count == 1 {
|
||||
"1 implementation".into()
|
||||
|
||||
Reference in New Issue
Block a user