Skip to content

How to config styler? #919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kalaschnik opened this issue Feb 28, 2022 · 5 comments
Closed

How to config styler? #919

kalaschnik opened this issue Feb 28, 2022 · 5 comments

Comments

@kalaschnik
Copy link

I sometimes run into the case where I want to provide information about parameters. Yet, when using styler my function goes from this:

my_fun <- function(
    param1,
    param2,
    param3 = list(start = 1, end = nrow(df)), # defaults to include all rows of df
    param4 = c("start", "end"), # some longer description which has a length like this comment
    param5 = FALSE) {

  print("yada yada")
}

into this:

my_fun <- function(param1,
                   param2,
                   param3 = list(start = 1, end = nrow(df)), # defaults to include all rows of df
                   param4 = c("start", "end"), # some longer description which has a length like this comment
                   param5 = FALSE) {

   print("yada yada")
}

This creates long lines with over 100 characters. Anyway, is there a way to set up a config file to enforce double-indent style (https://style.tidyverse.org/functions.html#long-lines-1)?

@lorenzwalthert
Copy link
Collaborator

There is currently an open issue for double indent with #845 but it's not implemented yet. So I'd consider that a duplicate of #845. Tangent issue: #247.

@kalaschnik
Copy link
Author

Just for clarification; as of now there is no way to config styler?

@lorenzwalthert
Copy link
Collaborator

lorenzwalthert commented Feb 28, 2022

There is a whole vignette on the topic of customization, but as far as double indent goes, you can't customize styler (unless you implement your own style guide).

@kalaschnik
Copy link
Author

Thanks for the link; there really should be a GETTING STARTED within the README.

I see that I can use transformers as an argument; yet, my question was related to having an external file such as: .stylerrc where I provide my own styler preferences without the need of repeating myself in function arguments.

@kalaschnik
Copy link
Author

Wooops; I just found this: #319. That was what I was looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants