blob: 8c4d593bee3f4101a0594a1b6e27a92f661f5a34 (
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
|
use lsp_types::CompletionParams;
use crate::features::cursor::CursorContext;
use super::types::{InternalCompletionItem, InternalCompletionItemData};
pub fn complete_user_commands<'a>(
context: &'a CursorContext<CompletionParams>,
items: &mut Vec<InternalCompletionItem<'a>>,
) -> Option<()> {
let range = context.cursor.command_range(context.offset)?;
let token = context.cursor.as_latex()?;
for document in context.request.workspace.documents_by_uri.values() {
if let Some(data) = document.data.as_latex() {
for name in data
.extras
.command_names
.iter()
.filter(|name| name.as_str() != token.text())
.cloned()
{
items.push(InternalCompletionItem::new(
range,
InternalCompletionItemData::UserCommand { name },
));
}
}
}
Some(())
}
|