WIP: Command to open docs under cursor

This commit is contained in:
Zac Pullar-Strecker
2020-08-30 20:02:29 +12:00
parent e95e666b10
commit bfda0d2583
9 changed files with 176 additions and 4 deletions

View File

@@ -34,7 +34,7 @@ use crate::{
config::RustfmtConfig,
from_json, from_proto,
global_state::{GlobalState, GlobalStateSnapshot},
lsp_ext::{self, InlayHint, InlayHintsParams},
lsp_ext::{self, DocumentationLink, InlayHint, InlayHintsParams, OpenDocsParams},
to_proto, LspError, Result,
};
@@ -1310,6 +1310,19 @@ pub(crate) fn handle_semantic_tokens_range(
Ok(Some(semantic_tokens.into()))
}
pub(crate) fn handle_open_docs(
snap: GlobalStateSnapshot,
params: OpenDocsParams,
) -> Result<DocumentationLink> {
let _p = profile::span("handle_open_docs");
let position = from_proto::file_position(&snap, params.position)?;
// FIXME: Propogate or ignore this error instead of panicking.
let remote = snap.analysis.get_doc_url(position)?.unwrap();
Ok(DocumentationLink { remote })
}
fn implementation_title(count: usize) -> String {
if count == 1 {
"1 implementation".into()