-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Question: how do I supply arguments to the style function? #178
Comments
revisit when lorenzwalthert/precommit#178 is closed
Thanks for raising this: Indeed, {precommit} currently does not allow you to use non-default arguments for the transformer because you can only pass a style function, not a transformer function. We should fix this and depreciate the use of Context: That's the way to specify the reindention with styler without precommit. text <- '
call(
# no
)'
style_text(
text,
transformers = styler::tidyverse_style(reindention = specify_reindention(""))
) Now see the docs args: [--style_pkg=<styler>, --style_fun=<tidyverse_style>] and note that |
So I'd like to allow: args: [--style_pkg=styler, --style_transformers='tidyverse_style(reindention = specify_reindention("")']
|
- More flexibility to specify styler style (#178).
I no longer think the proposed API was a good idea, in particular because of problems in parsing quotes on windows, see #195. https://github.com/lorenzwalthert/test-docopt. I think we should make a more CLI-like interface and use key value pairs, so we can specify args like this:
We can hardcode the args (but this would limit third-party style guides), or try to pass key-value pairs and have docopt parsing them. An alternative is to use a styler config file as proposed in r-lib/styler#319. |
Better late than never @zkamvar. You should now be able to use styler as you wanted: id: style-files
args: [--scope=spaces, --reindention=specify_reindention('#')] To not indent comments at all. For this to work until we create a new release (not CRAN, just hooks), you must set |
I get super frustrated by the reindentation of comments, so I usually like to turn that off, but I cannot figure out how to pass the option reindentation = NULL to the pre-commit hook. I've tried tidyverse_style(reindentation = NULL) with no luck. Any advice?
The text was updated successfully, but these errors were encountered: