use_air() also turns on "format on save" for qmd + other updates - #2136
Conversation
| #' - For Positron, install the [OpenVSX | ||
| #' Extension](https://open-vsx.org/extension/posit/air-vscode). | ||
| #' - For Positron, the [Air extension](https://open-vsx.org/extension/posit/air-vscode) | ||
| #' is installed by default and that already includes the Air binary. A typical | ||
| #' Positron user does not need to do anything about installing Air. |
There was a problem hiding this comment.
Note: we needed this important update anyway!
DavisVaughan
left a comment
There was a problem hiding this comment.
Looks good, just a question about the ^[\.]?air\.toml$ change
| air_toml_regex <- function() { | ||
| # Pre-escaped regex allowing both `air.toml` and `.air.toml` | ||
| "^[\\.]?air\\.toml$" | ||
| "^[.]?air[.]toml$" |
There was a problem hiding this comment.
I believe the \\. was purposeful. i.e. we have ^\.vscode$ in our Rbuildignore along with many other \. usage.
Unless the [] does something special, I think we should end up with [\.] as well, otherwise doesn't a lone . mean "anything" or something like that?
There was a problem hiding this comment.
[] is commonly used as a less heavy quote syntax for single characters. I like it as it's easier to read.
There was a problem hiding this comment.
It's perhaps a really small hill to die on, but, yes, I am a big fan of using [] instead of escaping, when possible. (But yes, you'll see some escaping in usethis because history.) I really don't care deeply about this.
| settings <- jsonlite::read_json(path) | ||
| settings_r <- settings[["[r]"]] | ||
|
|
||
| if (is.null(settings_r)) { | ||
| # Mock it | ||
| settings_r <- set_names(list()) | ||
| } | ||
|
|
||
| # Set these regardless of their previous values. Assume that calling | ||
| # `use_air()` is an explicit request to opt in to these settings. | ||
| settings_r[["editor.formatOnSave"]] <- TRUE | ||
| settings_r[["editor.defaultFormatter"]] <- "Posit.air-vscode" | ||
|
|
||
| settings[["[r]"]] <- settings_r |
There was a problem hiding this comment.
I was a little worried modifyList() would overwrite an existing [r] or [quarto] setting that wasn't formatOnSave or defaultFormatter, but I see your new test with
"[quarto]" = list(
"editor.wordWrap" = "wordWrapColumn"
)
And it looks like it preserves that, so that's a win for modifyList() I guess 馃憤
There was a problem hiding this comment.
It really is designed for exactly this.
| air_toml_regex <- function() { | ||
| # Pre-escaped regex allowing both `air.toml` and `.air.toml` | ||
| "^[\\.]?air\\.toml$" | ||
| "^[.]?air[.]toml$" |
There was a problem hiding this comment.
[] is commonly used as a less heavy quote syntax for single characters. I like it as it's easier to read.
Co-authored-by: Davis Vaughan <davis@rstudio.com>

Closes #2135