Hi there,
I see that RStudio now has format-on-save functionality as of RStudio 2024.12.0 (details on issue that led to it here). Still, I'm having a few challenges using it in practice, specifically around the options in Options > Code > Formatting. I'm curious if folks have any solutions to the following issues.
- Using the 'styler' option requires that styler be present in the current environment. Because i use renv and the default snapshot options, unless styler appears in my code, it isn't snapshotted, and won't be present for the end user. It seems like the best approach is to update the .Rprofile for a project to install styler if it doesn't exist, but this seems hacky. Is there a way to make RStudio's "styler" option work alongside renv without this RProfile trick?
- It's not clear to me how to use the "External" option, which allows the user to "Use an external application to format code" and prompts for "Reformat command". Are there any docs on how to use this? I've skimmed the PR that added it and the RStudio docs and don't see anything that would help much. I'm also not aware of any R code formatters that run in a standalone process (e.g., something you can call from the command line). Any one have any guidance here?
Thanks! For context, i'm operating in a team environment, so just looking for solutions that are easy to onboard others to and keep consistent across our many projects together.