Open RobinKohrs opened 1 year ago
Many thanks for opening the issue. Short answer: I'm not sure but would welcome thoughts from others, marking as help wanted accordingly.
Hi @Robinlovelace
Thank you for promoting equality among statisticians :)
I wrote an addin here freely based rstudio examples repo
It seems to work alright. The saveAndStylerEqualsAddin needs to be assign to a shortcut. When triggering this addin by shortcut, it saves the active document and then styles it. Not exactly to apply styling to any normal saving, but pretty close.
I will try for some days and make a revised PR.
Amazing, thanks @sorhawell and great work you on polars
! I'll aim to get this on CRAN seeing as there seem to be some users...
@Robinlovelace many thanks :)
I'm new to using styler. In this addin, I run default styler
first, and then styler.equals
after.
#' @export
saveAndStylerEqualsAddin = function() {
ctx = rstudioapi::getActiveDocumentContext()
rstudioapi::documentSave(id = ctx$id)
styler::style_file(path = ctx$path)
styler.equals::style_file(path = ctx$path)
}
I was unsure if possible to run both stylers in one pass from styler.equals
?
#' @export
saveAndStylerEqualsAddin = function() {
ctx = rstudioapi::getActiveDocumentContext()
rstudioapi::documentSave(id = ctx$id)
### styler::style_file(path = ctx$path) ## MAYBE NOT NEEDED?
styler.equals::style_file(path = ctx$path, [SOME EXTRA ARGS OR SOMETHING])
}
I was unsure if possible to run both stylers in one pass from
styler.equals
?
I imagine so. One way to find out: give it a spin!
Thank you so much for this package!!
I'm a bit confused by the several options R offers for styling/reformatting your code. Especially when looking at the amazing
styler
package I get a little bit lost when all I want to do is just change the<-
for the=
.Anyways... I was wondering if there is any way (certainly there is as described here https://github.com/r-lib/styler/issues/860 and here https://styler.r-lib.org/reference/styler_addins.html?q=addin ) to use this package here as the formatting option when using the addin from the
styler
packages. I'm not really understanding how to set the options in the.Rprofile
file to make this work.Especially this sentence:
"To use this style with the addin, you need to create an R package that exports this style guide, and then set the R option styler.addins_style_transformer as described here." from here https://github.com/r-lib/styler/issues/860#issuecomment-954581742 is confusing me
I tried the following in an
.Rprofile
file, but this is not right definitly...I'm sorry about any misunderstandings and really grateful for any advises.