summaryrefslogtreecommitdiff
path: root/support/texlab/crates/texlab/src/features/completion/user_environment.rs
blob: 109925d623bb2ee51d35f8e20eac17783728b9fc (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
use base_db::DocumentData;

use crate::util::cursor::CursorContext;

use super::builder::CompletionBuilder;

pub fn complete<'db>(
    context: &'db CursorContext,
    builder: &mut CompletionBuilder<'db>,
) -> Option<()> {
    let range = context.find_environment_name()?;

    for document in &context.project.documents {
        let DocumentData::Tex(data) = &document.data else { continue };
        for name in data
            .semantics
            .environments
            .iter()
            .filter(|name| name.range != range)
        {
            builder.user_environment(range, &name.text);
        }
    }

    Some(())
}