summaryrefslogtreecommitdiff
path: root/support/texlab/crates/texlab/src/features/completion/user_environment.rs
blob: 4e06eac6da96f1ad0f7ec357e5172f597eeead4c (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 (name, 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(|n| n.as_str() != name)
        {
            builder.user_environment(range, name);
        }
    }

    Some(())
}