diff --git a/DESCRIPTION b/DESCRIPTION index 9c8a65e..3e888a3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,7 +19,7 @@ Suggests: rstudioapi, testthat (>= 3.0.0) Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 Config/testthat/edition: 3 URL: https://github.com/lionel-/codegrip BugReports: https://github.com/lionel-/codegrip/issues diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..2aef915 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,6 @@ +# codegrip (development version) + +* The long "flat" form for function definitions now aligns arguments using a + single indent rather than a double indent, which follows the + [tidyverse style guide](https://style.tidyverse.org/functions.html#long-lines-1) + (#20). diff --git a/R/reshape-addin.R b/R/reshape-addin.R index 69ba68f..806481a 100644 --- a/R/reshape-addin.R +++ b/R/reshape-addin.R @@ -15,7 +15,7 @@ #' Note that for function definitions, `addin_reshape()` cycles through two #' different long shapes. The traditional L form uses more horizontal space #' whereas the flat form uses less horizontal space and the arguments are -#' always aligned at double indent: +#' always aligned at single indent: #' ``` #' foo <- function(a, b, c) { #' NULL diff --git a/R/reshape-call.R b/R/reshape-call.R index 5245d02..a1da2e5 100644 --- a/R/reshape-call.R +++ b/R/reshape-call.R @@ -68,10 +68,8 @@ node_call_longer <- function(node, ..., L = FALSE, info) { if (prefix) { body <- node_text(node_call_body(node), info = info) suffix <- paste0(" ", body) - indent_factor <- 2 } else { suffix <- "" - indent_factor <- 1 } fn <- node_text(set[[1]], info = info) @@ -82,11 +80,7 @@ node_call_longer <- function(node, ..., L = FALSE, info) { new_indent_n <- xml_col2(left_paren) } else { fn <- paste0(fn, left_paren_text, "\n") - if (prefix) { - new_indent_n <- current_indent_n + base_indent * indent_factor - } else { - new_indent_n <- current_indent_n + base_indent - } + new_indent_n <- current_indent_n + base_indent } if (L) { @@ -125,7 +119,7 @@ node_call_longer <- function(node, ..., L = FALSE, info) { if (L) { arg_indent_n <- new_indent_n - current_indent_n - arg_parent_indent_n } else { - arg_indent_n <- base_indent * indent_factor - arg_parent_indent_n + arg_indent_n <- base_indent - arg_parent_indent_n } if (length(arg)) { diff --git a/README.md b/README.md index a06ad6a..b5b5b71 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ codegrip provides [RStudio addins](http://rstudio.github.io/rstudioaddins/) and -Note that for function definitions, `addin_reshape` cycles through two different long shapes. The traditional L form uses more horizontal space whereas the flat form uses less horizontal space and the arguments are always aligned at double indent: +Note that for function definitions, `addin_reshape` cycles through two different long shapes. The traditional L form uses more horizontal space whereas the flat form uses less horizontal space and the arguments are always aligned at single indent: @@ -61,7 +61,7 @@ Not yet implemented: ## Using in Visual Studio Code -`addin_reshape` is available for keybinding in VS Code. See [here](https://github.com/REditorSupport/vscode-R/wiki/RStudio-addin-support#enabling-rstudio-addin-support) for instructions on enabling general addin support. +`addin_reshape` is available for keybinding in VS Code. See [here](https://github.com/REditorSupport/vscode-R/wiki/RStudio-addin-support#enabling-rstudio-addin-support) for instructions on enabling general addin support. Once addins are enabled, add the following to `keybindings.json`: diff --git a/man/addin_reshape.Rd b/man/addin_reshape.Rd index e6dccca..234a268 100644 --- a/man/addin_reshape.Rd +++ b/man/addin_reshape.Rd @@ -23,7 +23,7 @@ list( Note that for function definitions, \code{addin_reshape()} cycles through two different long shapes. The traditional L form uses more horizontal space whereas the flat form uses less horizontal space and the arguments are -always aligned at double indent: +always aligned at single indent: \if{html}{\out{