summaryrefslogtreecommitdiff
path: root/support/texlab/crates/texlab/src/features/hover/entry_type.rs
blob: 8875b30b2e6f4e780beb0027e16c3036cfafd65e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use lsp_types::MarkupKind;
use syntax::bibtex;

use crate::util::{cursor::CursorContext, lang_data::LANGUAGE_DATA};

use super::HoverResult;

pub(super) fn find_hover(context: &CursorContext) -> Option<HoverResult> {
    let name = context
        .cursor
        .as_bib()
        .filter(|token| token.kind() == bibtex::TYPE)?;

    let docs = LANGUAGE_DATA.entry_type_documentation(&name.text()[1..])?;
    Some(HoverResult {
        range: name.text_range(),
        value: docs.to_string(),
        value_kind: MarkupKind::Markdown,
    })
}