summaryrefslogtreecommitdiff
path: root/support/texlab/src/completion/latex/begin_command.rs
blob: ce6ba17afab5937b5be16da42645119bae8908e2 (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
use super::combinators;
use crate::completion::factory::{self, LatexComponentId};
use crate::workspace::*;
use futures_boxed::boxed;
use lsp_types::{CompletionItem, CompletionParams};

#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct LatexBeginCommandCompletionProvider;

impl FeatureProvider for LatexBeginCommandCompletionProvider {
    type Params = CompletionParams;
    type Output = Vec<CompletionItem>;

    #[boxed]
    async fn execute<'a>(&'a self, request: &'a FeatureRequest<Self::Params>) -> Self::Output {
        combinators::command(request, |_| {
            async move {
                let snippet = factory::command_snippet(
                    request,
                    "begin",
                    None,
                    "begin{$1}\n\t$0\n\\end{$1}",
                    &LatexComponentId::kernel(),
                );
                vec![snippet]
            }
        })
        .await
    }
}