diff options
author | Norbert Preining <norbert@preining.info> | 2021-05-23 03:00:39 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2021-05-23 03:00:39 +0000 |
commit | f1261b349e875b842745b63258c3e338cb1fe3bf (patch) | |
tree | b5d402b3e80818cde2c079a42249f3dcb9732247 /support/texlab/src/features/formatting.rs | |
parent | 58aa1ac09b1d9e4769d0a0661cf12e2b2db41b14 (diff) |
CTAN sync 202105230300
Diffstat (limited to 'support/texlab/src/features/formatting.rs')
-rw-r--r-- | support/texlab/src/features/formatting.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/support/texlab/src/features/formatting.rs b/support/texlab/src/features/formatting.rs new file mode 100644 index 0000000000..4492a0532d --- /dev/null +++ b/support/texlab/src/features/formatting.rs @@ -0,0 +1,24 @@ +mod bibtex_internal; +mod latexindent; + +use cancellation::CancellationToken; +use lsp_types::{DocumentFormattingParams, TextEdit}; + +use crate::BibtexFormatter; + +use self::{bibtex_internal::format_bibtex_internal, latexindent::format_with_latexindent}; + +use super::FeatureRequest; + +pub fn format_source_code( + request: FeatureRequest<DocumentFormattingParams>, + cancellation_token: &CancellationToken, +) -> Option<Vec<TextEdit>> { + let mut edits = None; + if request.context.options.read().unwrap().bibtex_formatter == BibtexFormatter::Texlab { + edits = edits.or_else(|| format_bibtex_internal(&request, cancellation_token)); + } + + edits = edits.or_else(|| format_with_latexindent(&request, cancellation_token)); + edits +} |