formatR icon indicating copy to clipboard operation
formatR copied to clipboard

A pre-commit hook for `formatR`

Open fabianegli opened this issue 3 years ago • 4 comments

It would be great to have formatR available as a pre-commit hook to keep R projects formatted consistently.

Since version 2.11.0, pre-commit supports R.

I would be glad to help implementing one if that is desired.

fabianegli avatar Nov 07 '22 15:11 fabianegli

I'm not familiar with pre-commit. Please feel free to submit a pull request if it's simple enough. Thanks!

yihui avatar Nov 07 '22 16:11 yihui

Just for your interest, I built the R integration of pre-commit and I maintain a bunch of hooks, including a hook to format code with {styler}, at https://github.com/lorenzwalthert/precommit. You can add support for pre-commit to this {formatR} repo, as described in the link above. If you need help, let me know.

lorenzwalthert avatar Nov 07 '22 17:11 lorenzwalthert

@lorenzwalthert That looks nice - And I think for the repo I had in mind to use the pre-commit hook in I might actually end up recommending your style-files hook. And any help to implement the hook for formatR is of course welcome. I'm attempting that for the first time.

fabianegli avatar Nov 07 '22 18:11 fabianegli

I hope the above linked docs are self-explanatory, but I think you are the first one to attempt using it (apart from myself), so it's a good test to see if the docs are complete.

lorenzwalthert avatar Nov 07 '22 18:11 lorenzwalthert