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 anair.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 and Quarto 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. Likewise, sets the default formatter for Quarto.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 Air's 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 may be an additional manual step you must take before using Air for the first time:
For RStudio, follow the installation guide.
For Positron, the Air extension is installed by default and that already includes the Air binary. A typical Positron user does not need to do anything about installing Air.
For VS Code, install the VS Code Extension.
For other editors, check to see if that editor is supported by Air.