use crate::editing::editor_config::LineEnding;
use crate::server::YamlVersion;
#[derive(Debug, Clone)]
#[expect(
clippy::struct_excessive_bools,
reason = "each bool is a distinct, well-named formatting option; a flags enum would add complexity for no benefit"
)]
pub struct YamlFormatOptions {
pub print_width: usize,
pub tab_width: usize,
pub single_quote: bool,
pub preserve_quotes: bool,
pub bracket_spacing: bool,
pub yaml_version: YamlVersion,
pub format_enforce_block_style: bool,
pub format_remove_duplicate_keys: bool,
pub format_indent_sequences: bool,
pub line_ending: LineEnding,
pub insert_final_newline: bool,
}
impl Default for YamlFormatOptions {
fn default() -> Self {
Self {
print_width: 80,
tab_width: 2,
single_quote: false,
preserve_quotes: false,
bracket_spacing: true,
yaml_version: YamlVersion::V1_2,
format_enforce_block_style: false,
format_remove_duplicate_keys: false,
format_indent_sequences: true,
line_ending: LineEnding::Lf,
insert_final_newline: true,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn format_enforce_block_style_defaults_to_false() {
assert!(!YamlFormatOptions::default().format_enforce_block_style);
}
#[test]
fn format_remove_duplicate_keys_defaults_to_false() {
assert!(!YamlFormatOptions::default().format_remove_duplicate_keys);
}
}