Closed rkrug closed 9 months ago
I can’t tell you on top of my head but you should find the answer if you look at the docs. In particular https://styler.r-lib.org/articles/customizing_styler.html
I recently tried this on this particular use case. I ended up with the following script: https://rpubs.com/krlmlr/styler-resp .
I do prefer
x <- function(
a,
b
) {
}
over
x <- function(
a,
b) {
}
. This is also what the codegrip package emits -- a huge time saver. However, https://style.tidyverse.org/functions.html#long-lines-1 mandates the last form. This is unfortunate.
Because styler is about non-invasive pretty-printing, we should support keeping the first form. @lorenzwalthert: How do you feel about this, at least for strict = FALSE
?
a huge time saver.
Can you elaborate why? Maybe time is also an argument in the tidyverse style guide?
I think we should implement the style guide but for strict = FALSE
I am open.
I chose to tweak codegrip instead: https://github.com/lionel-/codegrip/pull/16.
Ok, also fine.
But this does not help me as a lonely VSCode user...
Sorry I can't support this in {styler}. It's not compliant with the tidyverse style guide...
I understand - but Is there any styler option which makes this possible, as it states "styler formats your code according to the tidyverse style guide (or your custom style guide)" on https://styler.r-lib.org?
Not with tidyverse_style()
. The part of {styler} that makes it possible is the infrastructure to run you style guide. But you have to provide your own style guide. There is no option in tidyverse_style()
for it.
Assume I have the following function definition, formatted in VS Code using the tidy verse styler:
I would prefer to have the following:
How can I modify the
tidyverse_style()
so that it is formatted as I would like to have it, i.e. have a line break in front of the) {
, unless it is in the same line as the(
in the function definition?Thanks,
Rainer