Skip to content

Commit

Permalink
Change defaults to use 2 spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisVaughan committed Jan 8, 2025
1 parent 5bc60db commit eb7f512
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion crates/settings/src/indent_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use std::str::FromStr;
)]
pub enum IndentStyle {
/// Tab
#[default]
Tab,
/// Space
#[default]
Space,
}

Expand Down
6 changes: 3 additions & 3 deletions crates/settings/src/indent_width.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct IndentWidth(NonZeroU8);

impl IndentWidth {
/// Default value for [IndentWidth]
const DEFAULT: u8 = 4;
const DEFAULT: u8 = 2;

/// Maximum allowed value for a valid [IndentWidth]
const MAX: u8 = 24;
Expand Down Expand Up @@ -158,13 +158,13 @@ mod tests {
fn deserialize_indent_width() -> Result<()> {
let options: Options = toml::from_str(
r"
indent-width = 2
indent-width = 6
",
)?;

assert_eq!(
options.indent_width,
Some(IndentWidth::try_from(2).unwrap())
Some(IndentWidth::try_from(6).unwrap())
);

Ok(())
Expand Down
14 changes: 8 additions & 6 deletions crates/workspace/src/toml_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ pub struct FormatTomlOptions {

/// The number of spaces per indentation level (tab).
///
/// The value must be greater than or equal to `1` and less than or equal to `24`.
/// The value must be greater than or equal to `1` and less than or equal to `24`. The
/// default value is `2`.
///
/// Used by the formatter to determine the visual width of a tab.
///
Expand All @@ -65,23 +66,24 @@ pub struct FormatTomlOptions {

/// Whether to use spaces or tabs for indentation.
///
/// `indent-style = "tab"` (default):
/// `indent-style = "space"` (default):
///
/// ```r
/// fn <- function() {
/// cat("Hello") # A tab `\t` indents the `cat()` call.
/// cat("Hello") # Spaces indent the `cat()` call.
/// }
/// ```
///
/// `indent-style = "space"`:
/// `indent-style = "tab"`:
///
/// ```r
/// fn <- function() {
/// cat("Hello") # Spaces indent the `cat()` call.
/// cat("Hello") # A tab `\t` indents the `cat()` call.
/// }
/// ```
///
/// We recommend you use tabs for accessibility.
/// Air defaults to spaces due to the overwhelming amount of existing R code written
/// in this style, but consider using tabs for new projects to improve accessibility.
///
/// See `indent-width` to configure the number of spaces per indentation and the tab width.
pub indent_style: Option<IndentStyle>,
Expand Down

0 comments on commit eb7f512

Please sign in to comment.