RStudio
RStudio does not support the Language Server Protocol, but you can still use Air as an external formatter.
Installation
Ensure you have at least RStudio version 2024.12.0, which you can download from here. Additionally, you’ll need to install the Air command line tool.
Next, you’ll need to tell RStudio to use Air as an external formatter:
Open
Tools -> Global Options -> Code
Choose the
Formatting
tab at the topChange the
Code formatter:
option toExternal
Change the
Reformat command:
to{path/to/air} format
Note that you set this to a partially complete command! RStudio will append the name of the file to this partial command, but you must specify
format
in addition to the path to Air for it to work.The easiest way to figure out
{path/to/air}
for yourself is to runwhich air
from a Terminal on Unix, andwhere air
from the Command Prompt on Windows.
Apply the changes and exit the settings.
At this point, explicit calls to Reformat Selection
and Reformat Document
should use Air. If you’d also like RStudio to invoke Air on save, follow the instructions in Format on Save.
Features
Format on save
After you’ve set Air as an external formatter, you can either tell RStudio to format all documents on save, or set this on a per document basis.
To format all documents on save, open Tools -> Global Options -> Code -> Saving
and check Reformat documents on save
.
To format individual documents on save, open the file specific settings and check Reformat Document on Save
.
Quarto
There is currently no way to use Air in RStudio with Quarto documents.