diff options
Diffstat (limited to 'support/texlab/src/features/formatting/latexindent.rs')
-rw-r--r-- | support/texlab/src/features/formatting/latexindent.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/support/texlab/src/features/formatting/latexindent.rs b/support/texlab/src/features/formatting/latexindent.rs index 3dab10c923..087b8f0941 100644 --- a/support/texlab/src/features/formatting/latexindent.rs +++ b/support/texlab/src/features/formatting/latexindent.rs @@ -10,12 +10,12 @@ use tempfile::tempdir; use crate::{ db::{Document, Language, Workspace}, util::line_index_ext::LineIndexExt, - Db, LatexindentOptions, + Db, LatexIndentConfig, }; pub fn format_with_latexindent(db: &dyn Db, document: Document) -> Option<Vec<TextEdit>> { let workspace = Workspace::get(db); - let options = workspace.options(db); + let config = db.config(); let target_dir = tempdir().ok()?; let source_dir = workspace .working_dir(db, document.directory(db)) @@ -29,9 +29,9 @@ pub fn format_with_latexindent(db: &dyn Db, document: Document) -> Option<Vec<Te } else { "file.tex" }); - std::fs::write(&target_file, document.contents(db).text(db)).ok()?; + std::fs::write(&target_file, document.text(db)).ok()?; - let args = build_arguments(&options.latexindent, &target_file); + let args = build_arguments(&config.formatting.latex_indent, &target_file); log::debug!( "Running latexindent in folder \"{}\" with args: {:?}", @@ -48,12 +48,12 @@ pub fn format_with_latexindent(db: &dyn Db, document: Document) -> Option<Vec<Te .output() .ok()?; - let old_text = document.contents(db).text(db); + let old_text = document.text(db); let new_text = String::from_utf8_lossy(&output.stdout).into_owned(); if new_text.is_empty() { None } else { - let line_index = document.contents(db).line_index(db); + let line_index = document.line_index(db); Some(vec![TextEdit { range: line_index.line_col_lsp_range(TextRange::new(0.into(), old_text.text_len())), new_text, @@ -61,15 +61,15 @@ pub fn format_with_latexindent(db: &dyn Db, document: Document) -> Option<Vec<Te } } -fn build_arguments(options: &LatexindentOptions, target_file: &Path) -> Vec<String> { +fn build_arguments(config: &LatexIndentConfig, target_file: &Path) -> Vec<String> { let mut args = Vec::new(); - args.push(match &options.local { + args.push(match &config.local { Some(yaml_file) => format!("--local={yaml_file}"), None => "--local".to_string(), }); - if options.modify_line_breaks { + if config.modify_line_breaks { args.push("--modifylinebreaks".to_string()); } |