texlab/features/completion/
user_environment.rs1use lsp_types::CompletionParams;
2
3use crate::features::cursor::CursorContext;
4
5use super::types::{InternalCompletionItem, InternalCompletionItemData};
6
7pub fn complete_user_environments<'a>(
8 context: &'a CursorContext<CompletionParams>,
9 items: &mut Vec<InternalCompletionItem<'a>>,
10) -> Option<()> {
11 let (name, range) = context.find_environment_name()?;
12
13 for document in context.request.workspace.iter() {
14 if let Some(data) = document.data().as_latex() {
15 for name in data
16 .extras
17 .environment_names
18 .iter()
19 .filter(|n| n.as_str() != name)
20 .cloned()
21 {
22 items.push(InternalCompletionItem::new(
23 range,
24 InternalCompletionItemData::UserEnvironment { name },
25 ));
26 }
27 }
28 }
29
30 Some(())
31}