blob: 5ed7ce5121076de7133b6c5b5b312711abc919bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
use base_db::semantics::tex::LabelKind;
use lsp_types::MarkupKind;
use crate::util::{self, cursor::CursorContext};
use super::HoverResult;
pub(super) fn find_hover(context: &CursorContext) -> Option<HoverResult> {
let (name_text, range) = context
.find_label_name_key()
.or_else(|| context.find_label_name_command())?;
context
.project
.documents
.iter()
.filter_map(|document| document.data.as_tex())
.flat_map(|data| data.semantics.labels.iter())
.find(|label| label.kind == LabelKind::Definition && label.name.text == name_text)
.and_then(|label| util::label::render(context.workspace, &context.project, label))
.map(|label| HoverResult {
range,
value: label.reference(),
value_kind: MarkupKind::PlainText,
})
}
|