summaryrefslogtreecommitdiff
path: root/support/texlab/src/folding/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'support/texlab/src/folding/mod.rs')
-rw-r--r--support/texlab/src/folding/mod.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/support/texlab/src/folding/mod.rs b/support/texlab/src/folding/mod.rs
new file mode 100644
index 0000000000..52c8149a31
--- /dev/null
+++ b/support/texlab/src/folding/mod.rs
@@ -0,0 +1,45 @@
+mod bibtex_declaration;
+mod latex_environment;
+mod latex_section;
+
+use self::bibtex_declaration::BibtexDeclarationFoldingProvider;
+use self::latex_environment::LatexEnvironmentFoldingProvider;
+use self::latex_section::LatexSectionFoldingProvider;
+use crate::workspace::*;
+use futures_boxed::boxed;
+use lsp_types::{FoldingRange, FoldingRangeParams};
+
+pub struct FoldingProvider {
+ provider: ConcatProvider<FoldingRangeParams, FoldingRange>,
+}
+
+impl FoldingProvider {
+ pub fn new() -> Self {
+ Self {
+ provider: ConcatProvider::new(vec![
+ Box::new(BibtexDeclarationFoldingProvider),
+ Box::new(LatexEnvironmentFoldingProvider),
+ Box::new(LatexSectionFoldingProvider),
+ ]),
+ }
+ }
+}
+
+impl Default for FoldingProvider {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
+impl FeatureProvider for FoldingProvider {
+ type Params = FoldingRangeParams;
+ type Output = Vec<FoldingRange>;
+
+ #[boxed]
+ async fn execute<'a>(
+ &'a self,
+ request: &'a FeatureRequest<FoldingRangeParams>,
+ ) -> Vec<FoldingRange> {
+ self.provider.execute(request).await
+ }
+}