Skip to content

Commit

Permalink
Add latexindent replacement options (#1241)
Browse files Browse the repository at this point in the history
Add an option field "replacement" to the LatexIndentConfig structs, and modify the build_arguments function to check if it config.replacement contains one of "-r", "-rr", or "-rv". If so, it appends that to the list of arguments to LatexIndent. If it does not exist, or it contains any other string, the option is ignored.
  • Loading branch information
nolanking90 authored Oct 19, 2024
1 parent 4a25391 commit 410adf5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/base-db/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub enum Formatter {
pub struct LatexIndentConfig {
pub local: Option<String>,
pub modify_line_breaks: bool,
pub replacement: Option<String>,
}

#[derive(Debug, Default)]
Expand Down
9 changes: 9 additions & 0 deletions crates/texlab/src/features/formatting/latexindent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ fn build_arguments(config: &LatexIndentConfig, target_file: &Path) -> Vec<String
args.push("--modifylinebreaks".to_string());
}

match &config.replacement {
Some(replacement_flag) => {
if ["-r", "-rv", "-rr"].contains(& replacement_flag.as_str()) {
args.push(replacement_flag.clone());
}
},
None => {}
}

args.push(target_file.display().to_string());
args
}
1 change: 1 addition & 0 deletions crates/texlab/src/server/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ impl Default for LatexFormatter {
pub struct LatexindentOptions {
pub local: Option<String>,
pub modify_line_breaks: bool,
pub replacement: Option<String>,
}

#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)]
Expand Down
1 change: 1 addition & 0 deletions crates/texlab/src/util/from_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ pub fn config(value: Options) -> Config {

config.formatting.latex_indent.local = value.latexindent.local;
config.formatting.latex_indent.modify_line_breaks = value.latexindent.modify_line_breaks;
config.formatting.latex_indent.replacement = value.latexindent.replacement;

config.synctex = value
.forward_search
Expand Down

0 comments on commit 410adf5

Please sign in to comment.