blob: bf1569572226f62baf58a9828579398c6d44c715 (
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
|
use lsp_types::CompletionParams;
use rowan::ast::AstNode;
use crate::{features::cursor::CursorContext, syntax::latex, LANGUAGE_DATA};
use super::types::{InternalCompletionItem, InternalCompletionItemData};
pub fn complete_tikz_libraries<'a>(
context: &'a CursorContext<CompletionParams>,
items: &mut Vec<InternalCompletionItem<'a>>,
) -> Option<()> {
let (_, range, group) = context.find_curly_group_word_list()?;
let import = latex::TikzLibraryImport::cast(group.syntax().parent()?)?;
if import.command()?.text() == "\\usepgflibrary" {
for name in &LANGUAGE_DATA.pgf_libraries {
items.push(InternalCompletionItem::new(
range,
InternalCompletionItemData::PgfLibrary { name },
));
}
} else {
for name in &LANGUAGE_DATA.tikz_libraries {
items.push(InternalCompletionItem::new(
range,
InternalCompletionItemData::TikzLibrary { name },
));
}
}
Some(())
}
|