1313# ' used by the Air extension installed through either VS Code or Positron, see
1414# ' the Installation section for more details. Specifically it:
1515# '
16- # ' - Sets `editor.formatOnSave = true` for R files to enable formatting on
17- # ' every save.
16+ # ' - Sets `editor.formatOnSave = true` for R and Quarto files to enable
17+ # ' formatting on every save.
1818# '
1919# ' - Sets `editor.defaultFormatter` to Air for R files to ensure that Air is
20- # ' always selected as the formatter for this project.
20+ # ' always selected as the formatter for this project. Likewise, sets the
21+ # ' default formatter for Quarto.
2122# '
2223# ' - Sets the Air extension as a "recommended" extension for this project,
2324# ' which triggers a notification for contributors coming to this project
3132# ' may prefer another editor.
3233# '
3334# ' Note that `use_air()` does not actually invoke Air, it just configures your
34- # ' project with the recommended settings. Consult the [ editors
35+ # ' project with the recommended settings. Consult [Air's editors
3536# ' guide](https://posit-dev.github.io/air/editors.html) to learn how to invoke
3637# ' Air in your preferred editor.
3738# '
3839# ' ## Installation
3940# '
40- # ' Note that this setup does not install an Air binary, so there is an
41+ # ' Note that this setup does not install an Air binary, so there may be an
4142# ' additional manual step you must take before using Air for the first time:
4243# '
4344# ' - For RStudio, follow the [installation
4445# ' guide](https://posit-dev.github.io/air/editor-rstudio.html).
4546# '
46- # ' - For Positron, install the [OpenVSX
47- # ' Extension](https://open-vsx.org/extension/posit/air-vscode).
47+ # ' - For Positron, the [Air extension](https://open-vsx.org/extension/posit/air-vscode)
48+ # ' is installed by default and that already includes the Air binary. A typical
49+ # ' Positron user does not need to do anything to install Air.
4850# '
4951# ' - For VS Code, install the [VS Code
5052# ' Extension](https://marketplace.visualstudio.com/items?itemName=Posit.air-vscode).
@@ -118,7 +120,7 @@ create_air_toml <- function(ignore = FALSE) {
118120
119121air_toml_regex <- function () {
120122 # Pre-escaped regex allowing both `air.toml` and `.air.toml`
121- " ^[\\ .]?air\\ . toml$"
123+ " ^[.]?air[.] toml$"
122124}
123125
124126create_vscode_json_file <- function (name ) {
@@ -142,20 +144,19 @@ create_vscode_json_file <- function(name) {
142144}
143145
144146write_air_vscode_settings_json <- function (path ) {
145- settings <- jsonlite :: read_json(path )
146- settings_r <- settings [[" [r]" ]]
147-
148- if (is.null(settings_r )) {
149- # Mock it
150- settings_r <- set_names(list ())
151- }
152-
153- # Set these regardless of their previous values. Assume that calling
154- # `use_air()` is an explicit request to opt in to these settings.
155- settings_r [[" editor.formatOnSave" ]] <- TRUE
156- settings_r [[" editor.defaultFormatter" ]] <- " Posit.air-vscode"
157-
158- settings [[" [r]" ]] <- settings_r
147+ settings <- jsonlite :: read_json(path ) %|| % set_names(list ())
148+
149+ patch <- list (
150+ `[r]` = list (
151+ " editor.formatOnSave" = TRUE ,
152+ " editor.defaultFormatter" = " Posit.air-vscode"
153+ ),
154+ `[quarto]` = list (
155+ " editor.formatOnSave" = TRUE ,
156+ " editor.defaultFormatter" = " quarto.quarto"
157+ )
158+ )
159+ settings <- utils :: modifyList(settings , patch )
159160
160161 write_vscode_json(x = settings , path = path )
161162}
0 commit comments