blob: 4d262a68913472c03bd52e6541a68dffd12b6a7f (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
|
use crate::completion::DATABASE;
use crate::range::RangeExt;
use crate::syntax::*;
use crate::workspace::*;
use futures_boxed::boxed;
use lsp_types::{Hover, HoverContents, TextDocumentPositionParams};
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct LatexComponentHoverProvider;
impl FeatureProvider for LatexComponentHoverProvider {
type Params = TextDocumentPositionParams;
type Output = Option<Hover>;
#[boxed]
async fn execute<'a>(
&'a self,
request: &'a FeatureRequest<TextDocumentPositionParams>,
) -> Option<Hover> {
if let SyntaxTree::Latex(tree) = &request.document().tree {
for include in &tree.includes {
if include.kind == LatexIncludeKind::Package
|| include.kind == LatexIncludeKind::Class
{
for path in include.paths() {
if path.range().contains(request.params.position) {
let documentation = DATABASE.documentation(path.text())?;
return Some(Hover {
contents: HoverContents::Markup(documentation),
range: Some(path.range()),
});
}
}
}
}
}
None
}
}
|