I have been using the excellent
styler package, and its associated RStudio Add-Ins to automatically format R code. Along with CI and pre-commit hooks, this makes a great workflow to enforce standards without draconian barriers to code contributions.
However, one thing that is missing is a "File Watcher" capability in RStudio. When working in PyCharm IDE, I can set up a watcher to run a code formatter on a file every time I save. I haven't been able to tweak RStudio to get similar functionality working-- while I can use a hotkey to style my active file with
styler (I believe this can be done with
formatR as well), it is another step to remember in addition to saving the file.
Is there some way to set up File Watcher-esque functionality within RStudio that I haven't discovered? Or, does anyone have other suggestions for how I could set up a workflow that makes saving a file and formatting a file one and the same?