summaryrefslogtreecommitdiff
path: root/support/texlab/src/features/hover/label.rs
blob: 2f8489d76996c9781d732017f237746a85e1cc9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use lsp_types::{HoverParams, MarkupKind};

use crate::{features::cursor::CursorContext, render_label};

use super::HoverResult;

pub(super) fn find_label_hover(context: &CursorContext<HoverParams>) -> Option<HoverResult> {
    let (name_text, range) = context
        .find_label_name_key()
        .or_else(|| context.find_label_name_command())?;

    let label = render_label(&context.request.workspace, &name_text, None)?;

    Some(HoverResult {
        range,
        value: label.reference(),
        value_kind: MarkupKind::PlainText,
    })
}