I am new to R and am trying to set up a minimal R development environment on my machine. I want to set up an auto-formatter for R code which formats my code upon save (Like prettier, ruff or rustfmt).
After looking into the problem it seems like styler and formatR packages seem to do what I want, but these offer API's to format files from R code using functions. What I want is a command line tool (like ruff or rustfmt) with which I can set up a hook to format my files on save from my editor (Neovim and Helix). However upon going through the documentation of the libraries, neither seem to provide a command line utility.
effectively what I want is to run the following from a terminal:
toolname Rfile.R
and get the formatted version of RFile.R.
Does anyone have any suggestions on how I can go about this? Any help is greatly appreciated.
Rscript? stackoverflow.com/questions/28543490/…. If you're on a Unix machine you can add a shebang and make the R-file executable as well.