You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can you point me to an existing rule in the tidyverse style guide that requires such a behavior? We generally only implement rules explicitly formulated there. Also, styler currently does not understand which namespace a token belongs to, i.e. it could not distinguish + from ggplot2 and the base +. Related issue: #247.
One thing you could do is to adapt the tidyverse style guide and add line breaks after + when the token afterwards is a function call, which would avoid generating line breaks for simple arithmetic operations like 1 + 1.
I am a bit surprised to be honest that Hadley has accepted style advise that is so specific to a package in the style guide 😄. Anyways I think we might derive more general rules for arithmetic
operations that involve function call. For now, I implemented what you suggested. Can you have a look at the test files in #569 I added (called ggplot2-in.R for before and ggplot2-out.R for after) and tell me if these tests look reasonable? Also, I'd like you to install that version of styler with
remotes::install_github("r-lib/styler@569")
and style your files with it and tell me if the result is satisfying. Can you do that?
Activity
lorenzwalthert commentedon Sep 17, 2019
Can you point me to an existing rule in the tidyverse style guide that requires such a behavior? We generally only implement rules explicitly formulated there. Also, styler currently does not understand which namespace a token belongs to, i.e. it could not distinguish
+from ggplot2 and the base+. Related issue: #247.lorenzwalthert commentedon Sep 17, 2019
One thing you could do is to adapt the tidyverse style guide and add line breaks after
+when the token afterwards is a function call, which would avoid generating line breaks for simple arithmetic operations like1 + 1.mine-cetinkaya-rundel commentedon Oct 16, 2019
@lorenzwalthert As a reference, the advice around line breaks for ggplot2 are now in the style guide as well: https://style.tidyverse.org/ggplot2.html.
lorenzwalthert commentedon Dec 14, 2019
I am a bit surprised to be honest that Hadley has accepted style advise that is so specific to a package in the style guide 😄. Anyways I think we might derive more general rules for arithmetic
operations that involve function call. For now, I implemented what you suggested. Can you have a look at the test files in #569 I added (called
ggplot2-in.Rfor before andggplot2-out.Rfor after) and tell me if these tests look reasonable? Also, I'd like you to install that version of styler withand style your files with it and tell me if the result is satisfying. Can you do that?
Merge pull request #569 from lorenzwalthert/issue-544
vimaloctavius commentedon Sep 1, 2020
Would love to see this feature added, easier to manage typing when using notebooks
lorenzwalthert commentedon Sep 1, 2020
@vimal739 This feature is available in the latest CRAN release and any CRAN release after December 18, 2019.
vimaloctavius commentedon Sep 2, 2020
@lorenzwalthert Wow that's great, thanks much!