-
Notifications
You must be signed in to change notification settings - Fork 73
Overriding tidyverse function arg style #1184
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
Comments
I agree that this should be the default, but, unfortunately, since the underlying style guide specifies this behaviour, we need to stick to it. As for That said, |
Gotya, so are you saying that Edit: grkstyle does not adhere to balanced delimiters |
It's not But TBH, I'd much rather the style guide change its recommendation here. |
Say I've figured out how to customize my styler, how do I utilize it as a global standard? For example with lintr, there is a For context, I'm using VS Code to format on save and not manually styling a file from the R console. Ideally it can be modified in the Rprofile or other environment location |
I believe this may be possible in r-lib/lintr#1411 by @MichaelChirico but unclear how 🤔 |
Two options:
library(styler.noncomments)
style_text('1 # comment') # this default to transformers = nocomments_style |
a directory specific configuration for styler is an open issue: #319 |
@lorenzwalthert I have no intention of creating and distributing my own R package for modifying a single style rule. It would ideal to be able to change or remove one rule in the transformers list and have that be used. Perhaps it can be set via |
For VS code specifically, see https://github.com/REditorSupport/languageserver?tab=readme-ov-file#customizing-formatting-style. You can modify a rule inline, e.g. in the above mentioned link, but I think for caching reasons, you should also set name and version of the style guide to avoid caching issues as described in #1170 (comment). ...
transformers$style_guide_name = "rpolars_style"
transformers$style_guide_version = "0.1.0"
... |
I think it seems like the style guide might change in the future or at least allow both options since Lionel supports your point of view in https://github.com/lionel-/codegrip/pull/16, but for this to happen, I think as @IndrajeetPatil said, it needs a formal decision upstream. Depending on what happens there, we could change the behaviour or expose an argument in |
Then I am afraid you have to adhere to the style guide, or open an issue in tidyverse/style. |
Heard. Just to be crystal clear, the maintainers of options(lintr.line_length_lintr = NULL) and instead, require users to create their own R package for this behavior? |
I might be able to show you how you can modify styler to achieve what you want, but unless you create your own style guide, the option won’t be as portable as a simple one liner in a config file like for {lintr}. |
Intentions we have to make configuration
easier to access through a config file or similar as noted in #319. But time and resources and priorities are a different topic 😜 To achieve what you wanted in your original post, we would first have to expose an argument to the default style guide |
Closing in favor of #319 |
FWIW I think we'd be supportive of a style guide PR to bring it in line with codegrip behaviour. We've originally aligned our guide to the google C++ one, but after working with Rust and Typescript where the balanced style seem to be the norm we think it's best to align with these languages. |
This is now official tidyverse style see https://style.tidyverse.org/functions.html#multi-line-function-definitions Can we consider reopening this issue? |
With the latest commit on the "reverse_geocode <- function(
locations,
.progress = TRUE) {
NULL
}" -> code
styler::style_text(code)
#> reverse_geocode <- function(
#> locations,
#> .progress = TRUE
#> ) {
#> NULL
#> } Created on 2024-11-25 with reprex v2.1.1 |
Nice!! For a second I though I got a bug report in my email! 🫣 |
I guess we can close this now. |
@lorenzwalthert Should we create a new CRAN release? I would say that enough has changed to make it available to the users. |
I think we should also implement some of the other open issues that resulted from the style guide update before that. |
@lorenzwalthert So only after closing this issue? One of those items is open upstream, so it might be a while before that issue can be closed. But maybe we can try to address the other two items in it and prepare a release. |
I'd pose this in a discussion but there are not any for this repo!
The tidyverse style guide says:
However, it the closing
)
and opening{
on the same line as the last argument give me the ick! 😜 Is there a way to modify styler to put the closing paren and opening bracket on their own line when there are many function arguments?I use codegrip to format my function arguments. However, I have recently configured my environment to use styler to format on save. This one styling, though, i'd like to override.
The text was updated successfully, but these errors were encountered: