Skip to content

Air is an extremely fast R code formatter. This function sets up a project to use Air. Specifically, it:

  • Creates an empty air.toml configuration file. If either an air.toml or .air.toml file already existed, nothing is changed. If the project is an R package, .Rbuildignore is updated to ignore this file.

  • Creates a .vscode/ directory and adds recommended settings to .vscode/settings.json and .vscode/extensions.json. These settings are used by the Air extension installed through either VS Code or Positron, see the Installation section for more details. Specifically it:

    • Sets editor.formatOnSave = true for R files to enable formatting on every save.

    • Sets editor.defaultFormatter to Air for R files to ensure that Air is always selected as the formatter for this project.

    • Sets the Air extension as a "recommended" extension for this project, which triggers a notification for contributors coming to this project that don't yet have the Air extension installed.

    If the project is an R package, .Rbuildignore is updated to ignore the .vscode/ directory.

    If you'd like to opt out of VS Code / Positron specific setup, set vscode = FALSE, but remember that even if you work in RStudio, other contributors may prefer another editor.

Note that use_air() does not actually invoke Air, it just configures your project with the recommended settings. Consult the editors guide to learn how to invoke Air in your preferred editor.

Installation

Note that this setup does not install an Air binary, so there is an additional manual step you must take before using Air for the first time:

Usage

use_air(vscode = TRUE)

Arguments

vscode

Either:

  • TRUE to set up VS Code and Positron specific Air settings. This is the default.

  • FALSE to opt out of those settings.

Examples

if (FALSE) { # \dontrun{
# Prepare an R package or project to use Air
use_air()
} # }