RStudio

RStudio does not support the Language Server Protocol, but you can still use Air as an external formatter.

Installation

Air is currently only supported on macOS and Windows. Linux support is coming soon!

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.

Open Tools -> Global Options -> Code and change the option to use an External formatter. Then set the Reformat command to {path/to/air} format.

The easiest way to figure out {path/to/air} for yourself is to run which air from a Terminal on Unix, and where air from the Command Prompt on Windows.

Setting Air as an external formatter with Tools -> Global Options -> Code -> Formatting

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.

Setting RStudio to format all documents on save in Tools -> Global Options -> Code -> Saving

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.