-
Notifications
You must be signed in to change notification settings - Fork 73
styler addin with "indention" as scope #475
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
Note that the following is related:
Given #463, you could: Edit: Use the CRAN version and follow the example below.
library(styler)
tidyverse_style_scope_indention <- purrr::partial(
tidyverse_style,
scope = "indention"
)
options("styler.addins.style" = "tidyverse_style_scope_indention")
This should give you the desired result. Does it work? for you |
hi, this worked! more casual users might appreciate an easier way of getting this to work though. i'm teaching a grad statistics class at stanford, and i'd love to promote the package in class (since i highlight how important good coding practices are) but in my code i use thanks a lot for your quick response! cheers, tobi |
Well, I can understand that my solution is not exactly what you were after. Also, although flexibility is a key strength of styler, we've not seen many people implementing their own style guide as described here, because it comes with quite some overhead. In particular, it would be nice to add more customization for the Addin, I agree, even if we are just talking about specifying scope and other argument within the tidyverse style guide. We thought about a shiny app but it's quite a bit of work if you want to do it right and it's not been a priority so far. If |
this is not working anymore with the following setup:
and this .Rprofile file
instead of the desired scope "indention" the plugin just uses "tokens". |
Yes, there was a breaking API change from the dev version, you must now support a transformer, not a style, as of styler v1.1.1. This makes specifying the style more flexible. options("styler.addins.style" = "styler::tidyverse_style(scope = 'indention')") See the docs: https://styler.r-lib.org/reference/styler_addins.html |
this didn't work for me. i've updated the .Rprofile file like so
but the add-in still behaves like the scope is set to "tokens" in the docs (https://styler.r-lib.org/reference/styler_addins.html) it specifies that it should be set like so:
but this also didn't work for me. |
Well, you specify indention or spaces, depending on what you want. Make sure to restart R or source the .Rprofile or just execute the line manually to set the option. Make sure you have the latest version of styler from CRAN. Does it still not work? I will check tomorrow when I have my computer with me. |
cool -- setting it like so in
i didn't have a final empty line on my in my last post, i wasn't referring to the difference between 'spaces' and 'indention' but rather the two version of writing the LHS in the thanks for your help! |
Right, sorry I forgot we renamed the option too. I should not reply to issues in my phone when they involve code and I am tired -.- glad you figured it out. |
Is it possible to change the scope for the styler addin? Specifically, I've set up a keyboard shorcut to pretty-print the selection using the styler addin.
However, instead of the default
scope = "tokens"
I would like to change it toscope = indention
.Thanks!
The text was updated successfully, but these errors were encountered: